Team Fox / Mbed 2 deprecated BAE_QM_MAR9

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of workinQM_5thJan_azad by Team Fox

Revision:
44:da258a0977a4
Parent:
43:dec54ff03d3f
diff -r dec54ff03d3f -r da258a0977a4 main.cpp
--- a/main.cpp	Thu Jul 07 19:45:45 2016 +0000
+++ b/main.cpp	Mon Jul 11 19:01:12 2016 +0000
@@ -198,7 +198,8 @@
 extern uint8_t EPS_BAT_TEMP_DEFAULT;
 float EPS_BTRY_TMP_AVG;
 extern DigitalInOut BTRY_HTR_ENABLE;
-
+int eps_btg_read_flag;  // flag to check I2C ack on reading from BTG
+int eps_btg_writ_flag;  // flag to check I2C ack on writing from BTG
 //extern void FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters);
 
 
@@ -677,6 +678,7 @@
 void F_EPS()
 {
       float eps_btry_temp;
+      int BTG_MAIN_FLAG,btg_status_flag = 0; 
       pc.printf("\n\rEntered EPS   %f\n\r",t_start.read());
       EPS_MAIN_STATUS = 1; // Set EPS main status
       EPS_MAIN_COUNTER++;
@@ -719,16 +721,23 @@
       }  
  
         unsigned short statusreg = read(REG_STATUS);
-        if( EPS_BATTERY_GAUGE_STATUS == 0 ) reset();
-        if( read(REG_STATUS)  & 0x0100 == 0x0100 )     //checking if Reset Indicator bit is set
+        if( eps_btg_read_flag != 0 || (read(REG_STATUS)  & 0x0100) == 0x0100 ) 
         {
-            printf("REG_STATUS = %d\r\n",read(REG_STATUS));    
+            printf("REG_STATUS = %d,BTG_INIT\r\n",read(REG_STATUS));   
             FCTN_BATTERYGAUGE_INIT();
-        }    
-        int BTG_MAIN_FLAG = FCTN_BATTERYGAUGE_MAIN(actual_data.Batt_gauge_actual, eps_btry_temp);
-        if( BTG_MAIN_FLAG == 0 )                      //Data not received
+            if(EPS_BATTERY_GAUGE_STATUS != 1) btg_status_flag = 1;
+                
+        }
+        //if( EPS_BATTERY_GAUGE_STATUS == 0 ) reset();
+        //if( read(REG_STATUS)  & 0x0100 == 0x0100 )     //checking if Reset Indicator bit is set
+        //{
+        //   printf("REG_STATUS = %d\r\n",read(REG_STATUS));    
+        //    FCTN_BATTERYGAUGE_INIT();
+        //}    
+        BTG_MAIN_FLAG = FCTN_BATTERYGAUGE_MAIN(actual_data.Batt_gauge_actual, eps_btry_temp);
+        if( BTG_MAIN_FLAG == 1 || btg_status_flag == 1 )                      //Data not received
             {
-              actual_data.power_mode = 1;
+              actual_data.power_mode = 0;
               EPS_BATTERY_GAUGE_STATUS = 0;           //clear EPS_BATTERY_GAUGE_STATUS 
             }
         else
@@ -1036,15 +1045,17 @@
             if( BAE_STANDBY!=0x01 && BAE_STANDBY!=0x03 && BAE_STANDBY!=0x05 && BAE_STANDBY!=0x07)
                 {
                     //time_wdog = 1;
-                    //F_EPS();
+                    F_EPS();
                 }
             //time_wdog = 0;
         }
     if(schedcount%6==0)
         {
             if(BAE_STANDBY!=0x04 && BAE_STANDBY!=0x05 && BAE_STANDBY!=0x06 && BAE_STANDBY!=0x07)
+            {
             //  time_wdog = 0;
-             F_BCN();
+             //F_BCN();
+             }
         }
     schedcount++;
     #if print
@@ -1206,8 +1217,8 @@
     
     //...........order mentioned in flow chart.................//
     //FCTN_ACS_INIT();
-    //FCTN_EPS_INIT();
-    FCTN_BCN_INIT();
+    FCTN_EPS_INIT();
+    //FCTN_BCN_INIT();
     
     //uint32_t data_flash=FCTN_BAE_RD_FLASH_ENTITY(0);/*sending the 0 entity as in mms tc/tm bae_reset_counter is present in first 32 bits */
     //uint32_t data_modify=data_flash & 0x000000FF;