Team Fox / Mbed 2 deprecated BAE_QM_MAR9

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of workinQM_5thJan_azad by Team Fox

Revision:
101:cf1976e16f28
Parent:
99:2cc5c0c98cb3
diff -r af43bc82d3eb -r cf1976e16f28 BCN.cpp
--- a/BCN.cpp	Thu Mar 09 08:08:10 2017 +0000
+++ b/BCN.cpp	Tue Mar 28 08:48:42 2017 +0000
@@ -35,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 = 5;          // For Temperature
+int 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.
@@ -72,23 +72,24 @@
     SHORT_HK_data[5] = 0x28;
     SHORT_HK_data[6] = 0x8A;
     
-    SHORT_HK_data[7] = (quant_data.voltage_quant[0]/10)<<4; // bat voltage: changed by samp from quant_data.voltage_quant[15] to quant_data.voltage_quant[0]
-    SHORT_HK_data[7] = (SHORT_HK_data[7] & 0xF0) | (quant_data.current_quant[0]/100); //>>4, solar bus current changed from quant_data.current_quant[1] to quant_data.current_quant[0]
+    SHORT_HK_data[7] = (quant_data.voltage_quant[0])<<4; // bat voltage: changed by samp from quant_data.voltage_quant[15] to quant_data.voltage_quant[0]
+    SHORT_HK_data[7] = (SHORT_HK_data[7] & 0xF0) | (quant_data.current_quant[0]); //>>4, solar bus current changed from quant_data.current_quant[1] to quant_data.current_quant[0]
     
     //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+50)>>3;
     //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;
-    
+    SHORT_HK_data[9] = (SHORT_HK_data[9]&0xF0) | BAE_RESET_COUNTER>>4;  //
+     pc_bcn.printf("\n\n\r acs_mg = %d \n",actual_data.bit_data_acs_mg[0]);
     
     //RETURN_UPTIME(BAE_uptime.read(),&days,&hours,&mins);
     RETURN_UPTIME(BAE_uptime.read(),&days,&hours,&mins);
     
     SHORT_HK_data[10] = ~CDMS_OC_FAULT<<7;
     SHORT_HK_data[10] = (SHORT_HK_data[10]) | 0;//receiver_oc_fault//to be diss - Is it (tc[10]>>1)&0x01 ?
-    SHORT_HK_data[10] = (SHORT_HK_data[10]) | (((quant_data.voltage_quant[5]/4)<<2)&0x3C);
+    SHORT_HK_data[10] = (SHORT_HK_data[10]) | (((quant_data.voltage_quant[5])<<2)&0x3C);
     SHORT_HK_data[10] = (SHORT_HK_data[10]) | ((hours>>2)&0x03);// just for testing purpose change it to days 5 bits ((days>>3)&0x03)
     SHORT_HK_data[11] = (hours<<6) | (mins&0x3F);//(days<<5) | (hours&0x1F);
     
@@ -102,10 +103,15 @@
     SHORT_HK_data[13] = (days<<6) | (mins&0x3F);
 
     SHORT_HK_data[14] = crc8_short();   
+    pc_bcn.printf("\n\n\r  hrs = %x\n",days);
+     pc_bcn.printf("\n\n\r  min = %x\n",mins);
+     
     
     #if short_bcn_print
     pc_bcn.printf("\n\rShort BCN data:\n");
     for(int ib = 0;ib<15;ib++) pc_bcn.printf("\n\r%02x",SHORT_HK_data[ib]);
+    pc_bcn.printf("\n\rsolar Ibits= %d\n",quant_data.current_quant[0]/16);
+     pc_bcn.printf("\n\rsolar I= %d\n",quant_data.current_quant[0]);
     pc_bcn.printf("\n\rV_D = %d\n",quant_data.voltage_quant[6]);
     pc_bcn.printf("V_C = %d\n",quant_data.voltage_quant[5]);
     pc_bcn.printf("V_C in bits = %x\n",(quant_data.voltage_quant[5])&0x3C);
@@ -407,8 +413,8 @@
         }
         
     }
-    Read_I_B_IN_BCN();
-    wait_ms(70);
+  //  Read_I_B_IN_BCN();
+  //  wait_ms(70);
     
     if( BCN_SW == 1 )
     {
@@ -466,7 +472,9 @@
             }
             else if(count == 2)
             {
-                reset_rfm(1); pc_bcn.printf("reg = 0x%X\n",reg);break;
+                 reset_rfm(1);
+                 pc_bcn.printf("reg = 0x%X\n",reg);
+                 break;
             }
             else init_spi();
         }