Team Fox / Mbed 2 deprecated workinQM_5thJan_azad

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of workinQM_10thDec by Team Fox

Revision:
58:c4203e162d12
Parent:
51:661dc022613a
Child:
66:a5d2b8dc6b9e
--- a/BCN.cpp	Sun Sep 04 13:08:33 2016 +0000
+++ b/BCN.cpp	Sun Sep 04 18:05:31 2016 +0000
@@ -12,6 +12,8 @@
 Timer timer_Set_BCN_TX_STATUS_SUCCESS;
 Timer timer_Set_BCN_TX_STATUS_FAILURE;
 
+extern BAE_HK_actual actual_data;
+
  
 DigitalOut bcn_sw(PIN14,0);
 Serial pc_bcn(USBTX, USBRX);        //tx,rx
@@ -33,7 +35,7 @@
 uint8_t BCN_TX_SW_STATUS = 1;
 uint8_t BCN_FEN = 0;                //hardcoding for now    //write this value to flash
 uint8_t BCN_SPND_TX = 0;            //hardcoding for now    //check where is this variable toggled??
-uint8_t BCN_TMP = 0;          // For Temperature
+uint8_t BCN_TMP = 5;          // For Temperature
 uint8_t ERROR_CHECK = 0;
 uint8_t BCN_FAIL_COUNT = 0;         //Flag for keeping count of no. of times of BCN failure in init or one transmission in 30 secs (failure in spi communication)
                                     //This Flag when exceeds a threshold, uC should reset.
@@ -53,6 +55,8 @@
 extern DigitalIn EPS_CHARGER_STATUS;
 extern uint8_t crc8_short();
 
+extern uint8_t float_to_uint8(float min,float max,float val);
+
 void SHORT_HK_data_AQ()
 {   
     uint8_t days,hours,mins;//for calculating the timing data in bae i2c uptime
@@ -69,17 +73,18 @@
     
     SHORT_HK_data[7] = quant_data.voltage_quant[15];
     SHORT_HK_data[7] = (SHORT_HK_data[7] & 0xF0) | (quant_data.current_quant[1]>>4);
-    SHORT_HK_data[8] = 0xFF;
-    //braga SHORT_HK_data[8] = acs first 4 bit
+    
+    //taking only the most significant bits
+    SHORT_HK_data[8] = actual_data.bit_data_acs_mg[0]>>8;
     SHORT_HK_data[8] = (SHORT_HK_data[8] & 0xF0) | BCN_TMP>>4;
-    SHORT_HK_data[9] = 0xFF;
-    //SHORT_HK_data[9] = float_to_uint8(min,max,EPS_BTRY_TMP_AVG); min max diss azad
+    //SHORT_HK_data[9] = 0xFF;
+    SHORT_HK_data[9] = float_to_uint8(-50,100,EPS_BTRY_TMP_AVG);
     SHORT_HK_data[9] = (SHORT_HK_data[9]&0xF0) | BAE_RESET_COUNTER>>4;
     
     
     RETURN_UPTIME(BAE_uptime.read(),&days,&hours,&mins);
     SHORT_HK_data[10] = CDMS_OC_FAULT;
-    //SHORT_HK_data[10] = (1<<SHORT_HK_data[10]) | receiver_oc_fault//to be diss;
+    SHORT_HK_data[10] = (SHORT_HK_data[10]<<1) | 0;//receiver_oc_fault//to be diss;
     SHORT_HK_data[10] = (SHORT_HK_data[10]<<1) | ((quant_data.voltage_quant[12]>>2)&0x3C);
     SHORT_HK_data[10] = (SHORT_HK_data[10]<<2) | ((days>>3)&0x03);
     SHORT_HK_data[11] = (days<<5) | (hours&0x1F);
@@ -157,6 +162,7 @@
                 uint8_t temp_temp = check_Temperature();
                 if( temp_temp != 0xFF )
                     BCN_TMP = temp_temp;
+                    printf("\n\rthe BCN_TMP is %d\n",temp_temp);
                 pc_bcn.printf("temperature = %d\n\r",BCN_TMP);
                 //Get BCN_HK data from BCN HW(SPI) //Store BCN_HK data in BCN_HK_BUFFER
                 printf("BCN_SPND_TX = %d\n\r",BCN_SPND_TX);
@@ -226,16 +232,17 @@
 {   
     uint8_t temperature;
     writereg(RF22_REG_0F_ADC_CONFIGURATION,0x00);//set ADC to temp measurement            
-    writereg(RF22_REG_12_Temperature_Sensor_Calibration,0x60);//measure in degree celsius
+    writereg(RF22_REG_12_Temperature_Sensor_Calibration,0x20);//measure in degree celsius
     writereg(RF22_REG_0F_ADC_CONFIGURATION,0x80);//start adc
     wait(0.1);
-    if( readreg(RF22_REG_0F_ADC_CONFIGURATION) & 0x80 == 0x00 )
+    //if( readreg(RF22_REG_0F_ADC_CONFIGURATION) & 0x80 == 0x80 )
         {    
             temperature = readreg(RF22_REG_11_ADC_Value);
-            temperature = (float)temperature - 64;  //* 0.5 factor
+            temperature = (float)temperature*0.5 - 64;  //* 0.5 factor
         }
-    else temperature = 0xFF;
+    //else temperature = 0xFF;
    // temperature = (float)temperature*0.5 - 64;
+   printf("\n\rthe vLKUE OF TEMPO %d",temperature);
     return temperature;
 }