Added EPS faults
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of QM_BAE_review_1 by
Diff: EPS.cpp
- Revision:
- 16:5f0f2a3f3e8d
- Parent:
- 15:e09aaaccf134
--- a/EPS.cpp Tue Apr 19 21:27:07 2016 +0000 +++ b/EPS.cpp Mon Jun 13 10:37:50 2016 +0000 @@ -57,6 +57,42 @@ extern char EPS_BATTERY_HEAT_ENABLE ; +//eps cdms fault +extern uint8_t CDMS_SW_STATUS; +extern bool CDMS_OC_FAULT; +extern bool CDMS_SW_ENABLE; +extern int CDMS_FAULT_COUNTER; + +//eps hw faults + +extern uint8_t ACS_TR_Z_SW_STATUS; +extern bool ACS_TR_Z_ENABLE; +extern bool ACS_TR_Z_OC_FAULT; +extern bool ACS_TR_Z_FAULT; //Driver IC fault +extern int ACS_TR_Z_FAULT_COUNTER; + +extern uint8_t ACS_TR_XY_SW_STATUS; +extern bool ACS_TR_XY_ENABLE; +extern bool ACS_TR_XY_OC_FAULT; +extern bool ACS_TR_XY_FAULT; //Driver IC fault +extern int ACS_TR_XY_FAULT_COUNTER; + +extern uint8_t ACS_ATS1_SW_STATUS; +extern bool ACS_ATS1_ENABLE; +extern bool ACS_ATS1_OC_FAULT; +extern int ACS_ATS1_FAULT_COUNTER; + +extern uint8_t ACS_ATS2_SW_STATUS; +extern bool ACS_ATS2_ENABLE; +extern bool ACS_ATS2_OC_FAULT; +extern int ACS_ATS2_FAULT_COUNTER; + +extern uint8_t BCN_TX_SW_STATUS; +extern bool BCN_TX_ENABLE; +extern bool BCN_TX_OC_FAULT; +extern int BCN_TX_FAULT_COUNTER; + + //........................................... FUCTIONS.................................................// void FCTN_EPS_INIT() @@ -87,6 +123,117 @@ } +void FCTN_EPS_HANDLE_CDMS_FAULT() +{ //Variable names from MMS structure, if not, marked as //Temp name + if(CDMS_SW_STATUS == 0b11) //powered on and oc fault + if(!CDMS_OC_FAULT) + CDMS_SW_STATUS = 0b01; //powered on and working + else + { + if(CDMS_SW_STATUS == 0b10) //powered off and oc fault + CDMS_SW_ENABLE = 1; //Temp name + if(CDMS_OC_FAULT == 0) + { + CDMS_FAULT_COUNTER = 0; //Temp name + CDMS_SW_STATUS = 0b01; //powered on and working + } + else + { + CDMS_FAULT_COUNTER++; + if(CDMS_FAULT_COUNTER == 3) + CDMS_SW_STATUS = 0b11; //powered on and oc fault + else + { + CDMS_SW_ENABLE = 0; //power OFF switch + CDMS_SW_STATUS = 0b10; //powered off and oc fault + } + } + } +} + +void FCTN_EPS_HANDLE_HW_FAULTS() +{ //Variable names from MMS structure, if not, marked as //Temp name + + //--------ACS_TR_Z--------// + if(ACS_TR_Z_SW_STATUS != 0b11) //!disabled + { + if(ACS_TR_Z_SW_STATUS == 0b10) //oc fault and powered off + ACS_TR_Z_ENABLE = 1; + if(ACS_TR_Z_OC_FAULT || ACS_TR_Z_FAULT) + { + ACS_TR_Z_ENABLE = 0; + ACS_TR_Z_FAULT_COUNTER++; //Temp name + if(ACS_TR_Z_FAULT_COUNTER == 3) + ACS_TR_Z_SW_STATUS = 0b11; //disabled + //update in flash as default state at bootup + else ACS_TR_Z_SW_STATUS = 0b10; //oc fault and powered off + } + else + { + ACS_TR_Z_SW_STATUS = 0b01; //powered on and working; + //update in flash also + ACS_TR_Z_FAULT_COUNTER = 0; + } + } + + //--------ACS_TR_XY--------// + //Same as ACS_TR_Z, just replace Z with XY + + //--------ACS_ATS1--------// + //Same as ACS_ATS2 + + //--------ACS_ATS2--------// + if(ACS_ATS2_SW_STATUS & 0b1100 != 0b1100) //!disabled + { + if(ACS_ATS2_SW_STATUS & 0b1100 == 0b1000) //oc fault and powered off + ACS_ATS2_ENABLE = 1; //Temp name + if(ACS_ATS2_OC_FAULT) + { + ACS_ATS2_ENABLE = 0; + ACS_ATS2_FAULT_COUNTER++; //Temp name + if(ACS_ATS2_FAULT_COUNTER == 3) + ACS_ATS2_SW_STATUS = ACS_ATS2_SW_STATUS | 0b1100; //disabled + //update in flash as default state at bootup + else + { + ACS_ATS2_SW_STATUS = ACS_ATS2_SW_STATUS | 0b1000; //setting to 10xx + ACS_ATS2_SW_STATUS = ACS_ATS2_SW_STATUS & 0b1011; //oc fault and powered off + } + } + else + { + if(ACS_ATS2_SW_STATUS & 0b1100 == 0b1000) //Device oc fault? + ACS_ATS2_ENABLE = 0; + ACS_ATS2_SW_STATUS = ACS_ATS2_SW_STATUS & 0b0011; //working but powered off + //Update in flash also + ACS_ATS2_FAULT_COUNTER = 0; + } + } + + //--------BCN_TX----------// + if(BCN_TX_SW_STATUS != 0b11) //!disabled + { + if(BCN_TX_SW_STATUS == 0b10) //oc fault and powered off + BCN_TX_ENABLE = 1; //Temp name + if(BCN_TX_OC_FAULT) + { + BCN_TX_ENABLE = 0; + BCN_TX_FAULT_COUNTER++; //Temp name + if(BCN_TX_FAULT_COUNTER == 3) + BCN_TX_SW_STATUS = 0b11; //disabled + //update in flash as default state at bootup + else BCN_TX_SW_STATUS = 0b10; //oc fault and powered off + } + else + { + BCN_TX_SW_STATUS = 0b01; //powered on and working; + //update in flash also + BCN_TX_FAULT_COUNTER = 0; + } + } + +} + //----------------------------------------------------Power algo code--------------------------------------------------------------------// /*update the power modes*/ @@ -693,6 +840,7 @@ //HS=0; spi_bt.format(8,3); spi_bt.frequency(1000000); + EPS_BATTERY_TEMP_STATUS = 1; } void FCTN_BATT_TEMP_SENSOR_MAIN(float temp[2])