File dump from Analog
This commit is contained in:
4
Keil_Studio_Cloud/.mbed
Normal file
4
Keil_Studio_Cloud/.mbed
Normal file
@ -0,0 +1,4 @@
|
||||
ROOT=.
|
||||
TARGET=SDP_K1
|
||||
TARGET_CODE=0604
|
||||
TARGET_SERIAL=0604000048824E450031700BDD8900338761000097969900
|
||||
141
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830CmdList.h
Normal file
141
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830CmdList.h
Normal file
@ -0,0 +1,141 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adBms6830CmdList.h
|
||||
* @brief: Command header file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/*! @addtogroup BMS_DRIVER
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/*! @addtogroup BMS_COMMAND BMS COMMAND
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ADBMSCOMMAND_H
|
||||
#define __ADBMSCOMMAND_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/* configuration registers commands */
|
||||
uint8_t WRCFGA[2] = { 0x00, 0x01 };
|
||||
uint8_t WRCFGB[2] = { 0x00, 0x24 };
|
||||
uint8_t RDCFGA[2] = { 0x00, 0x02 };
|
||||
uint8_t RDCFGB[2] = { 0x00, 0x26 };
|
||||
|
||||
/* Read cell voltage result registers commands */
|
||||
uint8_t RDCVA[2] = { 0x00, 0x04 };
|
||||
uint8_t RDCVB[2] = { 0x00, 0x06 };
|
||||
uint8_t RDCVC[2] = { 0x00, 0x08 };
|
||||
uint8_t RDCVD[2] = { 0x00, 0x0A };
|
||||
uint8_t RDCVE[2] = { 0x00, 0x09 };
|
||||
uint8_t RDCVF[2] = { 0x00, 0x0B };
|
||||
uint8_t RDCVALL[2] = { 0x00, 0x0C };
|
||||
|
||||
/* Read average cell voltage result registers commands commands */
|
||||
uint8_t RDACA[2] = { 0x00, 0x44 };
|
||||
uint8_t RDACB[2] = { 0x00, 0x46 };
|
||||
uint8_t RDACC[2] = { 0x00, 0x48 };
|
||||
uint8_t RDACD[2] = { 0x00, 0x4A };
|
||||
uint8_t RDACE[2] = { 0x00, 0x49 };
|
||||
uint8_t RDACF[2] = { 0x00, 0x4B };
|
||||
uint8_t RDACALL[2] = { 0x00, 0x4C };
|
||||
|
||||
/* Read s voltage result registers commands */
|
||||
uint8_t RDSVA[2] = { 0x00, 0x03 };
|
||||
uint8_t RDSVB[2] = { 0x00, 0x05 };
|
||||
uint8_t RDSVC[2] = { 0x00, 0x07 };
|
||||
uint8_t RDSVD[2] = { 0x00, 0x0D };
|
||||
uint8_t RDSVE[2] = { 0x00, 0x0E };
|
||||
uint8_t RDSVF[2] = { 0x00, 0x0F };
|
||||
uint8_t RDSALL[2] = { 0x00, 0x10 };
|
||||
|
||||
/* Read c and s results */
|
||||
uint8_t RDCSALL[2] = { 0x00, 0x11 };
|
||||
uint8_t RDACSALL[2] = { 0x00, 0x51 };
|
||||
|
||||
/* Read all AUX and all Status Registers */
|
||||
uint8_t RDASALL[2] = { 0x00, 0x35 };
|
||||
|
||||
/* Read filtered cell voltage result registers*/
|
||||
uint8_t RDFCA[2] = { 0x00, 0x12 };
|
||||
uint8_t RDFCB[2] = { 0x00, 0x13 };
|
||||
uint8_t RDFCC[2] = { 0x00, 0x14 };
|
||||
uint8_t RDFCD[2] = { 0x00, 0x15 };
|
||||
uint8_t RDFCE[2] = { 0x00, 0x16 };
|
||||
uint8_t RDFCF[2] = { 0x00, 0x17 };
|
||||
uint8_t RDFCALL[2] = { 0x00, 0x18 };
|
||||
|
||||
/* Read aux results */
|
||||
uint8_t RDAUXA[2] = { 0x00, 0x19 };
|
||||
uint8_t RDAUXB[2] = { 0x00, 0x1A };
|
||||
uint8_t RDAUXC[2] = { 0x00, 0x1B };
|
||||
uint8_t RDAUXD[2] = { 0x00, 0x1F };
|
||||
|
||||
/* Read redundant aux results */
|
||||
uint8_t RDRAXA[2] = { 0x00, 0x1C };
|
||||
uint8_t RDRAXB[2] = { 0x00, 0x1D };
|
||||
uint8_t RDRAXC[2] = { 0x00, 0x1E };
|
||||
uint8_t RDRAXD[2] = { 0x00, 0x25 };
|
||||
|
||||
/* Read status registers */
|
||||
uint8_t RDSTATA[2] = { 0x00, 0x30 };
|
||||
uint8_t RDSTATB[2] = { 0x00, 0x31 };
|
||||
uint8_t RDSTATC[2] = { 0x00, 0x32 };
|
||||
uint8_t RDSTATCERR[2] = { 0x00, 0x72 }; /* ERR */
|
||||
uint8_t RDSTATD[2] = { 0x00, 0x33 };
|
||||
uint8_t RDSTATE[2] = { 0x00, 0x34 };
|
||||
|
||||
/* Pwm registers commands */
|
||||
uint8_t WRPWM1[2] = { 0x00, 0x20 };
|
||||
uint8_t RDPWM1[2] = { 0x00, 0x22 };
|
||||
|
||||
uint8_t WRPWM2[2] = { 0x00, 0x21 };
|
||||
uint8_t RDPWM2[2] = { 0x00, 0x23 };
|
||||
|
||||
/* Clear commands */
|
||||
uint8_t CLRCELL[2] = { 0x07, 0x11 };
|
||||
uint8_t CLRAUX [2] = { 0x07, 0x12 };
|
||||
uint8_t CLRSPIN[2] = { 0x07, 0x16 };
|
||||
uint8_t CLRFLAG[2] = { 0x07, 0x17 };
|
||||
uint8_t CLRFC[2] = { 0x07, 0x14 };
|
||||
uint8_t CLOVUV[2] = { 0x07, 0x15 };
|
||||
|
||||
/* Poll adc command */
|
||||
uint8_t PLADC[2] = { 0x07, 0x18 };
|
||||
uint8_t PLAUT[2] = { 0x07, 0x19 };
|
||||
uint8_t PLCADC[2] = { 0x07, 0x1C };
|
||||
uint8_t PLSADC[2] = { 0x07, 0x1D };
|
||||
uint8_t PLAUX1[2] = { 0x07, 0x1E };
|
||||
uint8_t PLAUX2[2] = { 0x07, 0x1F };
|
||||
|
||||
/* Diagn command */
|
||||
uint8_t DIAGN[2] = {0x07 , 0x15};
|
||||
|
||||
/* GPIOs Comm commands */
|
||||
uint8_t WRCOMM[2] = { 0x07, 0x21 };
|
||||
uint8_t RDCOMM[2] = { 0x07, 0x22 };
|
||||
uint8_t STCOMM[13] = { 0x07, 0x23, 0xB9, 0xE4 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00};
|
||||
|
||||
/* Mute and Unmute commands */
|
||||
uint8_t MUTE[2] = { 0x00, 0x28 };
|
||||
uint8_t UNMUTE[2] = { 0x00, 0x29 };
|
||||
|
||||
uint8_t RSTCC[2] = { 0x00, 0x2E };
|
||||
uint8_t SNAP[2] = { 0x00, 0x2D };
|
||||
uint8_t UNSNAP[2] = { 0x00, 0x2F };
|
||||
uint8_t SRST[2] = { 0x00, 0x27 };
|
||||
|
||||
/* Read SID command */
|
||||
uint8_t RDSID[2] = { 0x00, 0x2C };
|
||||
|
||||
#endif /* __BMS_COMMAND_H */
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
620
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830Data.h
Normal file
620
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830Data.h
Normal file
@ -0,0 +1,620 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adBms6830Data.h
|
||||
* @brief: Generic bms data structure header file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
|
||||
/*! @addtogroup BMS DRIVER
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/*! @addtogroup BMS_DATA BMS DATA
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ADBMSDATA_H
|
||||
#define __ADBMSDATA_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define CELL 16 /* Bms ic number of cell */
|
||||
#define AUX 12 /* Bms ic number of Aux */
|
||||
#define RAUX 10 /* Bms ic number of RAux */
|
||||
#define PWMA 12 /* Bms ic number of PWMA */
|
||||
#define PWMB 4 /* Bms ic number of PWMB */
|
||||
#define COMM 3 /* GPIO communication comm reg */
|
||||
#define RSID 6 /* Bms ic number of SID byte */
|
||||
#define TX_DATA 6 /* Bms tx data byte */
|
||||
#define RX_DATA 8 /* Bms rx data byte */
|
||||
#define RDCVALL_SIZE 34 /* RDCVALL data byte size */
|
||||
#define RDSALL_SIZE 34 /* RDSALL data byte size */
|
||||
#define RDACALL_SIZE 34 /* RDACALL data byte size */
|
||||
#define RDFCALL_SIZE 34 /* RDFCALL data byte size */
|
||||
#define RDCSALL_SIZE 66 /* RDCSALL data byte size */
|
||||
#define RDASALL_SIZE 70 /* RDASALL data byte size */
|
||||
#define RDACSALL_SIZE 66 /* RDACSALL data byte size */
|
||||
|
||||
/* For ADBMS6830 config register structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t refon :1;
|
||||
uint8_t cth :3;
|
||||
uint8_t flag_d :8;
|
||||
uint8_t soakon :1;
|
||||
uint8_t owrng :1;
|
||||
uint8_t owa :3;
|
||||
uint16_t gpo :10;
|
||||
uint8_t snap :1;
|
||||
uint8_t mute_st :1;
|
||||
uint8_t comm_bk :1;
|
||||
uint8_t fc :3;
|
||||
}cfa_;
|
||||
|
||||
/* For ADBMS6830 config register structure */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vuv :16;
|
||||
uint16_t vov :16;
|
||||
uint8_t dtmen :1;
|
||||
uint8_t dtrng :1;
|
||||
uint8_t dcto :6;
|
||||
uint16_t dcc :16;
|
||||
}cfb_;
|
||||
|
||||
/* Cell Voltage Data structure */
|
||||
typedef struct
|
||||
{
|
||||
int16_t c_codes[CELL]; /* Cell Voltage Codes */
|
||||
} cv_;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t ac_codes[CELL]; /* Average Cell Voltage Codes */
|
||||
} acv_;
|
||||
|
||||
/* S Voltage Data structure */
|
||||
typedef struct
|
||||
{
|
||||
int16_t sc_codes[CELL]; /* S Voltage Codes */
|
||||
} scv_;
|
||||
|
||||
/* Filtered Cell Voltage Data structure */
|
||||
typedef struct
|
||||
{
|
||||
int16_t fc_codes[CELL]; /* filtered Cell Voltage Codes */
|
||||
} fcv_;
|
||||
|
||||
/* Aux Voltage Data Structure*/
|
||||
typedef struct
|
||||
{
|
||||
int16_t a_codes[AUX]; /* Aux Voltage Codes */
|
||||
} ax_;
|
||||
|
||||
/* Redundant Aux Voltage Data Structure*/
|
||||
typedef struct
|
||||
{
|
||||
int16_t ra_codes[RAUX]; /* Aux Voltage Codes */
|
||||
} rax_;
|
||||
|
||||
/* Status A register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vref2;
|
||||
uint16_t itmp;
|
||||
uint16_t vref3;
|
||||
} sta_;
|
||||
|
||||
/* Status B register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vd;
|
||||
uint16_t va;
|
||||
uint16_t vr4k;
|
||||
} stb_;
|
||||
|
||||
/* Status C register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t cs_flt;
|
||||
uint8_t va_ov :1;
|
||||
uint8_t va_uv :1;
|
||||
uint8_t vd_ov :1;
|
||||
uint8_t vd_uv :1;
|
||||
uint8_t otp1_ed :1;
|
||||
uint8_t otp1_med:1;
|
||||
uint8_t otp2_ed :1;
|
||||
uint8_t otp2_med:1;
|
||||
uint8_t vde :1;
|
||||
uint8_t vdel :1;
|
||||
uint8_t comp :1;
|
||||
uint8_t spiflt :1;
|
||||
uint8_t sleep :1;
|
||||
uint8_t thsd :1;
|
||||
uint8_t tmodchk :1;
|
||||
uint8_t oscchk :1;
|
||||
} stc_;
|
||||
|
||||
/* ClrFlag register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t cl_csflt;
|
||||
uint8_t cl_smed :1;
|
||||
uint8_t cl_sed :1;
|
||||
uint8_t cl_cmed :1;
|
||||
uint8_t cl_ced :1;
|
||||
uint8_t cl_vduv :1;
|
||||
uint8_t cl_vdov :1;
|
||||
uint8_t cl_vauv :1;
|
||||
uint8_t cl_vaov :1;
|
||||
uint8_t cl_oscchk :1;
|
||||
uint8_t cl_tmode :1;
|
||||
uint8_t cl_thsd :1;
|
||||
uint8_t cl_sleep :1;
|
||||
uint8_t cl_spiflt :1;
|
||||
uint8_t cl_vdel :1;
|
||||
uint8_t cl_vde :1;
|
||||
} clrflag_;
|
||||
|
||||
/* Status D register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t c_ov[CELL];
|
||||
uint8_t c_uv[CELL];
|
||||
uint8_t ct :6;
|
||||
uint8_t cts :2;
|
||||
uint8_t oc_cntr;
|
||||
} std_;
|
||||
|
||||
/* Status E register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t gpi :10;
|
||||
uint8_t rev :4;
|
||||
} ste_;
|
||||
|
||||
/* Pwm register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pwma[PWMA];
|
||||
} pwma_;
|
||||
|
||||
/*PWMB Register Structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pwmb[PWMB];
|
||||
} pwmb_;
|
||||
|
||||
/* COMM register Data structure*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t fcomm[COMM];
|
||||
uint8_t icomm[COMM];
|
||||
uint8_t data[COMM];
|
||||
} com_;
|
||||
|
||||
/*SID Register Structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sid[RSID];
|
||||
} sid_;
|
||||
|
||||
/* Transmit byte and recived byte data structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t tx_data[TX_DATA];
|
||||
uint8_t rx_data[RX_DATA];
|
||||
} ic_register_;
|
||||
|
||||
/* Command counter and pec error data Structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t cmd_cntr;
|
||||
uint8_t cfgr_pec;
|
||||
uint8_t cell_pec;
|
||||
uint8_t acell_pec;
|
||||
uint8_t scell_pec;
|
||||
uint8_t fcell_pec;
|
||||
uint8_t aux_pec;
|
||||
uint8_t raux_pec;
|
||||
uint8_t stat_pec;
|
||||
uint8_t comm_pec;
|
||||
uint8_t pwm_pec;
|
||||
uint8_t sid_pec;
|
||||
} cmdcnt_pec_;
|
||||
|
||||
/* Diagnostic test result data structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t osc_mismatch;
|
||||
uint8_t supply_error;
|
||||
uint8_t supply_ovuv;
|
||||
uint8_t thsd;
|
||||
uint8_t fuse_ed;
|
||||
uint8_t fuse_med;
|
||||
uint8_t tmodchk;
|
||||
uint8_t cell_ow[CELL];
|
||||
uint8_t cellred_ow[CELL];
|
||||
uint8_t aux_ow[(AUX-2)];
|
||||
} diag_test_;
|
||||
|
||||
/* Aux open wire data structure */
|
||||
typedef struct
|
||||
{
|
||||
int cell_ow_even[CELL];
|
||||
int cell_ow_odd[CELL];
|
||||
} cell_ow_;
|
||||
|
||||
/* Aux open wire data structure */
|
||||
typedef struct
|
||||
{
|
||||
int aux_pup_up[(AUX-2)];
|
||||
int aux_pup_down[(AUX-2)];
|
||||
} aux_ow_;
|
||||
|
||||
/* BMS ic main structure */
|
||||
typedef struct
|
||||
{
|
||||
cfa_ tx_cfga;
|
||||
cfa_ rx_cfga;
|
||||
cfb_ tx_cfgb;
|
||||
cfb_ rx_cfgb;
|
||||
clrflag_ clflag;
|
||||
cv_ cell;
|
||||
acv_ acell;
|
||||
scv_ scell;
|
||||
fcv_ fcell;
|
||||
ax_ aux;
|
||||
rax_ raux;
|
||||
sta_ stata;
|
||||
stb_ statb;
|
||||
stc_ statc;
|
||||
std_ statd;
|
||||
ste_ state;
|
||||
com_ comm;
|
||||
pwma_ PwmA;
|
||||
pwmb_ PwmB;
|
||||
sid_ sid;
|
||||
ic_register_ configa;
|
||||
ic_register_ configb;
|
||||
ic_register_ clrflag;
|
||||
ic_register_ stat;
|
||||
ic_register_ com;
|
||||
ic_register_ pwma;
|
||||
ic_register_ pwmb;
|
||||
ic_register_ rsid;
|
||||
cmdcnt_pec_ cccrc;
|
||||
aux_ow_ gpio;
|
||||
cell_ow_ owcell;
|
||||
diag_test_ diag_result;
|
||||
} cell_asic;
|
||||
|
||||
/*!
|
||||
* \enum Loop Measurement ENABLED or DISABLED.
|
||||
*/
|
||||
typedef enum { DISABLED = 0X0, ENABLED = 0X1} LOOP_MEASURMENT;
|
||||
|
||||
/**************************************** CMDEnums *************************************************/
|
||||
/*!
|
||||
* \enum GPIO CHANNEL
|
||||
* CH: GPIO Channels.
|
||||
*/
|
||||
/* Channel selection */
|
||||
typedef enum
|
||||
{
|
||||
AUX_ALL = 0,
|
||||
GPIO1,
|
||||
GPIO2,
|
||||
GPIO3,
|
||||
GPIO4,
|
||||
GPIO5,
|
||||
GPIO6,
|
||||
GPIO7,
|
||||
GPIO8,
|
||||
GPIO9,
|
||||
GPIO10,
|
||||
VREF2,
|
||||
LD03V,
|
||||
LD05V,
|
||||
TEMP,
|
||||
V_POSTIVE_2_NAGATIVE,
|
||||
V_NAGATIVE,
|
||||
VR4K,
|
||||
VREF3
|
||||
}CH;
|
||||
|
||||
/*!
|
||||
* \enum RD
|
||||
* RD: Read Device.
|
||||
*/
|
||||
typedef enum { RD_OFF = 0X0, RD_ON = 0X1} RD;
|
||||
|
||||
/*!
|
||||
* \enum CONT
|
||||
* CONT: Continuous or single measurement.
|
||||
*/
|
||||
/* Continuous or single measurement */
|
||||
typedef enum { SINGLE = 0X0, CONTINUOUS = 0X1} CONT;
|
||||
|
||||
/*!
|
||||
* \enum OW_C_S
|
||||
* OW_C_S: Open wire c/s.
|
||||
*/
|
||||
/* Open wire c/s adcs */
|
||||
typedef enum { OW_OFF_ALL_CH = 0X0, OW_ON_EVEN_CH, OW_ON_ODD_CH, OW_ON_ALL_CH} OW_C_S;
|
||||
|
||||
/*!
|
||||
* \enum OW_AUX
|
||||
* OW_AUX: Open wire Aux.
|
||||
*/
|
||||
/* Open wire AUX */
|
||||
typedef enum { AUX_OW_OFF = 0X0, AUX_OW_ON = 0X1} OW_AUX;
|
||||
|
||||
/*!
|
||||
* \enum PUP
|
||||
* PUP: Pull Down current during aux conversion.
|
||||
*/
|
||||
/* Pull Down current during aux conversion (if OW = 1) */
|
||||
typedef enum { PUP_DOWN = 0X0, PUP_UP = 0X1 } PUP;
|
||||
|
||||
/*!
|
||||
* \enum DCP
|
||||
* DCP: Discharge permitted.
|
||||
*/
|
||||
/* Discharge permitted */
|
||||
typedef enum { DCP_OFF = 0X0, DCP_ON = 0X1} DCP;
|
||||
|
||||
/*!
|
||||
* \enum RSTF
|
||||
* RSTF: Reset Filter.
|
||||
*/
|
||||
/* Reset filter */
|
||||
typedef enum { RSTF_OFF = 0x0, RSTF_ON = 0x1 } RSTF;
|
||||
|
||||
/*!
|
||||
* \enum ERR
|
||||
* ERR: Inject error is spi read out.
|
||||
*/
|
||||
/* Inject error is spi read out */
|
||||
typedef enum { WITHOUT_ERR = 0x0, WITH_ERR = 0x1 } ERR;
|
||||
|
||||
/**************************************** Mem bits *************************************************/
|
||||
/* Configuration Register A */
|
||||
|
||||
/*!
|
||||
* \enum REFON
|
||||
* REFON: Refernece remains power up/down.
|
||||
*/
|
||||
/* Refernece remains power up/down */
|
||||
typedef enum { PWR_DOWN = 0x0, PWR_UP = 0x1 } REFON;
|
||||
|
||||
/*!
|
||||
* \enum CTH
|
||||
* CTH: Comparison voltages threshold C vs S.
|
||||
*/
|
||||
/* Comparison voltages threshold C vs S*/
|
||||
typedef enum
|
||||
{
|
||||
CVT_5_1mV = 0, /* 5.1mV */
|
||||
CVT_8_1mV, /* 8.1mV (Default) */
|
||||
CVT_10_05mV, /* 10.05mV */
|
||||
CVT_15mV, /* 15mV */
|
||||
CVT_22_5mV, /* 22.5mV */
|
||||
CVT_45mV, /* 45mV */
|
||||
CVT_75mV, /* 75mV */
|
||||
CVT_135mV, /* 135mV */
|
||||
}CTH;
|
||||
|
||||
/*!
|
||||
* \enum FLAG_D
|
||||
* FLAG_D: Fault flags.
|
||||
*/
|
||||
/* Fault flags */
|
||||
typedef enum
|
||||
{
|
||||
FLAG_D0 = 0, /* Force oscillator counter fast */
|
||||
FLAG_D1, /* Force oscillator counter slow */
|
||||
FLAG_D2, /* Force Supply Error detection */
|
||||
FLAG_D3, /* FLAG_D[3]: 1--> Select Supply OV and delta detection, 0 --> Selects UV */
|
||||
FLAG_D4, /* Set THSD */
|
||||
FLAG_D5, /* Force Fuse ED */
|
||||
FLAG_D6, /* Force Fuse MED */
|
||||
FLAG_D7, /* Force TMODCHK */
|
||||
} FLAG_D;
|
||||
|
||||
typedef enum { FLAG_CLR = 0x0, FLAG_SET = 0x1 } CFGA_FLAG;
|
||||
|
||||
/*!
|
||||
* \enum CL FLAG
|
||||
* FLAG: Fault Clear.
|
||||
*/
|
||||
typedef enum { CL_FLAG_CLR = 0x0, CL_FLAG_SET = 0x1 } FLAG;
|
||||
|
||||
/*!
|
||||
* \enum SOAKON
|
||||
* SOAKON: Enables or disable soak time for all commands.
|
||||
*/
|
||||
/* Enables or disable soak time for all commands */
|
||||
typedef enum { SOAKON_CLR = 0x0, SOAKON_SET = 0x1 } SOAKON;
|
||||
|
||||
|
||||
/* Open wire sokon time owa */
|
||||
typedef enum {OWA0 = 0x0, OWA1, OWA2, OWA3, OWA4, OWA5, OWA6, OWA7} OWA;
|
||||
|
||||
/*!
|
||||
* \enum OWRNG
|
||||
* OWRNG: Set soak time range Long/Short.
|
||||
*/
|
||||
/* Set soak time range Long/Short */
|
||||
typedef enum { SHORT = 0x0, LONG = 0x1 } OWRNG;
|
||||
|
||||
|
||||
/*!
|
||||
* \enum OW_TIME
|
||||
* OW_TIME:Open Wire Soak times
|
||||
* For Aux commands. If OWRNG=0, Soak time = 2^(6 +OWA[2:0]) Clocks (32 us 4.1 ms)
|
||||
* For Aux commands. If OWRNG=1, Soak time = 2^(13+OWA[2:0]) Clocks (41 ms 524 ms)
|
||||
*/
|
||||
typedef enum { TIME_32US_TO_4_1MS = 0x0, TIME_41MS_TO_524MS = 0x1 } OW_TIME;
|
||||
|
||||
/*!
|
||||
* \enum GPO
|
||||
* GPO: GPO Pins.
|
||||
*/
|
||||
/* GPO Pins */
|
||||
typedef enum
|
||||
{
|
||||
GPO1 = 0,
|
||||
GPO2,
|
||||
GPO3,
|
||||
GPO4,
|
||||
GPO5,
|
||||
GPO6,
|
||||
GPO7,
|
||||
GPO8,
|
||||
GPO9,
|
||||
GPO10,
|
||||
} GPO;
|
||||
|
||||
/*!
|
||||
* \enum GPIO
|
||||
* GPIO: GPIO Pin Control.
|
||||
*/
|
||||
/* GPO Pin Control */
|
||||
typedef enum { GPO_CLR = 0x0, GPO_SET = 0x1 } CFGA_GPO;
|
||||
|
||||
/*!
|
||||
* \enum IIR_FPA
|
||||
* IIR_FPA: IIR Filter Parameter.
|
||||
*/
|
||||
/* IIR Filter Parameter */
|
||||
typedef enum
|
||||
{
|
||||
IIR_FPA_OFF = 0, /* Filter Disabled */
|
||||
IIR_FPA2, /* 110 Hz -3dB Frequency */
|
||||
IIR_FPA4, /* 45 Hz -3dB Frequency */
|
||||
IIR_FPA8, /* 21 Hz -3dB Frequency */
|
||||
IIR_FPA16, /* 10 Hz -3dB Frequency */
|
||||
IIR_FPA32, /* 5 Hz -3dB Frequency */
|
||||
IIR_FPA128, /* 1.25 Hz -3dB Frequency */
|
||||
IIR_FPA256, /* 0.625 Hz -3dB Frequency */
|
||||
}IIR_FPA;
|
||||
|
||||
/*!
|
||||
* \enum COMM_BK
|
||||
* COMM_BK: Communication Break.
|
||||
*/
|
||||
/* Communication Break */
|
||||
typedef enum { COMM_BK_OFF = 0x0, COMM_BK_ON = 0x1 } COMM_BK;
|
||||
|
||||
/*!
|
||||
* \enum SNAPSHOT
|
||||
* SNAPSHOT: Snapshot.
|
||||
*/
|
||||
/* Snapshot */
|
||||
typedef enum { SNAP_OFF = 0x0, SNAP_ON = 0x1 } SNAPSHOT;
|
||||
|
||||
/* Configuration Register B */
|
||||
|
||||
/*!
|
||||
* \enum DTMEN
|
||||
* DTMEN: Enable Dis-charge Timer Monitor.
|
||||
*/
|
||||
/* Enable Dis-charge Timer Monitor */
|
||||
typedef enum { DTMEN_OFF = 0x0, DTMEN_ON = 0x1 } DTMEN;
|
||||
|
||||
/*!
|
||||
* \enum DTRNG
|
||||
* DTRNG: Discharge Timer Range Setting.
|
||||
*/
|
||||
/* Discharge Timer Range Setting */
|
||||
typedef enum { RANG_0_TO_63_MIN = 0x0, RANG_0_TO_16_8_HR = 0x1 } DTRNG;
|
||||
|
||||
/*!
|
||||
* \enum DCTO
|
||||
* DCTO: DCTO timeout values.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DCTO_TIMEOUT = 0,
|
||||
TIME_1MIN_OR_0_26HR,
|
||||
TIME_2MIN_OR_0_53HR,
|
||||
TIME_3MIN_OR_0_8HR,
|
||||
TIME_4MIN_OR_1_06HR,
|
||||
TIME_5MIN_OR_1_33HR,
|
||||
TIME_6MIN_OR_1_6HR,
|
||||
/* If required more time out value add here */
|
||||
} DCTO;
|
||||
|
||||
/*!
|
||||
* \enum PWM
|
||||
* PWM: PWM Duty cycle.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PWM_0_0_PCT = 0, /* 0.0% (default) */
|
||||
PWM_6_6_PCT, /* 6.6% */
|
||||
PWM_13_2_PCT, /* 13.2% */
|
||||
PWM_19_8_PCT, /* 19.8% */
|
||||
PWM_26_4_PCT, /* 26.4% */
|
||||
PWM_33_0_PCT, /* 33.0% */
|
||||
PWM_39_6_PCT, /* 39.6% */
|
||||
PWM_46_2_PCT, /* 46.2% */
|
||||
PWM_52_8_PCT, /* 52.8% */
|
||||
PWM_59_4_PCT, /* 59.4% */
|
||||
PWM_66_0_PCT, /* 66.0% */
|
||||
PWM_72_6_PCT, /* 72.6% */
|
||||
PWM_79_2_PCT, /* 79.2% */
|
||||
PWM_85_8_PCT, /* 85.8% */
|
||||
PWM_92_4_PCT, /* 92.4% */
|
||||
PWM_100_0_PCT, /* ~100.0% */
|
||||
} PWM_DUTY;
|
||||
|
||||
/*!
|
||||
* \enum DCC
|
||||
* DCC: DCC bits.
|
||||
*/
|
||||
/* DCC bits */
|
||||
typedef enum
|
||||
{
|
||||
DCC1 = 0,
|
||||
DCC2,
|
||||
DCC3,
|
||||
DCC4,
|
||||
DCC5,
|
||||
DCC6,
|
||||
DCC7,
|
||||
DCC8,
|
||||
DCC9,
|
||||
DCC10,
|
||||
DCC11,
|
||||
DCC12,
|
||||
DCC13,
|
||||
DCC14,
|
||||
DCC15,
|
||||
DCC16,
|
||||
} DCC;
|
||||
|
||||
/*!
|
||||
* \enum DCC_BIT
|
||||
* DCC_BIT: Discharge cell set and claer.
|
||||
*/
|
||||
/* Discharge cell set and claer */
|
||||
typedef enum { DCC_BIT_CLR = 0x0, DCC_BIT_SET = 0x1 } DCC_BIT;
|
||||
|
||||
/* General Enums */
|
||||
typedef enum { ALL_GRP = 0x0, A,B, C, D, E, F ,NONE} GRP;
|
||||
typedef enum { Cell = 0x0, Aux, RAux, Status, Pwm, AvgCell, S_volt, F_volt, Config, Comm, Sid, Clrflag, Rdcvall, Rdacall, Rdsall, Rdcsall, Rdacsall, Rdfcall, Rdasall} TYPE;
|
||||
typedef enum { PASS , FAIL } RESULT ;
|
||||
typedef enum { OSC_MISMATCH = 0x0, SUPPLY_ERROR, THSD, FUSE_ED, FUSE_MED, TMODCHK} DIAGNOSTIC_TYPE;
|
||||
#endif /* __BMS_DATA_H */
|
||||
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
85
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830GenericType.h
Normal file
85
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830GenericType.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adBms6830GenericType.h
|
||||
* @brief: Generic Type function header file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/** @addtogroup BMS_DRIVER
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup GENERIC_TYPE GENERIC TYPE
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
#ifndef __adBmsGenericType_H
|
||||
#define __adBmsGenericType_H
|
||||
|
||||
#include "adbms_main.h"
|
||||
|
||||
/* Calculates and returns the CRC15Table */
|
||||
uint16_t Pec15_Calc
|
||||
(
|
||||
uint8_t len, /* Number of bytes that will be used to calculate a PEC */
|
||||
uint8_t *data /* Array of data that will be used to calculate a PEC */
|
||||
);
|
||||
uint16_t pec10_calc(bool rx_cmd, int len, uint8_t *data);
|
||||
|
||||
void spiSendCmd(uint8_t tx_cmd[2]);
|
||||
|
||||
void spiReadData
|
||||
(
|
||||
uint8_t tIC,
|
||||
uint8_t tx_cmd[2],
|
||||
uint8_t *rx_data,
|
||||
uint8_t *pec_error,
|
||||
uint8_t *cmd_cntr,
|
||||
uint8_t regData_size
|
||||
);
|
||||
void spiWriteData
|
||||
(
|
||||
uint8_t tIC,
|
||||
uint8_t tx_cmd[2],
|
||||
uint8_t *data
|
||||
);
|
||||
void adBmsReadData(uint8_t tIC, cell_asic *ic, uint8_t cmd_arg[2], TYPE type, GRP group);
|
||||
void adBmsWriteData(uint8_t tIC, cell_asic *ic, uint8_t cmd_arg[2], TYPE type, GRP group);
|
||||
uint32_t adBmsPollAdc(uint8_t tx_cmd[2]);
|
||||
|
||||
void adBms6830_Adcv
|
||||
(
|
||||
RD rd,
|
||||
CONT cont,
|
||||
DCP dcp,
|
||||
RSTF rstf,
|
||||
OW_C_S owcs
|
||||
);
|
||||
|
||||
void adBms6830_Adsv
|
||||
(
|
||||
CONT cont,
|
||||
DCP dcp,
|
||||
OW_C_S owcs
|
||||
);
|
||||
|
||||
void adBms6830_Adax
|
||||
(
|
||||
OW_AUX owaux,
|
||||
PUP pup,
|
||||
CH ch
|
||||
);
|
||||
|
||||
void adBms6830_Adax2
|
||||
(
|
||||
CH ch
|
||||
);
|
||||
|
||||
#endif
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
63
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830ParseCreate.h
Normal file
63
Keil_Studio_Cloud/ADBMS6830/inc/adBms6830ParseCreate.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adBms6830ParseCreate.h
|
||||
* @brief: Data parse create helper function header file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/** @addtogroup BMS_DRIVER
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup PARSE_CREATE PARSE CREATE DATA
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
#ifndef __ADBMSPARSECREATE_H
|
||||
#define __ADBMSPARSECREATE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "adBms6830Data.h"
|
||||
|
||||
uint16_t SetOverVoltageThreshold(float volt);
|
||||
uint16_t SetUnderVoltageThreshold(float voltage);
|
||||
uint8_t ConfigA_Flag(FLAG_D flag_d, CFGA_FLAG flag);
|
||||
uint16_t ConfigA_Gpo(GPO gpo, CFGA_GPO stat);
|
||||
uint16_t ConfigB_DccBit(DCC dcc, DCC_BIT dccbit);
|
||||
void SetConfigB_DischargeTimeOutValue(uint8_t tIC, cell_asic *ic, DTRNG timer_rang, DCTO timeout_value);
|
||||
void SetPwmDutyCycle(uint8_t tIC, cell_asic *ic, PWM_DUTY duty_cycle);
|
||||
void adBms6830ParseConfiga(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParseConfigb(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParseConfig(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *data);
|
||||
void adBms6830ParseCell(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *cv_data);
|
||||
void adBms6830ParseAverageCell(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *acv_data);
|
||||
void adBms6830ParseSCell(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *scv_data);
|
||||
void adBms6830ParseFCell(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *fcv_data);
|
||||
void adBms6830ParseAux(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *aux_data);
|
||||
void adBms6830ParseRAux(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *raux_data);
|
||||
void adBms6830ParseStatusA(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParseStatusB(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParseStatusC(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParseStatusD(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParseStatusE(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParseStatus(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *data);
|
||||
void adBms6830ParseComm(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParsePwma(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParsePwmb(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
void adBms6830ParsePwm(uint8_t tIC, cell_asic *ic, GRP grp, uint8_t *data);
|
||||
void adBms6830CreateConfiga(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830CreateConfigb(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830CreateClrflagData(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830CreateComm(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830CreatePwma(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830CreatePwmb(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830ParseSID(uint8_t tIC, cell_asic *ic, uint8_t *data);
|
||||
|
||||
#endif
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
871
Keil_Studio_Cloud/ADBMS6830/src/adBms6830GenericType.cpp
Normal file
871
Keil_Studio_Cloud/ADBMS6830/src/adBms6830GenericType.cpp
Normal file
@ -0,0 +1,871 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: Adbms6830GenericType.c
|
||||
* @brief: Generic function driver file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/*! \addtogroup BMS DRIVER
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @addtogroup GENERIC_TYPE GENERIC TYPE
|
||||
* @{
|
||||
*
|
||||
This documentation provides details about BMS driver APIs and their usage.
|
||||
Using the BMS Driver Application can:
|
||||
- Read/Write the configuration registers of the BMS devices stacked in daisy chaining.
|
||||
- Send commands and Read the Cell Voltages, Aux Voltages and Status registers (Sum of cells, Internal Die temperature etc.)
|
||||
|
||||
*/
|
||||
#include "common.h"
|
||||
#include "adbms_main.h"
|
||||
#ifdef MBED
|
||||
extern Serial pc;
|
||||
#endif
|
||||
/**************************************** BMS Driver APIs definitions ********************************************/
|
||||
/* Precomputed CRC15 Table */
|
||||
const uint16_t Crc15Table[256] =
|
||||
{
|
||||
0x0000,0xc599, 0xceab, 0xb32, 0xd8cf, 0x1d56, 0x1664, 0xd3fd, 0xf407, 0x319e, 0x3aac,
|
||||
0xff35, 0x2cc8, 0xe951, 0xe263, 0x27fa, 0xad97, 0x680e, 0x633c, 0xa6a5, 0x7558, 0xb0c1,
|
||||
0xbbf3, 0x7e6a, 0x5990, 0x9c09, 0x973b, 0x52a2, 0x815f, 0x44c6, 0x4ff4, 0x8a6d, 0x5b2e,
|
||||
0x9eb7, 0x9585, 0x501c, 0x83e1, 0x4678, 0x4d4a, 0x88d3, 0xaf29, 0x6ab0, 0x6182, 0xa41b,
|
||||
0x77e6, 0xb27f, 0xb94d, 0x7cd4, 0xf6b9, 0x3320, 0x3812, 0xfd8b, 0x2e76, 0xebef, 0xe0dd,
|
||||
0x2544, 0x2be, 0xc727, 0xcc15, 0x98c, 0xda71, 0x1fe8, 0x14da, 0xd143, 0xf3c5, 0x365c,
|
||||
0x3d6e, 0xf8f7,0x2b0a, 0xee93, 0xe5a1, 0x2038, 0x7c2, 0xc25b, 0xc969, 0xcf0, 0xdf0d,
|
||||
0x1a94, 0x11a6, 0xd43f, 0x5e52, 0x9bcb, 0x90f9, 0x5560, 0x869d, 0x4304, 0x4836, 0x8daf,
|
||||
0xaa55, 0x6fcc, 0x64fe, 0xa167, 0x729a, 0xb703, 0xbc31, 0x79a8, 0xa8eb, 0x6d72, 0x6640,
|
||||
0xa3d9, 0x7024, 0xb5bd, 0xbe8f, 0x7b16, 0x5cec, 0x9975, 0x9247, 0x57de, 0x8423, 0x41ba,
|
||||
0x4a88, 0x8f11, 0x57c, 0xc0e5, 0xcbd7, 0xe4e, 0xddb3, 0x182a, 0x1318, 0xd681, 0xf17b,
|
||||
0x34e2, 0x3fd0, 0xfa49, 0x29b4, 0xec2d, 0xe71f, 0x2286, 0xa213, 0x678a, 0x6cb8, 0xa921,
|
||||
0x7adc, 0xbf45, 0xb477, 0x71ee, 0x5614, 0x938d, 0x98bf, 0x5d26, 0x8edb, 0x4b42, 0x4070,
|
||||
0x85e9, 0xf84, 0xca1d, 0xc12f, 0x4b6, 0xd74b, 0x12d2, 0x19e0, 0xdc79, 0xfb83, 0x3e1a, 0x3528,
|
||||
0xf0b1, 0x234c, 0xe6d5, 0xede7, 0x287e, 0xf93d, 0x3ca4, 0x3796, 0xf20f, 0x21f2, 0xe46b, 0xef59,
|
||||
0x2ac0, 0xd3a, 0xc8a3, 0xc391, 0x608, 0xd5f5, 0x106c, 0x1b5e, 0xdec7, 0x54aa, 0x9133, 0x9a01,
|
||||
0x5f98, 0x8c65, 0x49fc, 0x42ce, 0x8757, 0xa0ad, 0x6534, 0x6e06, 0xab9f, 0x7862, 0xbdfb, 0xb6c9,
|
||||
0x7350, 0x51d6, 0x944f, 0x9f7d, 0x5ae4, 0x8919, 0x4c80, 0x47b2, 0x822b, 0xa5d1, 0x6048, 0x6b7a,
|
||||
0xaee3, 0x7d1e, 0xb887, 0xb3b5, 0x762c, 0xfc41, 0x39d8, 0x32ea, 0xf773, 0x248e, 0xe117, 0xea25,
|
||||
0x2fbc, 0x846, 0xcddf, 0xc6ed, 0x374, 0xd089, 0x1510, 0x1e22, 0xdbbb, 0xaf8, 0xcf61, 0xc453,
|
||||
0x1ca, 0xd237, 0x17ae, 0x1c9c, 0xd905, 0xfeff, 0x3b66, 0x3054, 0xf5cd, 0x2630, 0xe3a9, 0xe89b,
|
||||
0x2d02, 0xa76f, 0x62f6, 0x69c4, 0xac5d, 0x7fa0, 0xba39, 0xb10b, 0x7492, 0x5368, 0x96f1, 0x9dc3,
|
||||
0x585a, 0x8ba7, 0x4e3e, 0x450c, 0x8095
|
||||
};
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: Pec15_Calc
|
||||
* @brief CRC15 Pec Calculation Function
|
||||
*
|
||||
* @details This function calculates and return the CRC15 value
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] Len Data length
|
||||
*
|
||||
* @param [in] *data Data pointer
|
||||
*
|
||||
* @return CRC15_Value
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
uint16_t Pec15_Calc
|
||||
(
|
||||
uint8_t len, /* Number of bytes that will be used to calculate a PEC */
|
||||
uint8_t *data /* Array of data that will be used to calculate a PEC */
|
||||
)
|
||||
{
|
||||
uint16_t remainder,addr;
|
||||
remainder = 16; /* initialize the PEC */
|
||||
for (uint8_t i = 0; i<len; i++) /* loops for each byte in data array */
|
||||
{
|
||||
addr = (((remainder>>7)^data[i])&0xff);/* calculate PEC table address */
|
||||
remainder = ((remainder<<8)^Crc15Table[addr]);
|
||||
}
|
||||
return(remainder*2);/* The CRC15 has a 0 in the LSB so the remainder must be multiplied by 2 */
|
||||
}
|
||||
|
||||
uint16_t pec10_calc(bool rx_cmd, int len, uint8_t *data)
|
||||
{
|
||||
uint16_t remainder = 16; /* PEC_SEED; 0000010000 */
|
||||
uint16_t polynom = 0x8F; /* x10 + x7 + x3 + x2 + x + 1 <- the CRC15 polynomial 100 1000 1111 48F */
|
||||
|
||||
/* Perform modulo-2 division, a byte at a time. */
|
||||
for (uint8_t pbyte = 0; pbyte < len; ++pbyte)
|
||||
{
|
||||
/* Bring the next byte into the remainder. */
|
||||
remainder ^= (uint16_t)(data[pbyte] << 2);
|
||||
/* Perform modulo-2 division, a bit at a time.*/
|
||||
for (uint8_t bit_ = 8; bit_ > 0; --bit_)
|
||||
{
|
||||
/* Try to divide the current data bit. */
|
||||
if ((remainder & 0x200) > 0)//equivalent to remainder & 2^14 simply check for MSB
|
||||
{
|
||||
remainder = (uint16_t)((remainder << 1));
|
||||
remainder = (uint16_t)(remainder ^ polynom);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainder = (uint16_t)(remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rx_cmd == true)
|
||||
{
|
||||
remainder ^= (uint16_t)((data[len] & 0xFC) << 2);
|
||||
/* Perform modulo-2 division, a bit at a time */
|
||||
for (uint8_t bit_ = 6; bit_ > 0; --bit_)
|
||||
{
|
||||
/* Try to divide the current data bit */
|
||||
if ((remainder & 0x200) > 0)//equivalent to remainder & 2^14 simply check for MSB
|
||||
{
|
||||
remainder = (uint16_t)((remainder << 1));
|
||||
remainder = (uint16_t)(remainder ^ polynom);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainder = (uint16_t)((remainder << 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ((uint16_t)(remainder & 0x3FF));
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiSendCmd
|
||||
* @brief Send command in spi line
|
||||
*
|
||||
* @details This function send bms command in spi line
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] tx_cmd Tx command bytes
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiSendCmd(uint8_t tx_cmd[2])
|
||||
{
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
cmd[0] = tx_cmd[0];
|
||||
cmd[1] = tx_cmd[1];
|
||||
cmd_pec = Pec15_Calc(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
adBmsCsLow();
|
||||
spiWriteBytes(4, &cmd[0]);
|
||||
adBmsCsHigh();
|
||||
}
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiReadData
|
||||
* @brief Spi Read Bms Data
|
||||
*
|
||||
* @details This function send bms command in spi line and read command corrospond data byte.
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] tIC Total IC
|
||||
*
|
||||
* @param [in] tx_cmd Tx command bytes
|
||||
*
|
||||
* @param [in] *rx_data Rx data pointer
|
||||
*
|
||||
* @param [in] *pec_error Pec error pointer
|
||||
*
|
||||
* @param [in] *cmd_cntr command counter pointer
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiReadData
|
||||
(
|
||||
uint8_t tIC,
|
||||
uint8_t tx_cmd[2],
|
||||
uint8_t *rx_data,
|
||||
uint8_t *pec_error,
|
||||
uint8_t *cmd_cntr,
|
||||
uint8_t regData_size
|
||||
)
|
||||
{
|
||||
uint8_t *data, *copyArray, src_address = 0;
|
||||
uint16_t cmd_pec, received_pec, calculated_pec;
|
||||
uint8_t BYTES_IN_REG = regData_size;
|
||||
uint8_t RX_BUFFER = (regData_size * tIC);
|
||||
|
||||
data = (uint8_t *)calloc(RX_BUFFER, sizeof(uint8_t));
|
||||
copyArray = (uint8_t *)calloc(BYTES_IN_REG, sizeof(uint8_t));
|
||||
if((data == NULL) || (copyArray == NULL))
|
||||
{
|
||||
#ifdef MBED
|
||||
pc.printf(" Failed to allocate spi read data memory \n");
|
||||
#else
|
||||
printf(" Failed to allocate spi read data memory \n");
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t cmd[4];
|
||||
cmd[0] = tx_cmd[0];
|
||||
cmd[1] = tx_cmd[1];
|
||||
cmd_pec = Pec15_Calc(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
adBmsCsLow();
|
||||
spiWriteReadBytes(&cmd[0], &data[0], RX_BUFFER); /* Read the configuration data of all ICs on the daisy chain into readdata array */
|
||||
adBmsCsHigh();
|
||||
for (uint8_t current_ic = 0; current_ic < tIC; current_ic++) /* executes for each ic in the daisy chain and packs the data */
|
||||
{ /* Into the r_comm array as well as check the received data for any bit errors */
|
||||
for (uint8_t current_byte = 0; current_byte < (BYTES_IN_REG-2); current_byte++)
|
||||
{
|
||||
rx_data[(current_ic*BYTES_IN_REG)+current_byte] = data[current_byte + (current_ic*BYTES_IN_REG)];
|
||||
}
|
||||
/* Get command counter value */
|
||||
cmd_cntr[current_ic] = (data[(current_ic * BYTES_IN_REG) + (BYTES_IN_REG - 2)] >> 2);
|
||||
/* Get received pec value from ic*/
|
||||
received_pec = (uint16_t)(((data[(current_ic * BYTES_IN_REG) + (BYTES_IN_REG - 2)] & 0x03) << 8) | data[(current_ic * BYTES_IN_REG) + (BYTES_IN_REG - 1)]);
|
||||
/* Copy each ic correspond data + pec value for calculate data pec */
|
||||
memcpy(©Array[0], &data[src_address], BYTES_IN_REG);
|
||||
src_address = ((current_ic+1) * (regData_size));
|
||||
/* Calculate data pec */
|
||||
calculated_pec = (uint16_t)pec10_calc(true, (BYTES_IN_REG-2), ©Array[0]);
|
||||
/* Match received pec with calculated pec */
|
||||
if (received_pec == calculated_pec){ pec_error[current_ic] = 0; }/* If no error is there value set to 0 */
|
||||
else{ pec_error[current_ic] = 1; } /* If error is there value set to 1 */
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
free(copyArray);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiWriteData
|
||||
* @brief Spi Write Bms Data
|
||||
*
|
||||
* @details This function write the data into bms ic.
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] tIC Total IC
|
||||
*
|
||||
* @param [in] tx_cmd Tx command bytes
|
||||
*
|
||||
* @param [in] *data Data pointer
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiWriteData
|
||||
(
|
||||
uint8_t tIC,
|
||||
uint8_t tx_cmd[2],
|
||||
uint8_t *data
|
||||
)
|
||||
{
|
||||
uint8_t BYTES_IN_REG = TX_DATA;
|
||||
uint8_t CMD_LEN = 4 + (RX_DATA * tIC);
|
||||
uint16_t data_pec, cmd_pec;
|
||||
uint8_t *cmd, copyArray[TX_DATA], src_address = 0;
|
||||
uint8_t cmd_index;
|
||||
cmd = (uint8_t *)calloc(CMD_LEN, sizeof(uint8_t));
|
||||
if(cmd == NULL)
|
||||
{
|
||||
#ifdef MBED
|
||||
pc.printf(" Failed to allocate cmd array memory \n");
|
||||
#else
|
||||
printf(" Failed to allocate cmd array memory \n");
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd[0] = tx_cmd[0];
|
||||
cmd[1] = tx_cmd[1];
|
||||
cmd_pec = Pec15_Calc(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
cmd_index = 4;
|
||||
/* executes for each LTC68xx, this loops starts with the last IC on the stack */
|
||||
for (uint8_t current_ic = tIC; current_ic > 0; current_ic--)
|
||||
{
|
||||
src_address = ((current_ic-1) * TX_DATA);
|
||||
/* The first configuration written is received by the last IC in the daisy chain */
|
||||
for (uint8_t current_byte = 0; current_byte < BYTES_IN_REG; current_byte++)
|
||||
{
|
||||
cmd[cmd_index] = data[((current_ic-1)*6)+current_byte];
|
||||
cmd_index = cmd_index + 1;
|
||||
}
|
||||
/* Copy each ic correspond data + pec value for calculate data pec */
|
||||
memcpy(©Array[0], &data[src_address], TX_DATA); /* dst, src, size */
|
||||
/* calculating the PEC for each Ics configuration register data */
|
||||
data_pec = (uint16_t)pec10_calc(true,BYTES_IN_REG, ©Array[0]);
|
||||
cmd[cmd_index] = (uint8_t)(data_pec >> 8);
|
||||
cmd_index = cmd_index + 1;
|
||||
cmd[cmd_index] = (uint8_t)data_pec;
|
||||
cmd_index = cmd_index + 1;
|
||||
}
|
||||
adBmsCsLow();
|
||||
spiWriteBytes(CMD_LEN, &cmd[0]);
|
||||
adBmsCsHigh();
|
||||
}
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsReadData
|
||||
* @brief Adbms Read Data From Bms ic.
|
||||
*
|
||||
* @details This function send bms command, read payload data parse into function and check pec error.
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] tIC Total IC
|
||||
*
|
||||
* @param [in] *ic cell_asic stucture pointer
|
||||
*
|
||||
* @param [in] cmd_arg command bytes
|
||||
*
|
||||
* @param [in] TYPE Enum type of resistor
|
||||
*
|
||||
* @param [in] GRP Enum type of resistor group
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBmsReadData(uint8_t tIC, cell_asic *ic, uint8_t cmd_arg[2], TYPE type, GRP group)
|
||||
{
|
||||
uint16_t rBuff_size;
|
||||
uint8_t regData_size;
|
||||
if(group == ALL_GRP)
|
||||
{
|
||||
if(type == Rdcvall){rBuff_size = RDCVALL_SIZE; regData_size = RDCVALL_SIZE;}
|
||||
else if(type == Rdsall){rBuff_size = RDSALL_SIZE; regData_size = RDSALL_SIZE;}
|
||||
else if(type == Rdacall){rBuff_size = RDACALL_SIZE; regData_size = RDACALL_SIZE;}
|
||||
else if(type == Rdfcall){rBuff_size = RDFCALL_SIZE; regData_size = RDFCALL_SIZE;}
|
||||
else if(type == Rdcsall){rBuff_size = RDCSALL_SIZE; regData_size = RDCSALL_SIZE;}
|
||||
else if(type == Rdasall){rBuff_size = RDASALL_SIZE; regData_size = RDASALL_SIZE;}
|
||||
else if(type == Rdacsall){rBuff_size = RDACSALL_SIZE; regData_size = RDACSALL_SIZE;}
|
||||
else{printf("Read All cmd wrong type select \n");}
|
||||
}
|
||||
else{rBuff_size = (tIC * RX_DATA); regData_size = RX_DATA;}
|
||||
uint8_t *read_buffer, *pec_error, *cmd_count;
|
||||
read_buffer = (uint8_t *)calloc(rBuff_size, sizeof(uint8_t));
|
||||
pec_error = (uint8_t *)calloc(tIC, sizeof(uint8_t));
|
||||
cmd_count = (uint8_t *)calloc(tIC, sizeof(uint8_t));
|
||||
if((pec_error == NULL) || (cmd_count == NULL) || (read_buffer == NULL))
|
||||
{
|
||||
#ifdef MBED
|
||||
pc.printf(" Failed to allocate memory \n");
|
||||
#else
|
||||
printf(" Failed to allocate memory \n");
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
spiReadData(tIC, &cmd_arg[0], &read_buffer[0], &pec_error[0], &cmd_count[0], regData_size);
|
||||
switch (type)
|
||||
{
|
||||
case Config:
|
||||
adBms6830ParseConfig(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.cfgr_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Cell:
|
||||
adBms6830ParseCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.cell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case AvgCell:
|
||||
adBms6830ParseAverageCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.acell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case S_volt:
|
||||
adBms6830ParseSCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.scell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case F_volt:
|
||||
adBms6830ParseFCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.fcell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Aux:
|
||||
adBms6830ParseAux(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.aux_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case RAux:
|
||||
adBms6830ParseRAux(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.raux_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Status:
|
||||
adBms6830ParseStatus(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.stat_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Comm:
|
||||
adBms6830ParseComm(tIC, ic, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.comm_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Pwm:
|
||||
adBms6830ParsePwm(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.pwm_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Sid:
|
||||
adBms6830ParseSID(tIC, ic, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.sid_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Rdcvall:
|
||||
/* 32 byte cell data + 2 byte pec */
|
||||
adBms6830ParseCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.cell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Rdacall:
|
||||
/* 32 byte avg cell data + 2 byte pec */
|
||||
adBms6830ParseAverageCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.acell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Rdsall:
|
||||
/* 32 byte scell volt data + 2 byte pec */
|
||||
adBms6830ParseSCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.scell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Rdfcall:
|
||||
/* 32 byte fcell data + 2 byte pec */
|
||||
adBms6830ParseFCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.fcell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Rdcsall:
|
||||
/* 64 byte + 2 byte pec = 32 byte cell data + 32 byte scell volt data */
|
||||
adBms6830ParseCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.cell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
adBms6830ParseSCell(tIC, ic, group, &read_buffer[32]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.scell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Rdacsall:
|
||||
/* 64 byte + 2 byte pec = 32 byte avg cell data + 32 byte scell volt data */
|
||||
adBms6830ParseAverageCell(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.acell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
adBms6830ParseSCell(tIC, ic, group, &read_buffer[32]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.scell_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
case Rdasall:
|
||||
/* 68 byte + 2 byte pec:
|
||||
24 byte gpio data + 20 byte Redundant gpio data +
|
||||
24 byte status A(6 byte), B(6 byte), C(4 byte), D(6 byte) & E(2 byte)
|
||||
*/
|
||||
adBms6830ParseAux(tIC, ic, group, &read_buffer[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.aux_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
adBms6830ParseRAux(tIC, ic, group, &read_buffer[24]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.raux_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
adBms6830ParseStatus(tIC, ic, group, &read_buffer[44]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
ic[cic].cccrc.stat_pec = pec_error[cic];
|
||||
ic[cic].cccrc.cmd_cntr = cmd_count[cic];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(read_buffer);
|
||||
free(pec_error);
|
||||
free(cmd_count);
|
||||
}
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsWriteData
|
||||
* @brief Adbms Write Data into Bms ic.
|
||||
*
|
||||
* @details This function write the data into bms ic.
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] tIC Total IC
|
||||
*
|
||||
* @param [in] *ic cell_asic stucture pointer
|
||||
*
|
||||
* @param [in] cmd_arg command bytes
|
||||
*
|
||||
* @param [in] TYPE Enum type of resistor
|
||||
*
|
||||
* @param [in] GRP Enum type of resistor group
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBmsWriteData(uint8_t tIC, cell_asic *ic, uint8_t cmd_arg[2], TYPE type, GRP group)
|
||||
{
|
||||
uint8_t data_len = TX_DATA, write_size = (TX_DATA * tIC);
|
||||
uint8_t *write_buffer = (uint8_t *)calloc(write_size, sizeof(uint8_t));
|
||||
if(write_buffer == NULL)
|
||||
{
|
||||
#ifdef MBED
|
||||
pc.printf(" Failed to allocate write_buffer array memory \n");
|
||||
#else
|
||||
printf(" Failed to allocate write_buffer array memory \n");
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Config:
|
||||
switch (group)
|
||||
{
|
||||
case A:
|
||||
adBms6830CreateConfiga(tIC, &ic[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
for (uint8_t data = 0; data < data_len; data++)
|
||||
{
|
||||
write_buffer[(cic * data_len) + data] = ic[cic].configa.tx_data[data];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case B:
|
||||
adBms6830CreateConfigb(tIC, &ic[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
for (uint8_t data = 0; data < data_len; data++)
|
||||
{
|
||||
write_buffer[(cic * data_len) + data] = ic[cic].configb.tx_data[data];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Comm:
|
||||
adBms6830CreateComm(tIC, &ic[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
for (uint8_t data = 0; data < data_len; data++)
|
||||
{
|
||||
write_buffer[(cic * data_len) + data] = ic[cic].com.tx_data[data];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Pwm:
|
||||
switch (group)
|
||||
{
|
||||
case A:
|
||||
adBms6830CreatePwma(tIC, &ic[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
for (uint8_t data = 0; data < data_len; data++)
|
||||
{
|
||||
write_buffer[(cic * data_len) + data] = ic[cic].pwma.tx_data[data];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case B:
|
||||
adBms6830CreatePwmb(tIC, &ic[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
for (uint8_t data = 0; data < data_len; data++)
|
||||
{
|
||||
write_buffer[(cic * data_len) + data] = ic[cic].pwmb.tx_data[data];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Clrflag:
|
||||
adBms6830CreateClrflagData(tIC, &ic[0]);
|
||||
for (uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
for (uint8_t data = 0; data < data_len; data++)
|
||||
{
|
||||
write_buffer[(cic * data_len) + data] = ic[cic].clrflag.tx_data[data];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
spiWriteData(tIC, cmd_arg, &write_buffer[0]);
|
||||
free(write_buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsPollAdc
|
||||
* @brief PLADC Command.
|
||||
*
|
||||
* @details Send poll adc command and retun adc conversion count.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* @param [in] tIC Total IC
|
||||
*
|
||||
* @param [in] tx_cmd Tx command byte
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
uint32_t adBmsPollAdc(uint8_t tx_cmd[2])
|
||||
{
|
||||
uint32_t conv_count = 0;
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
uint8_t read_data = 0x00;
|
||||
uint8_t SDO_Line = 0xFF;
|
||||
cmd[0] = tx_cmd[0];
|
||||
cmd[1] = tx_cmd[1];
|
||||
cmd_pec = Pec15_Calc(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
startTimer();
|
||||
adBmsCsLow();
|
||||
spiWriteBytes(4, &cmd[0]);
|
||||
do{
|
||||
spiReadBytes(1, &read_data);
|
||||
}while(!(read_data == SDO_Line));
|
||||
adBmsCsHigh();
|
||||
conv_count = getTimCount();
|
||||
stopTimer();
|
||||
return(conv_count);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBms6830_Adcv
|
||||
* @brief ADCV Command.
|
||||
*
|
||||
* @details Send adcv command to start cell voltage conversion.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* @param [in] RD Enum type Read bit
|
||||
*
|
||||
* @param [in] CONT Enum type continuous measurement bit
|
||||
*
|
||||
* @param [in] DCP Enum type discharge bit
|
||||
*
|
||||
* @param [in] RSTF Enum type Reset filter
|
||||
*
|
||||
* @param [in] OW_C_S Enum type open wire c/s
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_Adcv
|
||||
(
|
||||
RD rd,
|
||||
CONT cont,
|
||||
DCP dcp,
|
||||
RSTF rstf,
|
||||
OW_C_S owcs
|
||||
)
|
||||
{
|
||||
uint8_t cmd[2];
|
||||
cmd[0] = 0x02 + rd;
|
||||
cmd[1] = (cont<<7)+(dcp<<4)+(rstf<<2)+(owcs & 0x03) + 0x60;
|
||||
spiSendCmd(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBms6830_Adsv
|
||||
* @brief ADSV Command.
|
||||
*
|
||||
* @details Send s_adcv command to start cell voltage conversion.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* @param [in] cont Enum type continuous measurement bit
|
||||
*
|
||||
* @param [in] dcp Enum type discharge bit
|
||||
*
|
||||
* @param [in] owcs Enum type open wire c/s
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_Adsv
|
||||
(
|
||||
CONT cont,
|
||||
DCP dcp,
|
||||
OW_C_S owcs
|
||||
)
|
||||
{
|
||||
uint8_t cmd[2];
|
||||
cmd[0] = 0x01;
|
||||
cmd[1] = (cont<<7)+(dcp<<4)+(owcs &0x03) + 0x68;
|
||||
spiSendCmd(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBms6830_Adax
|
||||
* @brief ADAX Command.
|
||||
*
|
||||
* @details Send Aux command to starts auxiliary conversion.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* @param [in] owcs Enum type open wire c/s
|
||||
*
|
||||
* @param [in] pup Enum type Pull Down current during aux conversion
|
||||
*
|
||||
* @param [in] ch Enum type gpio Channel selection
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_Adax
|
||||
(
|
||||
OW_AUX owaux,
|
||||
PUP pup,
|
||||
CH ch
|
||||
)
|
||||
{
|
||||
uint8_t cmd[2];
|
||||
cmd[0] = 0x04 + owaux;
|
||||
cmd[1] = (pup << 7) + (((ch >>4)&0x01)<<6) + (ch & 0x0F) + 0x10;
|
||||
spiSendCmd(cmd);
|
||||
}
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBms6830_Adax2
|
||||
* @brief ADAX2 Command.
|
||||
*
|
||||
* @details Send Aux2 command to starts auxiliary conversion.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* @param [in] ch Enum type gpio Channel selection
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_Adax2
|
||||
(
|
||||
CH ch
|
||||
)
|
||||
{
|
||||
uint8_t cmd[2];
|
||||
cmd[0] = 0x04;
|
||||
cmd[1] = (ch & 0x0F);
|
||||
spiSendCmd(cmd);
|
||||
}
|
||||
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
1583
Keil_Studio_Cloud/ADBMS6830/src/adBms6830ParseCreate.cpp
Normal file
1583
Keil_Studio_Cloud/ADBMS6830/src/adBms6830ParseCreate.cpp
Normal file
File diff suppressed because it is too large
Load Diff
355
Keil_Studio_Cloud/BUILD/SDP_K1/ARMC6/mbed_config.h
Normal file
355
Keil_Studio_Cloud/BUILD/SDP_K1/ARMC6/mbed_config.h
Normal file
@ -0,0 +1,355 @@
|
||||
/*
|
||||
* mbed SDK
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Automatically generated configuration file.
|
||||
// DO NOT EDIT, content will be overwritten.
|
||||
|
||||
#ifndef __MBED_CONFIG_DATA__
|
||||
#define __MBED_CONFIG_DATA__
|
||||
|
||||
// Configuration parameters
|
||||
#define CLOCK_FREQUENCY_MHZ 8 // set by target:SDP_K1
|
||||
#define CLOCK_SOURCE USE_PLL_HSE_XTAL|USE_PLL_HSI // set by target:SDP_K1
|
||||
#define LPTICKER_DELAY_TICKS 1 // set by target:FAMILY_STM32
|
||||
#define MBED_CONF_ALT1250_PPP_BAUDRATE 115200 // set by library:ALT1250_PPP
|
||||
#define MBED_CONF_ALT1250_PPP_PROVIDE_DEFAULT 0 // set by library:ALT1250_PPP
|
||||
#define MBED_CONF_ATMEL_RF_ASSUME_SPACED_SPI 1 // set by library:atmel-rf[STM]
|
||||
#define MBED_CONF_ATMEL_RF_FULL_SPI_SPEED 7500000 // set by library:atmel-rf
|
||||
#define MBED_CONF_ATMEL_RF_FULL_SPI_SPEED_BYTE_SPACING 250 // set by library:atmel-rf
|
||||
#define MBED_CONF_ATMEL_RF_IRQ_THREAD_STACK_SIZE 1024 // set by library:atmel-rf
|
||||
#define MBED_CONF_ATMEL_RF_LOW_SPI_SPEED 3750000 // set by library:atmel-rf
|
||||
#define MBED_CONF_ATMEL_RF_PROVIDE_DEFAULT 0 // set by library:atmel-rf
|
||||
#define MBED_CONF_ATMEL_RF_USE_SPI_SPACING_API 0 // set by library:atmel-rf
|
||||
#define MBED_CONF_CELLULAR_CONTROL_PLANE_OPT 0 // set by library:cellular
|
||||
#define MBED_CONF_CELLULAR_DEBUG_AT 0 // set by library:cellular
|
||||
#define MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY 0 // set by library:cellular
|
||||
#define MBED_CONF_CELLULAR_USE_APN_LOOKUP 1 // set by library:cellular
|
||||
#define MBED_CONF_CELLULAR_USE_SMS 1 // set by library:cellular
|
||||
#define MBED_CONF_DRIVERS_QSPI_CSN QSPI_FLASH1_CSN // set by library:drivers
|
||||
#define MBED_CONF_DRIVERS_QSPI_IO0 QSPI_FLASH1_IO0 // set by library:drivers
|
||||
#define MBED_CONF_DRIVERS_QSPI_IO1 QSPI_FLASH1_IO1 // set by library:drivers
|
||||
#define MBED_CONF_DRIVERS_QSPI_IO2 QSPI_FLASH1_IO2 // set by library:drivers
|
||||
#define MBED_CONF_DRIVERS_QSPI_IO3 QSPI_FLASH1_IO3 // set by library:drivers
|
||||
#define MBED_CONF_DRIVERS_QSPI_SCK QSPI_FLASH1_SCK // set by library:drivers
|
||||
#define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256 // set by library:drivers
|
||||
#define MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 256 // set by library:drivers
|
||||
#define MBED_CONF_ESP8266_DEBUG 0 // set by library:esp8266
|
||||
#define MBED_CONF_ESP8266_POWER_OFF_TIME_MS 3 // set by library:esp8266
|
||||
#define MBED_CONF_ESP8266_POWER_ON_POLARITY 0 // set by library:esp8266
|
||||
#define MBED_CONF_ESP8266_POWER_ON_TIME_MS 3 // set by library:esp8266
|
||||
#define MBED_CONF_ESP8266_PROVIDE_DEFAULT 0 // set by library:esp8266
|
||||
#define MBED_CONF_ESP8266_SERIAL_BAUDRATE 115200 // set by library:esp8266
|
||||
#define MBED_CONF_ESP8266_SOCKET_BUFSIZE 8192 // set by library:esp8266
|
||||
#define MBED_CONF_EVENTS_PRESENT 1 // set by library:events
|
||||
#define MBED_CONF_EVENTS_SHARED_DISPATCH_FROM_APPLICATION 0 // set by library:events
|
||||
#define MBED_CONF_EVENTS_SHARED_EVENTSIZE 768 // set by library:events
|
||||
#define MBED_CONF_EVENTS_SHARED_HIGHPRIO_EVENTSIZE 256 // set by library:events
|
||||
#define MBED_CONF_EVENTS_SHARED_HIGHPRIO_STACKSIZE 1024 // set by library:events
|
||||
#define MBED_CONF_EVENTS_SHARED_STACKSIZE 2048 // set by library:events
|
||||
#define MBED_CONF_EVENTS_USE_LOWPOWER_TIMER_TICKER 0 // set by library:events
|
||||
#define MBED_CONF_FAT_CHAN_FFS_DBG 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_CODE_PAGE 437 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_EXFAT 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_HEAPBUF 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_LOCK 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_MINIMIZE 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_NOFSINFO 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_NORTC 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_READONLY 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_REENTRANT 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_RPATH 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_TIMEOUT 1000 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_FS_TINY 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_LFN_BUF 255 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_LFN_UNICODE 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_MAX_LFN 255 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_MAX_SS 4096 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_MIN_SS 512 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_MULTI_PARTITION 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_NORTC_MDAY 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_NORTC_MON 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_NORTC_YEAR 2017 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_SFN_BUF 12 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_STRF_ENCODE 3 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_STR_VOLUME_ID 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_SYNC_T HANDLE // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_CHMOD 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_EXPAND 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_FASTSEEK 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_FIND 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_FORWARD 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_LABEL 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_LFN 3 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_MKFS 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_STRFUNC 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_USE_TRIM 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_VOLUMES 4 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3" // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FLUSH_ON_NEW_CLUSTER 0 // set by library:fat_chan
|
||||
#define MBED_CONF_FAT_CHAN_FLUSH_ON_NEW_SECTOR 1 // set by library:fat_chan
|
||||
#define MBED_CONF_FILESYSTEM_PRESENT 1 // set by library:filesystem
|
||||
#define MBED_CONF_GEMALTO_CINTERION_BAUDRATE 115200 // set by library:GEMALTO_CINTERION
|
||||
#define MBED_CONF_GEMALTO_CINTERION_PROVIDE_DEFAULT 0 // set by library:GEMALTO_CINTERION
|
||||
#define MBED_CONF_GENERIC_AT3GPP_BAUDRATE 115200 // set by library:GENERIC_AT3GPP
|
||||
#define MBED_CONF_GENERIC_AT3GPP_PROVIDE_DEFAULT 0 // set by library:GENERIC_AT3GPP
|
||||
#define MBED_CONF_LORA_ADR_ON 1 // set by library:lora
|
||||
#define MBED_CONF_LORA_APPLICATION_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora
|
||||
#define MBED_CONF_LORA_APPLICATION_KEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora
|
||||
#define MBED_CONF_LORA_APPSKEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora
|
||||
#define MBED_CONF_LORA_APP_PORT 15 // set by library:lora
|
||||
#define MBED_CONF_LORA_AUTOMATIC_UPLINK_MESSAGE 1 // set by library:lora
|
||||
#define MBED_CONF_LORA_DEVICE_ADDRESS 0x00000000 // set by library:lora
|
||||
#define MBED_CONF_LORA_DEVICE_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora
|
||||
#define MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH 5 // set by library:lora
|
||||
#define MBED_CONF_LORA_DUTY_CYCLE_ON 1 // set by library:lora
|
||||
#define MBED_CONF_LORA_DUTY_CYCLE_ON_JOIN 1 // set by library:lora
|
||||
#define MBED_CONF_LORA_FSB_MASK {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x00FF} // set by library:lora
|
||||
#define MBED_CONF_LORA_FSB_MASK_CHINA {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF} // set by library:lora
|
||||
#define MBED_CONF_LORA_LBT_ON 0 // set by library:lora
|
||||
#define MBED_CONF_LORA_MAX_SYS_RX_ERROR 5 // set by library:lora
|
||||
#define MBED_CONF_LORA_NB_TRIALS 12 // set by library:lora
|
||||
#define MBED_CONF_LORA_NWKSKEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora
|
||||
#define MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION 1 // set by library:lora
|
||||
#define MBED_CONF_LORA_PHY EU868 // set by library:lora
|
||||
#define MBED_CONF_LORA_PUBLIC_NETWORK 1 // set by library:lora
|
||||
#define MBED_CONF_LORA_TX_MAX_SIZE 64 // set by library:lora
|
||||
#define MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH 8 // set by library:lora
|
||||
#define MBED_CONF_LORA_WAKEUP_TIME 5 // set by library:lora
|
||||
#define MBED_CONF_LWIP_ADDR_TIMEOUT 5 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_ADDR_TIMEOUT_MODE 1 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_DEBUG_ENABLED 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_DEFAULT_TCP_RECVMBOX_SIZE 8 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_DHCP_TIMEOUT 60 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_ENABLE_PPP_TRACE 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_ETHERNET_ENABLED 1 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_IPV4_ENABLED 1 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_IPV6_ENABLED 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_IP_VER_PREF 4 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_L3IP_ENABLED 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_MBOX_SIZE 8 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT 8 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_MEMP_NUM_TCP_SEG 16 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_MEM_SIZE 2310 // set by library:lwip[STM]
|
||||
#define MBED_CONF_LWIP_NUM_NETBUF 8 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_NUM_PBUF 8 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_PBUF_POOL_SIZE 5 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_PPP_ENABLED 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_PPP_IPV4_ENABLED 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_PRESENT 1 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 0 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCPIP_MBOX_SIZE 8 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT 1000 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_ENABLED 1 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_MAXRTX 6 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_MSS 536 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_SERVER_MAX 4 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_SND_BUF (2 * TCP_MSS) // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_SOCKET_MAX 4 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_SYNMAXRTX 6 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_TCP_WND (4 * TCP_MSS) // set by library:lwip
|
||||
#define MBED_CONF_LWIP_UDP_SOCKET_MAX 4 // set by library:lwip
|
||||
#define MBED_CONF_LWIP_USE_MBED_TRACE 0 // set by library:lwip
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_CHANNEL 0 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_CHANNEL_MASK 0x7fff800 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_CHANNEL_PAGE 0 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_DEVICE_TYPE NET_6LOWPAN_ROUTER // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PANID_FILTER 0xffff // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PSK_KEY {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf} // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PSK_KEY_ID 1 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_SECURITY_MODE NONE // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_SEC_LEVEL 5 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_HEAP_SIZE 32500 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_HEAP_STAT_INFO NULL // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_MAC_NEIGH_TABLE_SIZE 32 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_RADIUS_RETRY_COUNT 3 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_RADIUS_RETRY_IMAX 30 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_RADIUS_RETRY_IMIN 20 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_CHANNEL 22 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_CHANNEL_MASK 0x7fff800 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_CHANNEL_PAGE 0 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_COMMISSIONING_DATASET_TIMESTAMP 0x10000 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_EXTENDED_PANID {0xf1, 0xb5, 0xa1, 0xb2,0xc4, 0xd5, 0xa1, 0xbd } // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_ML_PREFIX {0xfd, 0x0, 0x0d, 0xb8, 0x0, 0x0, 0x0, 0x0} // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_NETWORK_NAME "Thread Network" // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_PANID 0x0700 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_CONFIG_PSKC {0xc8, 0xa6, 0x2e, 0xae, 0xf3, 0x68, 0xf3, 0x46, 0xa9, 0x9e, 0x57, 0x85, 0x98, 0x9d, 0x1c, 0xd0} // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE MESH_DEVICE_TYPE_THREAD_ROUTER // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_MASTER_KEY {0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff} // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_PSKD "ABCDEFGH" // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_SECURITY_POLICY 255 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_THREAD_USE_STATIC_LINK_CONFIG 1 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP 0 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_BC_CHANNEL_FUNCTION 255 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_BC_DWELL_INTERVAL 0 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_BC_FIXED_CHANNEL 0xffff // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_BC_INTERVAL 0 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_DEVICE_TYPE MESH_DEVICE_TYPE_WISUN_ROUTER // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_NETWORK_NAME "Wi-SUN Network" // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_OPERATING_CLASS 255 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_OPERATING_MODE 255 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_REGULATORY_DOMAIN 3 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION 255 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_UC_DWELL_INTERVAL 0 // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MBED_MESH_API_WISUN_UC_FIXED_CHANNEL 0xffff // set by library:mbed-mesh-api
|
||||
#define MBED_CONF_MCR20A_PROVIDE_DEFAULT 0 // set by library:mcr20a
|
||||
#define MBED_CONF_NANOSTACK_CONFIGURATION nanostack_full // set by library:nanostack
|
||||
#define MBED_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT 0 // set by library:nanostack-hal
|
||||
#define MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_DISPATCH_FROM_APPLICATION 0 // set by library:nanostack-hal
|
||||
#define MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_THREAD_STACK_SIZE 6144 // set by library:nanostack-hal
|
||||
#define MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_USE_MBED_EVENTS 0 // set by library:nanostack-hal
|
||||
#define MBED_CONF_NANOSTACK_HAL_KVSTORE_PATH "/kv/" // set by library:nanostack-hal
|
||||
#define MBED_CONF_NANOSTACK_HAL_USE_KVSTORE 0 // set by library:nanostack-hal
|
||||
#define MBED_CONF_NSAPI_DEFAULT_MESH_TYPE THREAD // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_DEFAULT_STACK LWIP // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY NONE // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_DNS_CACHE_SIZE 3 // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 10000 // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_DNS_RETRIES 1 // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 10 // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_PRESENT 1 // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_SOCKET_STATS_ENABLED 0 // set by library:nsapi
|
||||
#define MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT 10 // set by library:nsapi
|
||||
#define MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX 8 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 9600 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_ERROR_HIST_ENABLED 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 4 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_ERROR_REBOOT_MAX 1 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 16 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT 1 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_POLL_USE_LOWPOWER_TIMER 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_STDIO_BAUD_RATE 9600 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_STDIO_CONVERT_TTY_NEWLINES 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_STDIO_FLUSH_AT_EXIT 1 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY 0 // set by library:platform
|
||||
#define MBED_CONF_PLATFORM_USE_MPU 1 // set by library:platform
|
||||
#define MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP 1 // set by library:ppp-cell-iface
|
||||
#define MBED_CONF_PPP_CELL_IFACE_AT_PARSER_BUFFER_SIZE 256 // set by library:ppp-cell-iface
|
||||
#define MBED_CONF_PPP_CELL_IFACE_AT_PARSER_TIMEOUT 8000 // set by library:ppp-cell-iface
|
||||
#define MBED_CONF_PPP_CELL_IFACE_BAUD_RATE 115200 // set by library:ppp-cell-iface
|
||||
#define MBED_CONF_PPP_ENABLED 0 // set by library:ppp
|
||||
#define MBED_CONF_PPP_ENABLE_TRACE 0 // set by library:ppp
|
||||
#define MBED_CONF_PPP_IPV4_ENABLED 1 // set by library:ppp
|
||||
#define MBED_CONF_PPP_IPV6_ENABLED 0 // set by library:ppp
|
||||
#define MBED_CONF_PPP_MBED_EVENT_QUEUE 0 // set by library:ppp
|
||||
#define MBED_CONF_PPP_THREAD_STACKSIZE 816 // set by library:ppp
|
||||
#define MBED_CONF_QUECTEL_BC95_BAUDRATE 9600 // set by library:QUECTEL_BC95
|
||||
#define MBED_CONF_QUECTEL_BC95_PROVIDE_DEFAULT 0 // set by library:QUECTEL_BC95
|
||||
#define MBED_CONF_QUECTEL_BG96_BAUDRATE 115200 // set by library:QUECTEL_BG96
|
||||
#define MBED_CONF_QUECTEL_BG96_PROVIDE_DEFAULT 0 // set by library:QUECTEL_BG96
|
||||
#define MBED_CONF_QUECTEL_EC2X_BAUDRATE 115200 // set by library:QUECTEL_EC2X
|
||||
#define MBED_CONF_QUECTEL_EC2X_PROVIDE_DEFAULT 0 // set by library:QUECTEL_EC2X
|
||||
#define MBED_CONF_QUECTEL_M26_BAUDRATE 115200 // set by library:QUECTEL_M26
|
||||
#define MBED_CONF_QUECTEL_M26_PROVIDE_DEFAULT 0 // set by library:QUECTEL_M26
|
||||
#define MBED_CONF_QUECTEL_UG96_BAUDRATE 115200 // set by library:QUECTEL_UG96
|
||||
#define MBED_CONF_QUECTEL_UG96_PROVIDE_DEFAULT 0 // set by library:QUECTEL_UG96
|
||||
#define MBED_CONF_RM1000_AT_BAUDRATE 230400 // set by library:RM1000_AT
|
||||
#define MBED_CONF_RM1000_AT_PROVIDE_DEFAULT 0 // set by library:RM1000_AT
|
||||
#define MBED_CONF_RTOS_API_PRESENT 1 // set by library:rtos-api
|
||||
#define MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE 512 // set by library:rtos
|
||||
#define MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE_DEBUG_EXTRA 128 // set by library:rtos[STM]
|
||||
#define MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE_TICKLESS_EXTRA 256 // set by library:rtos
|
||||
#define MBED_CONF_RTOS_MAIN_THREAD_STACK_SIZE 4096 // set by library:rtos
|
||||
#define MBED_CONF_RTOS_PRESENT 1 // set by library:rtos
|
||||
#define MBED_CONF_RTOS_THREAD_STACK_SIZE 4096 // set by library:rtos
|
||||
#define MBED_CONF_RTOS_TIMER_THREAD_STACK_SIZE 768 // set by library:rtos
|
||||
#define MBED_CONF_S2LP_PROVIDE_DEFAULT 0 // set by library:s2lp
|
||||
#define MBED_CONF_SARA4_PPP_BAUDRATE 115200 // set by library:SARA4_PPP
|
||||
#define MBED_CONF_SARA4_PPP_PROVIDE_DEFAULT 0 // set by library:SARA4_PPP
|
||||
#define MBED_CONF_STM32_EMAC_ETH_RXBUFNB 4 // set by library:stm32-emac
|
||||
#define MBED_CONF_STM32_EMAC_ETH_TXBUFNB 4 // set by library:stm32-emac
|
||||
#define MBED_CONF_STORAGE_DEFAULT_KV kv // set by library:storage
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_BLOCKDEVICE default // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_EXTERNAL_SIZE 0 // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_FILESYSTEM default // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_FOLDER_PATH kvstore // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_INTERNAL_BASE_ADDRESS 0 // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_MOUNT_POINT kv // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_BLOCKDEVICE default // set by library:storage_filesystem_no_rbp
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_filesystem_no_rbp
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_EXTERNAL_SIZE 0 // set by library:storage_filesystem_no_rbp
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_FILESYSTEM default // set by library:storage_filesystem_no_rbp
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_FOLDER_PATH kvstore // set by library:storage_filesystem_no_rbp
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_MOUNT_POINT kv // set by library:storage_filesystem_no_rbp
|
||||
#define MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE 0 // set by library:storage_filesystem
|
||||
#define MBED_CONF_STORAGE_STORAGE_TYPE default // set by library:storage
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_BLOCKDEVICE default // set by library:storage_tdb_external
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_external
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_EXTERNAL_SIZE 0 // set by library:storage_tdb_external
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_external
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_NO_RBP_BLOCKDEVICE default // set by library:storage_tdb_external_no_rbp
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_NO_RBP_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_external_no_rbp
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_NO_RBP_EXTERNAL_SIZE 0 // set by library:storage_tdb_external_no_rbp
|
||||
#define MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE 0 // set by library:storage_tdb_external
|
||||
#define MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_internal
|
||||
#define MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE 0 // set by library:storage_tdb_internal
|
||||
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 // set by library:rtos[*]
|
||||
#define MBED_CONF_TARGET_CONSOLE_UART 1 // set by target:Target
|
||||
#define MBED_CONF_TARGET_DEEP_SLEEP_LATENCY 4 // set by target:FAMILY_STM32
|
||||
#define MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT 1 // set by target:FAMILY_STM32
|
||||
#define MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK 1 // set by target:FAMILY_STM32
|
||||
#define MBED_CONF_TARGET_LPUART_CLOCK_SOURCE USE_LPUART_CLK_LSE|USE_LPUART_CLK_PCLK1 // set by target:FAMILY_STM32
|
||||
#define MBED_CONF_TARGET_LSE_AVAILABLE 0 // set by target:SDP_K1
|
||||
#define MBED_CONF_TARGET_MPU_ROM_END 0x0fffffff // set by target:Target
|
||||
#define MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER 0 // set by target:Target
|
||||
#define MBED_CONF_TARGET_XIP_ENABLE 0 // set by target:Target
|
||||
#define MBED_CONF_TELIT_HE910_BAUDRATE 115200 // set by library:TELIT_HE910
|
||||
#define MBED_CONF_TELIT_HE910_PROVIDE_DEFAULT 0 // set by library:TELIT_HE910
|
||||
#define MBED_CONF_TELIT_ME910_BAUDRATE 115200 // set by library:TELIT_ME910
|
||||
#define MBED_CONF_TELIT_ME910_PROVIDE_DEFAULT 0 // set by library:TELIT_ME910
|
||||
#define MBED_CONF_UBLOX_AT_BAUDRATE 115200 // set by library:UBLOX_AT
|
||||
#define MBED_CONF_UBLOX_AT_PROVIDE_DEFAULT 0 // set by library:UBLOX_AT
|
||||
#define MBED_CONF_UBLOX_N2XX_BAUDRATE 9600 // set by library:UBLOX_N2XX
|
||||
#define MBED_CONF_UBLOX_N2XX_PROVIDE_DEFAULT 0 // set by library:UBLOX_N2XX
|
||||
#define MBED_CONF_UBLOX_PPP_BAUDRATE 115200 // set by library:UBLOX_PPP
|
||||
#define MBED_CONF_UBLOX_PPP_PROVIDE_DEFAULT 0 // set by library:UBLOX_PPP
|
||||
#define MBED_LFS_BLOCK_SIZE 512 // set by library:littlefs
|
||||
#define MBED_LFS_ENABLE_INFO 0 // set by library:littlefs
|
||||
#define MBED_LFS_INTRINSICS 1 // set by library:littlefs
|
||||
#define MBED_LFS_LOOKAHEAD 512 // set by library:littlefs
|
||||
#define MBED_LFS_PROG_SIZE 64 // set by library:littlefs
|
||||
#define MBED_LFS_READ_SIZE 64 // set by library:littlefs
|
||||
#define MBED_STACK_DUMP_ENABLED 0 // set by library:platform
|
||||
#define MEM_ALLOC malloc // set by library:mbed-trace
|
||||
#define MEM_FREE free // set by library:mbed-trace
|
||||
#define NVSTORE_ENABLED 1 // set by library:nvstore
|
||||
#define NVSTORE_MAX_KEYS 16 // set by library:nvstore
|
||||
#define PPP_DEBUG 0 // set by library:ppp
|
||||
// Macros
|
||||
#define MBEDTLS_CIPHER_MODE_CTR // defined by library:SecureStore
|
||||
#define MBEDTLS_CMAC_C // defined by library:SecureStore
|
||||
#define NSAPI_PPP_AVAILABLE (MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED) // defined by library:ppp
|
||||
#define NS_USE_EXTERNAL_MBED_TLS // defined by library:nanostack
|
||||
#define UNITY_INCLUDE_CONFIG_H // defined by library:utest
|
||||
#define _RTE_ // defined by library:rtos
|
||||
|
||||
#endif
|
||||
36
Keil_Studio_Cloud/README.txt
Normal file
36
Keil_Studio_Cloud/README.txt
Normal file
@ -0,0 +1,36 @@
|
||||
Overview
|
||||
--------
|
||||
These code files provide drivers to communicate and operate ADBMS6830 BMS IC.
|
||||
This code was developed and tested on SDP-K1 controller board https://os.mbed.com/platforms/SDP_K1/.
|
||||
|
||||
Communication Protocol: SPI
|
||||
|
||||
How to Get Started
|
||||
------------------
|
||||
instructions on how to Engineers User Guide are here:
|
||||
- Documentation/SDP-K1 MBED Keil Studio User Guide for ADBMS6830.pdf
|
||||
- Documentation/SDP-K1 - IAR Embedded Workbench Project User Guide for ADBMS6830.pdf
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
If using Win 7, install serial drivers for Mbed. https://os.mbed.com/docs/mbed-os/v5.12/tutorials/windows-serial-driver.html
|
||||
A detailed user guide on SDP-K1 controller board is available here https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/SDP-K1.html.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
Copyright (c) 2020 Analog Devices, Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
- Modified versions of the software must be conspicuously marked as such.
|
||||
- This software is licensed solely and exclusively for use with processors/products manufactured by or for Analog Devices, Inc.
|
||||
- This software may not be combined or merged with other code in any manner that would cause the software to become subject to terms and conditions which differ from those listed here.
|
||||
- Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
- The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
2019-01-10-7CBSD SLA
|
||||
10957
Keil_Studio_Cloud/compile_commands.json
Normal file
10957
Keil_Studio_Cloud/compile_commands.json
Normal file
File diff suppressed because one or more lines are too long
94
Keil_Studio_Cloud/inc/adBms_Application.h
Normal file
94
Keil_Studio_Cloud/inc/adBms_Application.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adBms_Application.h
|
||||
* @brief: Bms application header file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/*! @addtogroup APPLICATION
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/*! @addtogroup APPLICATION
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "adbms_main.h"
|
||||
|
||||
void app_main(void);
|
||||
void run_command(int cmd);
|
||||
void adBms6830_init_config(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_write_read_config(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_config(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_start_adc_cell_voltage_measurment(uint8_t tIC);
|
||||
void adBms6830_read_cell_voltages(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_start_adc_s_voltage_measurment(uint8_t tIC);
|
||||
void adBms6830_read_s_voltages(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_start_avgcell_voltage_measurment(uint8_t tIC);
|
||||
void adBms6830_read_avgcell_voltages(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_start_fcell_voltage_measurment(uint8_t tIC);
|
||||
void adBms6830_read_fcell_voltages(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_start_aux_voltage_measurment(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_aux_voltages(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_start_raux_voltage_measurment(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_raux_voltages(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_status_registers(uint8_t tIC, cell_asic *ic);
|
||||
void measurement_loop(void);
|
||||
void adBms6830_read_device_sid(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_set_reset_gpio_pins(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_enable_mute(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_disable_mute(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_soft_reset(uint8_t tIC);
|
||||
void adBms6830_reset_cmd_count(uint8_t tIC);
|
||||
void adBms6830_reset_pec_error_flag(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_snap(uint8_t tIC);
|
||||
void adBms6830_unsnap(uint8_t tIC);
|
||||
void adBms6830_clear_cell_measurement(uint8_t tIC);
|
||||
void adBms6830_clear_aux_measurement(uint8_t tIC);
|
||||
void adBms6830_clear_spin_measurement(uint8_t tIC);
|
||||
void adBms6830_clear_fcell_measurement(uint8_t tIC);
|
||||
void adBms6830_clear_ovuv_measurement(uint8_t tIC);
|
||||
void adBms6830_clear_all_flags(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_set_dcc_discharge(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_clear_dcc_discharge(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_write_read_pwm_duty_cycle(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_gpio_spi_communication(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_gpio_i2c_write_to_slave(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_gpio_i2c_read_from_slave(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_set_dtrng_dcto_value(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_run_osc_mismatch_self_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_run_thermal_shutdown_self_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_run_supply_error_detection_self_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_run_thermal_shutdown_self_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_run_fuse_ed_self_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_run_fuse_med_self_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_run_tmodchk_self_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_check_latent_fault_csflt_status_bits(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_check_rdstatc_err_bit_functionality(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_cell_openwire_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_redundant_cell_openwire_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_cell_ow_volatge_collect(uint8_t tIC, cell_asic *ic, TYPE type, OW_C_S ow_c_s);
|
||||
void adBms6830_aux_openwire_test(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_gpio_pup_up_down_volatge_collect(uint8_t tIC, cell_asic *ic, PUP pup);
|
||||
void adBms6830_open_wire_detection_condtion_check(uint8_t tIC, cell_asic *ic, TYPE type);
|
||||
void adBms6830_read_rdcvall_voltage(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_rdacall_voltage(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_rdsall_voltage(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_rdfcall_voltage(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_rdcsall_voltage(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_rdacsall_voltage(uint8_t tIC, cell_asic *ic);
|
||||
void adBms6830_read_rdasall_voltage(uint8_t tIC, cell_asic *ic);
|
||||
|
||||
#endif
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
36
Keil_Studio_Cloud/inc/adbms_main.h
Normal file
36
Keil_Studio_Cloud/inc/adbms_main.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adbms_main.h
|
||||
* @brief: adbms main Heade file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/** @addtogroup MAIN
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup ADBMS_MAIN MAIN
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
#ifndef _ADBMS6830_MAIN_H
|
||||
#define _ADBMS6830_MAIN_H
|
||||
|
||||
//#include "main.h"
|
||||
#include "common.h"
|
||||
#include "adBms6830Data.h"
|
||||
#include "adBms6830GenericType.h"
|
||||
#include "adBms6830ParseCreate.h"
|
||||
#include "mcuWrapper.h"
|
||||
|
||||
|
||||
void adbms_main(void);
|
||||
|
||||
#endif
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
29
Keil_Studio_Cloud/inc/common.h
Normal file
29
Keil_Studio_Cloud/inc/common.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: common.h
|
||||
* @brief: Standard common header files
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
#ifndef __COMMON_H_
|
||||
#define __COMMON_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MBED /* Switch between IAR Workbench or Mbed Studio. */
|
||||
|
||||
#ifdef MBED
|
||||
#include "mbed.h"
|
||||
#include "SPI.h"
|
||||
#include "Timer.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
69
Keil_Studio_Cloud/inc/mcuWrapper.h
Normal file
69
Keil_Studio_Cloud/inc/mcuWrapper.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: mcuWrapper.h
|
||||
* @brief: Generic wrapper header file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/** @addtogroup MUC_DRIVER
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI_DRIVER SPI DRIVER
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
#ifndef __ADBMSWRAPPER_H
|
||||
#define __ADBMSWRAPPER_H
|
||||
#include "common.h"
|
||||
|
||||
#ifdef MBED
|
||||
|
||||
#else
|
||||
#include "main.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4xx_hal_tim.h"
|
||||
#include "stm32f4xx_it.h"
|
||||
|
||||
extern ADC_HandleTypeDef hadc1; /* Mcu dependent ADC handler */
|
||||
extern I2C_HandleTypeDef hi2c1; /* Mcu dependent I2C handler */
|
||||
extern I2C_HandleTypeDef hi2c3; /* Mcu dependent I2C handler */
|
||||
extern SPI_HandleTypeDef hspi1; /* Mcu dependent SPI handler */
|
||||
extern SPI_HandleTypeDef hspi5; /* Mcu dependent SPI handler */
|
||||
extern UART_HandleTypeDef huart4; /* Mcu dependent UART handler */
|
||||
extern UART_HandleTypeDef huart5; /* Mcu dependent UART handler */
|
||||
extern TIM_HandleTypeDef htim2; /* Mcu dependent TIM handler */
|
||||
extern TIM_HandleTypeDef htim5; /* Mcu dependent TIM handler */
|
||||
|
||||
#define CS_PIN ARDUINO_GPIO10_Pin /* Mcu dependent chip select */
|
||||
#define GPIO_PORT ARDUINO_GPIO10_GPIO_Port /* Mcu dependent adc chip select port */
|
||||
#endif
|
||||
|
||||
void Delay_ms(uint32_t delay);
|
||||
void adBmsCsLow(void);
|
||||
void adBmsCsHigh(void);
|
||||
void spiWriteBytes
|
||||
(
|
||||
uint16_t size, /*Option: Number of bytes to be written on the SPI port*/
|
||||
uint8_t *tx_Data /*Array of bytes to be written on the SPI port*/
|
||||
);
|
||||
void spiWriteReadBytes
|
||||
(
|
||||
uint8_t *tx_data, /*array of data to be written on SPI port*/
|
||||
uint8_t *rx_data, /*Input: array that will store the data read by the SPI port*/
|
||||
uint16_t size /*Option: number of bytes*/
|
||||
);
|
||||
void spiReadBytes(uint16_t size, uint8_t *rx_data);
|
||||
void startTimer(void);
|
||||
void stopTimer(void);
|
||||
uint32_t getTimCount(void);
|
||||
void adBmsWakeupIc(uint8_t total_ic);
|
||||
|
||||
#endif
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
46
Keil_Studio_Cloud/inc/serialPrintResult.h
Normal file
46
Keil_Studio_Cloud/inc/serialPrintResult.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: serialPrintResult.h
|
||||
* @brief: Print IO terminal functions
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/*! @addtogroup RESULT_PRINT
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/*! @addtogroup RESULT PRINT I/O
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __RESULT_H
|
||||
#define __RESULT_H
|
||||
|
||||
#include "adbms_main.h"
|
||||
|
||||
void printWriteConfig(uint8_t tIC, cell_asic *IC, TYPE type, GRP grp);
|
||||
void printReadConfig(uint8_t tIC, cell_asic *IC, TYPE type, GRP grp);
|
||||
void printVoltages(uint8_t tIC, cell_asic *IC, TYPE type);
|
||||
void printStatus(uint8_t tIC, cell_asic *IC, TYPE type, GRP grp);
|
||||
void printDeviceSID(uint8_t tIC, cell_asic *IC, TYPE type);
|
||||
void printWritePwmDutyCycle(uint8_t tIC, cell_asic *IC, TYPE type, GRP grp);
|
||||
void printReadPwmDutyCycle(uint8_t tIC, cell_asic *IC, TYPE type, GRP grp);
|
||||
void printWriteCommData(uint8_t tIC, cell_asic *IC, TYPE type);
|
||||
void printReadCommData(uint8_t tIC, cell_asic *IC, TYPE type);
|
||||
void printDiagnosticTestResult(uint8_t tIC, cell_asic *IC, DIAGNOSTIC_TYPE type);
|
||||
void diagnosticTestResultPrint(uint8_t result);
|
||||
void printOpenWireTestResult(uint8_t tIC, cell_asic *IC, TYPE type);
|
||||
void openWireResultPrint(uint8_t result);
|
||||
float getVoltage(int data);
|
||||
void printPollAdcConvTime(int count);
|
||||
void printMenu();
|
||||
|
||||
#endif
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
1
Keil_Studio_Cloud/mbed-os.lib
Normal file
1
Keil_Studio_Cloud/mbed-os.lib
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/ARMmbed/mbed-os/#b114a9c878519d6489ac3426697196bbea34c8ea
|
||||
656
Keil_Studio_Cloud/src/adBms_Application.cpp
Normal file
656
Keil_Studio_Cloud/src/adBms_Application.cpp
Normal file
@ -0,0 +1,656 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adbms_Application.c
|
||||
* @brief: adbms application test cases
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/*! \addtogroup APPLICATION
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @addtogroup Application
|
||||
* @{
|
||||
*/
|
||||
#include "common.h"
|
||||
#include "adBms_Application.h"
|
||||
#include "adBms6830CmdList.h"
|
||||
#include "adBms6830GenericType.h"
|
||||
#include "serialPrintResult.h"
|
||||
#include "mcuWrapper.h"
|
||||
#ifdef MBED
|
||||
extern Serial pc;
|
||||
#endif
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Setup Variables
|
||||
* The following variables can be modified to configure the software.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#define TOTAL_IC 1
|
||||
cell_asic IC[TOTAL_IC];
|
||||
|
||||
/* ADC Command Configurations */
|
||||
RD REDUNDANT_MEASUREMENT = RD_OFF;
|
||||
CH AUX_CH_TO_CONVERT = AUX_ALL;
|
||||
CONT CONTINUOUS_MEASUREMENT = SINGLE;
|
||||
OW_C_S CELL_OPEN_WIRE_DETECTION = OW_OFF_ALL_CH;
|
||||
OW_AUX AUX_OPEN_WIRE_DETECTION = AUX_OW_OFF;
|
||||
PUP OPEN_WIRE_CURRENT_SOURCE = PUP_DOWN;
|
||||
DCP DISCHARGE_PERMITTED = DCP_OFF;
|
||||
RSTF RESET_FILTER = RSTF_OFF;
|
||||
ERR INJECT_ERR_SPI_READ = WITHOUT_ERR;
|
||||
|
||||
/* Set Under Voltage and Over Voltage Thresholds */
|
||||
const float OV_THRESHOLD = 4.2; /* Volt */
|
||||
const float UV_THRESHOLD = 3.0; /* Volt */
|
||||
const int OWC_Threshold = 2000; /* Cell Open wire threshold(mili volt) */
|
||||
const int OWA_Threshold = 50000; /* Aux Open wire threshold(mili volt) */
|
||||
const uint32_t LOOP_MEASUREMENT_COUNT = 1; /* Loop measurment count */
|
||||
const uint16_t MEASUREMENT_LOOP_TIME = 10; /* milliseconds(mS)*/
|
||||
uint32_t loop_count = 0;
|
||||
uint32_t pladc_count;
|
||||
|
||||
/*Loop Measurement Setup These Variables are ENABLED or DISABLED Remember ALL CAPS*/
|
||||
LOOP_MEASURMENT MEASURE_CELL = ENABLED; /* This is ENABLED or DISABLED */
|
||||
LOOP_MEASURMENT MEASURE_AVG_CELL = ENABLED; /* This is ENABLED or DISABLED */
|
||||
LOOP_MEASURMENT MEASURE_F_CELL = ENABLED; /* This is ENABLED or DISABLED */
|
||||
LOOP_MEASURMENT MEASURE_S_VOLTAGE = ENABLED; /* This is ENABLED or DISABLED */
|
||||
LOOP_MEASURMENT MEASURE_AUX = DISABLED; /* This is ENABLED or DISABLED */
|
||||
LOOP_MEASURMENT MEASURE_RAUX = DISABLED; /* This is ENABLED or DISABLED */
|
||||
LOOP_MEASURMENT MEASURE_STAT = DISABLED; /* This is ENABLED or DISABLED */
|
||||
|
||||
void app_main()
|
||||
{
|
||||
printMenu();
|
||||
adBms6830_init_config(TOTAL_IC, &IC[0]);
|
||||
while(1)
|
||||
{
|
||||
int user_command;
|
||||
#ifdef MBED
|
||||
pc.scanf("%d", &user_command);
|
||||
pc.printf("Enter cmd:%d\n", user_command);
|
||||
#else
|
||||
scanf("%d", &user_command);
|
||||
printf("Enter cmd:%d\n", user_command);
|
||||
#endif
|
||||
run_command(user_command);
|
||||
}
|
||||
}
|
||||
|
||||
void run_command(int cmd)
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
|
||||
case 1:
|
||||
adBms6830_write_read_config(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
adBms6830_read_config(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
adBms6830_start_adc_cell_voltage_measurment(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
adBms6830_read_cell_voltages(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
adBms6830_start_adc_s_voltage_measurment(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
adBms6830_read_s_voltages(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
adBms6830_start_avgcell_voltage_measurment(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
adBms6830_read_avgcell_voltages(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
adBms6830_start_fcell_voltage_measurment(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
adBms6830_read_fcell_voltages(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
adBms6830_start_aux_voltage_measurment(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
adBms6830_read_aux_voltages(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 13:
|
||||
adBms6830_start_raux_voltage_measurment(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 14:
|
||||
adBms6830_read_raux_voltages(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 15:
|
||||
adBms6830_read_status_registers(TOTAL_IC, &IC[0]);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
loop_count = 0;
|
||||
adBmsWakeupIc(TOTAL_IC);
|
||||
adBmsWriteData(TOTAL_IC, &IC[0], WRCFGA, Config, A);
|
||||
adBmsWriteData(TOTAL_IC, &IC[0], WRCFGB, Config, B);
|
||||
adBmsWakeupIc(TOTAL_IC);
|
||||
adBms6830_Adcv(REDUNDANT_MEASUREMENT, CONTINUOUS, DISCHARGE_PERMITTED, RESET_FILTER, CELL_OPEN_WIRE_DETECTION);
|
||||
Delay_ms(1); // ADCs are updated at their conversion rate is 1ms
|
||||
adBms6830_Adcv(RD_ON, CONTINUOUS, DISCHARGE_PERMITTED, RESET_FILTER, CELL_OPEN_WIRE_DETECTION);
|
||||
Delay_ms(1); // ADCs are updated at their conversion rate is 1ms
|
||||
adBms6830_Adsv(CONTINUOUS, DISCHARGE_PERMITTED, CELL_OPEN_WIRE_DETECTION);
|
||||
Delay_ms(8); // ADCs are updated at their conversion rate is 8ms
|
||||
while(loop_count < LOOP_MEASUREMENT_COUNT)
|
||||
{
|
||||
measurement_loop();
|
||||
Delay_ms(MEASUREMENT_LOOP_TIME);
|
||||
loop_count = loop_count + 1;
|
||||
}
|
||||
printMenu();
|
||||
break;
|
||||
|
||||
case 17:
|
||||
adBms6830_clear_cell_measurement(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 18:
|
||||
adBms6830_clear_aux_measurement(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 19:
|
||||
adBms6830_clear_spin_measurement(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 20:
|
||||
adBms6830_clear_fcell_measurement(TOTAL_IC);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
printMenu();
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef MBED
|
||||
pc.printf("Incorrect Option\n\n");
|
||||
#else
|
||||
printf("Incorrect Option\n\n");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Set configuration register A. Refer to the data sheet
|
||||
* Set configuration register B. Refer to the data sheet
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_init_config(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
for(uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
/* Init config A */
|
||||
ic[cic].tx_cfga.refon = PWR_UP;
|
||||
// ic[cic].cfga.cth = CVT_8_1mV;
|
||||
// ic[cic].cfga.flag_d = ConfigA_Flag(FLAG_D0, FLAG_SET) | ConfigA_Flag(FLAG_D1, FLAG_SET);
|
||||
// ic[cic].cfga.gpo = ConfigA_Gpo(GPO2, GPO_SET) | ConfigA_Gpo(GPO10, GPO_SET);
|
||||
ic[cic].tx_cfga.gpo = 0X3FF; /* All GPIO pull down off */
|
||||
// ic[cic].cfga.soakon = SOAKON_CLR;
|
||||
// ic[cic].cfga.fc = IIR_FPA256;
|
||||
|
||||
/* Init config B */
|
||||
// ic[cic].cfgb.dtmen = DTMEN_ON;
|
||||
ic[cic].tx_cfgb.vov = SetOverVoltageThreshold(OV_THRESHOLD);
|
||||
ic[cic].tx_cfgb.vuv = SetUnderVoltageThreshold(UV_THRESHOLD);
|
||||
// ic[cic].cfgb.dcc = ConfigB_DccBit(DCC16, DCC_BIT_SET);
|
||||
// SetConfigB_DischargeTimeOutValue(tIC, &ic[cic], RANG_0_TO_63_MIN, TIME_1MIN_OR_0_26HR);
|
||||
}
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGA, Config, A);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGB, Config, B);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Write and Read Configuration Register A/B
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_write_read_config(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGA, Config, A);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGB, Config, B);
|
||||
adBmsReadData(tIC, &ic[0], RDCFGA, Config, A);
|
||||
adBmsReadData(tIC, &ic[0], RDCFGB, Config, B);
|
||||
printWriteConfig(tIC, &ic[0], Config, ALL_GRP);
|
||||
printReadConfig(tIC, &ic[0], Config, ALL_GRP);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read Configuration Register A/B
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_config(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsReadData(tIC, &ic[0], RDCFGA, Config, A);
|
||||
adBmsReadData(tIC, &ic[0], RDCFGB, Config, B);
|
||||
printReadConfig(tIC, &ic[0], Config, ALL_GRP);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Start ADC Cell Voltage Measurement
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_start_adc_cell_voltage_measurment(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBms6830_Adcv(REDUNDANT_MEASUREMENT, CONTINUOUS_MEASUREMENT, DISCHARGE_PERMITTED, RESET_FILTER, CELL_OPEN_WIRE_DETECTION);
|
||||
pladc_count = adBmsPollAdc(PLADC);
|
||||
#ifdef MBED
|
||||
pc.printf("Cell conversion completed\n");
|
||||
#else
|
||||
printf("Cell conversion completed\n");
|
||||
#endif
|
||||
printPollAdcConvTime(pladc_count);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read Cell Voltages
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_cell_voltages(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsReadData(tIC, &ic[0], RDCVA, Cell, A);
|
||||
adBmsReadData(tIC, &ic[0], RDCVB, Cell, B);
|
||||
adBmsReadData(tIC, &ic[0], RDCVC, Cell, C);
|
||||
adBmsReadData(tIC, &ic[0], RDCVD, Cell, D);
|
||||
adBmsReadData(tIC, &ic[0], RDCVE, Cell, E);
|
||||
adBmsReadData(tIC, &ic[0], RDCVF, Cell, F);
|
||||
printVoltages(tIC, &ic[0], Cell);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Start ADC S-Voltage Measurement
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_start_adc_s_voltage_measurment(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBms6830_Adsv(CONTINUOUS_MEASUREMENT, DISCHARGE_PERMITTED, CELL_OPEN_WIRE_DETECTION);
|
||||
pladc_count = adBmsPollAdc(PLADC);
|
||||
#ifdef MBED
|
||||
pc.printf("S-Voltage conversion completed\n");
|
||||
#else
|
||||
printf("S-Voltage conversion completed\n");
|
||||
#endif
|
||||
printPollAdcConvTime(pladc_count);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read S-Voltages
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_s_voltages(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsReadData(tIC, &ic[0], RDSVA, S_volt, A);
|
||||
adBmsReadData(tIC, &ic[0], RDSVB, S_volt, B);
|
||||
adBmsReadData(tIC, &ic[0], RDSVC, S_volt, C);
|
||||
adBmsReadData(tIC, &ic[0], RDSVD, S_volt, D);
|
||||
adBmsReadData(tIC, &ic[0], RDSVE, S_volt, E);
|
||||
adBmsReadData(tIC, &ic[0], RDSVF, S_volt, F);
|
||||
printVoltages(tIC, &ic[0], S_volt);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Start Avarage Cell Voltage Measurement
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_start_avgcell_voltage_measurment(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBms6830_Adcv(RD_ON, CONTINUOUS_MEASUREMENT, DISCHARGE_PERMITTED, RESET_FILTER, CELL_OPEN_WIRE_DETECTION);
|
||||
pladc_count = adBmsPollAdc(PLADC);
|
||||
#ifdef MBED
|
||||
pc.printf("Avg Cell voltage conversion completed\n");
|
||||
#else
|
||||
printf("Avg Cell voltage conversion completed\n");
|
||||
#endif
|
||||
printPollAdcConvTime(pladc_count);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read Avarage Cell Voltages
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_avgcell_voltages(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsReadData(tIC, &ic[0], RDACA, AvgCell, A);
|
||||
adBmsReadData(tIC, &ic[0], RDACB, AvgCell, B);
|
||||
adBmsReadData(tIC, &ic[0], RDACC, AvgCell, C);
|
||||
adBmsReadData(tIC, &ic[0], RDACD, AvgCell, D);
|
||||
adBmsReadData(tIC, &ic[0], RDACE, AvgCell, E);
|
||||
adBmsReadData(tIC, &ic[0], RDACF, AvgCell, F);
|
||||
printVoltages(tIC, &ic[0], AvgCell);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Start Filtered Cell Voltages Measurement
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_start_fcell_voltage_measurment(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBms6830_Adcv(REDUNDANT_MEASUREMENT, CONTINUOUS_MEASUREMENT, DISCHARGE_PERMITTED, RESET_FILTER, CELL_OPEN_WIRE_DETECTION);
|
||||
pladc_count = adBmsPollAdc(PLADC);
|
||||
#ifdef MBED
|
||||
pc.printf("F Cell voltage conversion completed\n");
|
||||
#else
|
||||
printf("F Cell voltage conversion completed\n");
|
||||
#endif
|
||||
printPollAdcConvTime(pladc_count);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read Filtered Cell Voltages
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_fcell_voltages(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsReadData(tIC, &ic[0], RDFCA, F_volt, A);
|
||||
adBmsReadData(tIC, &ic[0], RDFCB, F_volt, B);
|
||||
adBmsReadData(tIC, &ic[0], RDFCC, F_volt, C);
|
||||
adBmsReadData(tIC, &ic[0], RDFCD, F_volt, D);
|
||||
adBmsReadData(tIC, &ic[0], RDFCE, F_volt, E);
|
||||
adBmsReadData(tIC, &ic[0], RDFCF, F_volt, F);
|
||||
printVoltages(tIC, &ic[0], F_volt);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Start AUX, VMV, V+ Voltages Measurement
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_start_aux_voltage_measurment(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
for(uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
/* Init config A */
|
||||
ic[cic].tx_cfga.refon = PWR_UP;
|
||||
ic[cic].tx_cfga.gpo = 0X3FF; /* All GPIO pull down off */
|
||||
}
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGA, Config, A);
|
||||
adBms6830_Adax(AUX_OPEN_WIRE_DETECTION, OPEN_WIRE_CURRENT_SOURCE, AUX_CH_TO_CONVERT);
|
||||
pladc_count = adBmsPollAdc(PLADC);
|
||||
#ifdef MBED
|
||||
pc.printf("Aux voltage conversion completed\n");
|
||||
#else
|
||||
printf("Aux voltage conversion completed\n");
|
||||
#endif
|
||||
printPollAdcConvTime(pladc_count);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read AUX, VMV, V+ Voltages
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_aux_voltages(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsReadData(tIC, &ic[0], RDAUXA, Aux, A);
|
||||
adBmsReadData(tIC, &ic[0], RDAUXB, Aux, B);
|
||||
adBmsReadData(tIC, &ic[0], RDAUXC, Aux, C);
|
||||
adBmsReadData(tIC, &ic[0], RDAUXD, Aux, D);
|
||||
printVoltages(tIC, &ic[0], Aux);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Start Redundant GPIO Voltages Measurement
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_start_raux_voltage_measurment(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
for(uint8_t cic = 0; cic < tIC; cic++)
|
||||
{
|
||||
/* Init config A */
|
||||
ic[cic].tx_cfga.refon = PWR_UP;
|
||||
ic[cic].tx_cfga.gpo = 0X3FF; /* All GPIO pull down off */
|
||||
}
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGA, Config, A);
|
||||
adBms6830_Adax2(AUX_CH_TO_CONVERT);
|
||||
pladc_count = adBmsPollAdc(PLADC);
|
||||
#ifdef MBED
|
||||
pc.printf("RAux voltage conversion completed\n");
|
||||
#else
|
||||
printf("RAux voltage conversion completed\n");
|
||||
#endif
|
||||
printPollAdcConvTime(pladc_count);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read Redundant GPIO Voltages
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_raux_voltages(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsReadData(tIC, &ic[0], RDRAXA, RAux, A);
|
||||
adBmsReadData(tIC, &ic[0], RDRAXB, RAux, B);
|
||||
adBmsReadData(tIC, &ic[0], RDRAXC, RAux, C);
|
||||
adBmsReadData(tIC, &ic[0], RDRAXD, RAux, D);
|
||||
printVoltages(tIC, &ic[0], RAux);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Read Status Reg. A, B, C, D and E.
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_read_status_registers(uint8_t tIC, cell_asic *ic)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGA, Config, A);
|
||||
adBmsWriteData(tIC, &ic[0], WRCFGB, Config, B);
|
||||
adBms6830_Adax(AUX_OPEN_WIRE_DETECTION, OPEN_WIRE_CURRENT_SOURCE, AUX_CH_TO_CONVERT);
|
||||
pladc_count = adBmsPollAdc(PLADC);
|
||||
adBms6830_Adcv(REDUNDANT_MEASUREMENT, CONTINUOUS_MEASUREMENT, DISCHARGE_PERMITTED, RESET_FILTER, CELL_OPEN_WIRE_DETECTION);
|
||||
pladc_count = pladc_count + adBmsPollAdc(PLADC);
|
||||
|
||||
adBmsReadData(tIC, &ic[0], RDSTATA, Status, A);
|
||||
adBmsReadData(tIC, &ic[0], RDSTATB, Status, B);
|
||||
adBmsReadData(tIC, &ic[0], RDSTATC, Status, C);
|
||||
adBmsReadData(tIC, &ic[0], RDSTATD, Status, D);
|
||||
adBmsReadData(tIC, &ic[0], RDSTATE, Status, E);
|
||||
printPollAdcConvTime(pladc_count);
|
||||
printStatus(tIC, &ic[0], Status, ALL_GRP);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Loop measurment.
|
||||
*******************************************************************************
|
||||
*/
|
||||
void measurement_loop()
|
||||
{
|
||||
if(MEASURE_CELL == ENABLED)
|
||||
{
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDCVA, Cell, A);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDCVB, Cell, B);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDCVC, Cell, C);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDCVD, Cell, D);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDCVE, Cell, E);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDCVF, Cell, F);
|
||||
printVoltages(TOTAL_IC, &IC[0], Cell);
|
||||
}
|
||||
|
||||
if(MEASURE_AVG_CELL == ENABLED)
|
||||
{
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDACA, AvgCell, A);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDACB, AvgCell, B);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDACC, AvgCell, C);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDACD, AvgCell, D);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDACE, AvgCell, E);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDACF, AvgCell, F);
|
||||
printVoltages(TOTAL_IC, &IC[0], AvgCell);
|
||||
}
|
||||
|
||||
if(MEASURE_F_CELL == ENABLED)
|
||||
{
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDFCA, F_volt, A);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDFCB, F_volt, B);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDFCC, F_volt, C);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDFCD, F_volt, D);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDFCE, F_volt, E);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDFCF, F_volt, F);
|
||||
printVoltages(TOTAL_IC, &IC[0], F_volt);
|
||||
}
|
||||
|
||||
if(MEASURE_S_VOLTAGE == ENABLED)
|
||||
{
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSVA, S_volt, A);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSVB, S_volt, B);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSVC, S_volt, C);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSVD, S_volt, D);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSVE, S_volt, E);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSVF, S_volt, F);
|
||||
printVoltages(TOTAL_IC, &IC[0], S_volt);
|
||||
}
|
||||
|
||||
if(MEASURE_AUX == ENABLED)
|
||||
{
|
||||
adBms6830_Adax(AUX_OPEN_WIRE_DETECTION, OPEN_WIRE_CURRENT_SOURCE, AUX_CH_TO_CONVERT);
|
||||
adBmsPollAdc(PLAUX1);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDAUXA, Aux, A);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDAUXB, Aux, B);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDAUXC, Aux, C);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDAUXD, Aux, D);
|
||||
printVoltages(TOTAL_IC, &IC[0], Aux);
|
||||
}
|
||||
|
||||
if(MEASURE_RAUX == ENABLED)
|
||||
{
|
||||
adBmsWakeupIc(TOTAL_IC);
|
||||
adBms6830_Adax2(AUX_CH_TO_CONVERT);
|
||||
adBmsPollAdc(PLAUX2);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDRAXA, RAux, A);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDRAXB, RAux, B);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDRAXC, RAux, C);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDRAXD, RAux, D);
|
||||
printVoltages(TOTAL_IC, &IC[0], RAux);
|
||||
}
|
||||
|
||||
if(MEASURE_STAT == ENABLED)
|
||||
{
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSTATA, Status, A);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSTATB, Status, B);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSTATC, Status, C);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSTATD, Status, D);
|
||||
adBmsReadData(TOTAL_IC, &IC[0], RDSTATE, Status, E);
|
||||
printStatus(TOTAL_IC, &IC[0], Status, ALL_GRP);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Clear Cell measurement reg.
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_clear_cell_measurement(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
spiSendCmd(CLRCELL);
|
||||
#ifdef MBED
|
||||
pc.printf("Cell Registers Cleared\n\n");
|
||||
#else
|
||||
printf("Cell Registers Cleared\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Clear Aux measurement reg.
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_clear_aux_measurement(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
spiSendCmd(CLRAUX);
|
||||
#ifdef MBED
|
||||
pc.printf("Aux Registers Cleared\n\n");
|
||||
#else
|
||||
printf("Aux Registers Cleared\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Clear spin measurement reg.
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_clear_spin_measurement(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
spiSendCmd(CLRSPIN);
|
||||
#ifdef MBED
|
||||
pc.printf("Spin Registers Cleared\n\n");
|
||||
#else
|
||||
printf("Spin Registers Cleared\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Clear fcell measurement reg.
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBms6830_clear_fcell_measurement(uint8_t tIC)
|
||||
{
|
||||
adBmsWakeupIc(tIC);
|
||||
spiSendCmd(CLRFC);
|
||||
#ifdef MBED
|
||||
pc.printf("Fcell Registers Cleared\n\n");
|
||||
#else
|
||||
printf("Fcell Registers Cleared\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
34
Keil_Studio_Cloud/src/adbms_main.cpp
Normal file
34
Keil_Studio_Cloud/src/adbms_main.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: adbms_main.c
|
||||
* @brief: adbms main file
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
|
||||
/*! \addtogroup MAIN
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! \addtogroup adbms_Main adbms main
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! \addtogroup Application
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "adbms_main.h"
|
||||
#include "adBms_Application.h"
|
||||
|
||||
void adbms_main()
|
||||
{
|
||||
app_main();
|
||||
}
|
||||
/** @}*/ //MAIN
|
||||
/** @}*/ // Adbms main
|
||||
/** @}*/ //Application
|
||||
44
Keil_Studio_Cloud/src/main.cpp
Normal file
44
Keil_Studio_Cloud/src/main.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "adbms_main.h"
|
||||
|
||||
/*
|
||||
https://os.mbed.com/platforms/SDP_K1/
|
||||
Mbed SDP-K1 board MOSI, MOSI, SCK definition.
|
||||
Arduino Header Pinout
|
||||
MOSI = D11
|
||||
MISO = D12
|
||||
SCK = D13
|
||||
CSB = D10
|
||||
*/
|
||||
int main(void);
|
||||
void spi_init(void);
|
||||
|
||||
DigitalOut chip_select(D10); /* SPI chip select */
|
||||
DigitalOut mosi(D11); /* MOSI */
|
||||
DigitalIn miso(D12); /* MISO */
|
||||
DigitalOut sclk(D13); /* SCK */
|
||||
SPI spi(D11, D12, D13); /* SPI MOSI, MISO, SCK */
|
||||
Serial pc(USBTX, USBRX); /* USB Tx,Rx */
|
||||
Timer timer;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
spi_init();
|
||||
adbms_main();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_init()
|
||||
{
|
||||
chip_select = 1;
|
||||
spi.format(8,0); /* 8bit data, CPOL-CPHA= 0*/
|
||||
spi.frequency(2000000); /* SPI clock 2Mhz */
|
||||
pc.baud(115200); /* Usb baud rate */
|
||||
}
|
||||
426
Keil_Studio_Cloud/src/mcuWrapper.cpp
Normal file
426
Keil_Studio_Cloud/src/mcuWrapper.cpp
Normal file
@ -0,0 +1,426 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2020 - Analog Devices Inc. All Rights Reserved.
|
||||
This software is proprietary & confidential to Analog Devices, Inc.
|
||||
and its licensor.
|
||||
******************************************************************************
|
||||
* @file: mcuWrapper.c
|
||||
* @brief: BMS SPI driver functions
|
||||
* @version: $Revision$
|
||||
* @date: $Date$
|
||||
* Developed by: ADIBMS Software team, Bangalore, India
|
||||
*****************************************************************************/
|
||||
/*! \addtogroup MCU DRIVER
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @addtogroup Mcu Driver
|
||||
* @{
|
||||
*/
|
||||
#include "common.h"
|
||||
#include "mcuWrapper.h"
|
||||
#define WAKEUP_DELAY 4 /* BMS ic wakeup delay */
|
||||
|
||||
#ifdef MBED
|
||||
extern Serial pc;
|
||||
extern SPI spi;
|
||||
extern Timer timer;
|
||||
extern DigitalOut chip_select;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: Delay_ms
|
||||
* @brief Delay mili second
|
||||
*
|
||||
* @details This function insert delay in ms.
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] delay Delay_ms
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Delay_ms(uint32_t delay)
|
||||
{
|
||||
wait_ms((int)delay);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsCsLow
|
||||
* @brief Select chip select low
|
||||
*
|
||||
* @details This function does spi chip select low.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBmsCsLow()
|
||||
{
|
||||
spi.lock();
|
||||
chip_select = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsCsHigh
|
||||
* @brief Select chip select High
|
||||
*
|
||||
* @details This function does spi chip select high.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBmsCsHigh()
|
||||
{
|
||||
chip_select = 1;
|
||||
spi.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiWriteBytes
|
||||
* @brief Writes an array of bytes out of the SPI port.
|
||||
*
|
||||
* @details This function wakeup bms ic in IsoSpi mode send dumy byte data in spi line..
|
||||
*
|
||||
* @param [in] size Numberof bytes to be send on the SPI line
|
||||
*
|
||||
* @param [in] *tx_Data Tx data pointer
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiWriteBytes
|
||||
(
|
||||
uint16_t size, /*Option: Number of bytes to be written on the SPI port*/
|
||||
uint8_t *tx_data /*Array of bytes to be written on the SPI port*/
|
||||
)
|
||||
{
|
||||
uint8_t rx_data[size];
|
||||
spi.write((char *)tx_data, size ,(char *)rx_data, size);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiWriteReadBytes
|
||||
* @brief Writes and read a set number of bytes using the SPI port.
|
||||
*
|
||||
* @details This function writes and read a set number of bytes using the SPI port.
|
||||
*
|
||||
* @param [in] *tx_data Tx data pointer
|
||||
*
|
||||
* @param [in] *rx_data Rx data pointer
|
||||
*
|
||||
* @param [in] size Data size
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiWriteReadBytes
|
||||
(
|
||||
uint8_t *tx_data, /*array of data to be written on SPI port*/
|
||||
uint8_t *rx_data, /*Input: array that will store the data read by the SPI port*/
|
||||
uint16_t size /*Option: number of bytes*/
|
||||
)
|
||||
{
|
||||
uint16_t data_size = (4 + size);
|
||||
uint8_t cmd[data_size];
|
||||
memcpy(&cmd[0], &tx_data[0], 4); /* dst, src, size */
|
||||
spi.write((char *)cmd, data_size ,(char *)cmd, data_size);
|
||||
memcpy(&rx_data[0], &cmd[4], size); /* dst, src, size */
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiReadBytes
|
||||
* @brief Read number of bytes using the SPI port.
|
||||
*
|
||||
* @details This function Read a set number of bytes using the SPI port.
|
||||
*
|
||||
* @param [in] size Data size
|
||||
*
|
||||
* @param [in] *rx_data Rx data pointer
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiReadBytes(uint16_t size, uint8_t *rx_data)
|
||||
{
|
||||
uint8_t tx_data[size];
|
||||
for(uint8_t i=0; i < size; i++)
|
||||
{
|
||||
tx_data[i] = 0xFF;
|
||||
}
|
||||
spi.write((char *)tx_data, size ,(char *)rx_data, size);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: startTimer()
|
||||
* @brief Start timer
|
||||
*
|
||||
* @details This function start the timer.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void startTimer()
|
||||
{
|
||||
timer.start();
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: stopTimer()
|
||||
* @brief Stop timer
|
||||
*
|
||||
* @details This function stop the timer.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void stopTimer()
|
||||
{
|
||||
timer.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: getTimCount()
|
||||
* @brief Get Timer Count Value
|
||||
*
|
||||
* @details This function return the timer count value.
|
||||
*
|
||||
* @return tim_count
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
uint32_t getTimCount()
|
||||
{
|
||||
uint32_t count = 0;
|
||||
count = timer.read_us();
|
||||
timer.reset();
|
||||
return(count);
|
||||
}
|
||||
#else
|
||||
|
||||
#define SPI_TIME_OUT HAL_MAX_DELAY /* SPI Time out delay */
|
||||
#define UART_TIME_OUT HAL_MAX_DELAY /* UART Time out delay */
|
||||
#define I2C_TIME_OUT HAL_MAX_DELAY /* I2C Time out delay */
|
||||
|
||||
SPI_HandleTypeDef *hspi = &hspi1; /* MUC SPI Handler */
|
||||
UART_HandleTypeDef *huart = &huart5; /* MUC UART Handler */
|
||||
I2C_HandleTypeDef *hi2c = &hi2c1; /* MUC I2C Handler */
|
||||
TIM_HandleTypeDef *htim = &htim2; /* Mcu TIM handler */
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: Delay_ms
|
||||
* @brief Delay mili second
|
||||
*
|
||||
* @details This function insert delay in ms.
|
||||
*
|
||||
* Parameters:
|
||||
* @param [in] delay Delay_ms
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Delay_ms(uint32_t delay)
|
||||
{
|
||||
HAL_Delay(delay);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsCsLow
|
||||
* @brief Select chip select low
|
||||
*
|
||||
* @details This function does spi chip select low.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBmsCsLow()
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIO_PORT, CS_PIN, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsCsHigh
|
||||
* @brief Select chip select High
|
||||
*
|
||||
* @details This function does spi chip select high.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBmsCsHigh()
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIO_PORT, CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiWriteBytes
|
||||
* @brief Writes an array of bytes out of the SPI port.
|
||||
*
|
||||
* @details This function wakeup bms ic in IsoSpi mode send dumy byte data in spi line..
|
||||
*
|
||||
* @param [in] size Numberof bytes to be send on the SPI line
|
||||
*
|
||||
* @param [in] *tx_Data Tx data pointer
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiWriteBytes
|
||||
(
|
||||
uint16_t size, /*Option: Number of bytes to be written on the SPI port*/
|
||||
uint8_t *tx_Data /*Array of bytes to be written on the SPI port*/
|
||||
)
|
||||
{
|
||||
HAL_SPI_Transmit(hspi, tx_Data, size, SPI_TIME_OUT); /* SPI1 , data, size, timeout */
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiWriteReadBytes
|
||||
* @brief Writes and read a set number of bytes using the SPI port.
|
||||
*
|
||||
* @details This function writes and read a set number of bytes using the SPI port.
|
||||
*
|
||||
* @param [in] *tx_data Tx data pointer
|
||||
*
|
||||
* @param [in] *rx_data Rx data pointer
|
||||
*
|
||||
* @param [in] size Data size
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiWriteReadBytes
|
||||
(
|
||||
uint8_t *tx_data, /*array of data to be written on SPI port*/
|
||||
uint8_t *rx_data, /*Input: array that will store the data read by the SPI port*/
|
||||
uint16_t size /*Option: number of bytes*/
|
||||
)
|
||||
{
|
||||
HAL_SPI_Transmit(hspi, tx_data, 4, SPI_TIME_OUT);
|
||||
HAL_SPI_Receive(hspi, rx_data, size, SPI_TIME_OUT);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: spiReadBytes
|
||||
* @brief Read number of bytes using the SPI port.
|
||||
*
|
||||
* @details This function Read a set number of bytes using the SPI port.
|
||||
*
|
||||
* @param [in] size Data size
|
||||
*
|
||||
* @param [in] *rx_data Rx data pointer
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void spiReadBytes(uint16_t size, uint8_t *rx_data)
|
||||
{
|
||||
HAL_SPI_Receive(hspi, rx_data, size, SPI_TIME_OUT);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: startTimer()
|
||||
* @brief Start timer
|
||||
*
|
||||
* @details This function start the timer.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void startTimer()
|
||||
{
|
||||
HAL_TIM_Base_Start(htim);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: stopTimer()
|
||||
* @brief Stop timer
|
||||
*
|
||||
* @details This function stop the timer.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void stopTimer()
|
||||
{
|
||||
HAL_TIM_Base_Stop(htim);
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: getTimCount()
|
||||
* @brief Get Timer Count Value
|
||||
*
|
||||
* @details This function return the timer count value.
|
||||
*
|
||||
* @return tim_count
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
uint32_t getTimCount()
|
||||
{
|
||||
uint32_t count = 0;
|
||||
count = __HAL_TIM_GetCounter(htim);
|
||||
__HAL_TIM_SetCounter(htim, 0);
|
||||
return(count);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Function: adBmsWakeupIc
|
||||
* @brief Wakeup bms ic using chip select
|
||||
*
|
||||
* @details This function wakeup thr bms ic using chip select.
|
||||
*
|
||||
* @param [in] total_ic Total_ic
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void adBmsWakeupIc(uint8_t total_ic)
|
||||
{
|
||||
for (uint8_t ic = 0; ic < total_ic; ic++)
|
||||
{
|
||||
adBmsCsLow();
|
||||
Delay_ms(WAKEUP_DELAY);
|
||||
adBmsCsHigh();
|
||||
Delay_ms(WAKEUP_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
2090
Keil_Studio_Cloud/src/serialPrintResult.cpp
Normal file
2090
Keil_Studio_Cloud/src/serialPrintResult.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user