I2C BAE standalone hardware testing
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of ACS_Flowchart_BAE_1 by
Diff: EPS.h
- Revision:
- 0:7b4c00e3912f
- Child:
- 1:446a959e36ce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPS.h Thu Dec 24 19:15:43 2015 +0000 @@ -0,0 +1,126 @@ +#include <mbed.h> + + +#define tstart -40 +#define tstep 8 +#define tstep_thermistor 8 //verify everything!! +#define tstart_thermistor -40 +#define vstart 3.3 +#define vstep 0.84667 +#define cstart 0.0691 +#define cstep 0.09133 +#define rsens 0.095 + +#define m_ADDR (0x6C) //slave address + + //I2C register addresses +#define REG_VCELL 0x02 +#define REG_SOC 0x04 +#define REG_MODE 0x06 +#define REG_VERSION 0x08 +#define REG_HIBRT 0x0A +#define REG_CONFIG 0x0C +#define REG_VALRT 0x14 +#define REG_CRATE 0x16 +#define REG_VRESET_ID 0x18 +#define REG_STATUS 0x1A +#define REG_TABLE 0x40 +#define REG_CMD 0xFE + +//.............Power switching.......... +#define TRXY_DR_EN PIN82 //torque rod driver enable +#define TRZ_DR_EN PIN88 +#define ENBL3V3A PIN33 +#define VBATT PIN20 +#define BATT_HEAT PIN96 +//#define BATT_HEAT_OUTPUT + +void FCTN_EPS_POWERMODE(float soc) ; + +void HK_main(); +int quantiz(float start,float step,float x); + +void FCTN_BATTERYGAUGE_INIT(); +void FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters); + +unsigned short read(char reg); +void write(char reg, unsigned short data); +void reset(); //not used +void quickStart(); //not used +void disable_sleep(); +void disable_hibernate(); +void socChangeAlertEnabled(bool); +void compensation(char rcomp); +void tempCompensation(float temp); +void clearAlert(); +void emptyAlertThreshold(char threshold); +void vAlertMinMaxThreshold(); +void vResetThresholSet(); +void vResetAlertEnabled(bool enabled); +char alertFlags(); +void clearAlertFlags(); +float vcell(); +float soc(); +float crate(); +bool alerting(); +void vResetThresholdSet(); + +typedef struct BAE_HK_actual{ + float voltage_actual[16]; + float current_actual[12]; + float Batt_temp_actual[2]; + float Batt_gauge_actual[4]; + float BAE_temp_actual; + char power_mode; + float AngularSpeed_actual[3]; + float Bvalue_actual[3]; + float Batt_voltage_actual; +}BAE_HK_actual; + +typedef struct BAE_HK_quant{ + char voltage_quant[16]; //power_mode should be appended to sd card + char current_quant[12]; + char Batt_temp_quant[2]; + char Batt_gauge_quant[3]; + float Batt_gauge_alerts; + char BAE_temp_quant; + char AngularSpeed_quant[3]; + float Bvalue_quant[3]; + char Batt_voltage_quant; +}BAE_HK_quant; + +typedef struct BAE_HK_arch{ + + char Batt_1_temp; + char Batt_2_temp; + char EPS_PCB_temp; + char Batt_SOC; + char power_mode; + char Batt_voltage; + //char Batt_voltage2; + // char Digital power bus voltage; + + +}BAE_HK_arch; + +typedef struct BAE_HK_min_max{ + char voltage_max[16]; + char current_max[12]; + char Batt_temp_max[2]; + char Batt_gauge_max[3]; + char BAE_temp_max; + char AngularSpeed_max[3]; + float Bvalue_max[3]; + char Batt_voltage_max; + + char voltage_min[16]; + char current_min[12]; + char Batt_temp_min[2]; + char Batt_gauge_min[3]; + char BAE_temp_min; + char AngularSpeed_min[3]; + float Bvalue_min[3]; + char Batt_voltage_min; + +}BAE_HK_min_max; +