Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Diff: CDMS_HK.h
- Revision:
- 269:24c50959b0a4
- Parent:
- 268:ded5306a1fd1
- Child:
- 270:9dacc1d8459a
diff -r ded5306a1fd1 -r 24c50959b0a4 CDMS_HK.h --- a/CDMS_HK.h Wed Jul 20 09:58:59 2016 +0000 +++ b/CDMS_HK.h Thu Jul 21 10:46:36 2016 +0000 @@ -11,6 +11,8 @@ void minMaxHkData(); void COLLECT_CDMS_RAM(); +extern uint8_t beacon_array[134]; + AnalogIn TempInput(PIN27); // Input from Current Multiplexer AnalogIn CDMS_temp_sensor(PIN53); AnalogIn COMRX_RSSI_volatge(PIN70); @@ -150,16 +152,39 @@ gPC.printf("Completed BAE HK\n"); /*----------------------------------Beacon message--------------------------------------*/ - unsigned char SC_HK_LBM_0[135]; - SC_HK_LBM_0[0] = 0; // Sending long beacon msg as telecommand with Packet sequence count 0x00 + + // Add HK bits - + beacon_array[0] = 0x00; + beacon_array[1] = time >> 32; + beacon_array[2] = time >> 24; + beacon_array[3] = time >> 16; + beacon_array[4] = time >> 8; + beacon_array[5] = time; + beacon_array[6] = SD_FAULTCOUNT >> 8; + beacon_array[7] = SD_FAULTCOUNT; + beacon_array[8] = RTC_FAULTCOUNT >> 8; + beacon_array[9] = RTC_FAULTCOUNT; + beacon_array[10] = (((SD_STATUS == DEVICE_DISABLED || SD_STATUS == DEVICE_OC_FAULT)?1:0)<<7)|(RTC_STATUS <<6)|(COM_RX_STATUS<<3)|(V_C_PGOOD<<2)|(COMRX_OC_FAULT<<1)|(COMTX_OC_FAULT); + beacon_array[11] = (EPS_V_C_EN_STATUS <<7)|(EPS_V_D_EN_STATUS); + beacon_array[12] = CDMS_HK_MAIN_COUNTER >>8; + beacon_array[13] = CDMS_HK_MAIN_COUNTER; + beacon_array[14] = PL_MAIN_COUNTER >>8; + beacon_array[15] = PL_MAIN_COUNTER; + beacon_array[16] = PL_RCV_SC_DATA_COUNTER >>8; + beacon_array[17] = PL_RCV_SC_DATA_COUNTER; + beacon_array[18] = TIME_LATEST_SPI_SPEED >>24; + beacon_array[19] = TIME_LATEST_SPI_SPEED >>16; + beacon_array[20] = TIME_LATEST_SPI_SPEED >>8; + beacon_array[21] = TIME_LATEST_SPI_SPEED; + beacon_array[22] = (uint8_t)RSSI_volatge; + // Add SC bits - crc = crc16_gen(SC_HK_LBM_0,133); - SC_HK_LBM_0[132] = crc; - SC_HK_LBM_0[133] = crc >> 8; + crc = crc16_gen(beacon_array,132); + beacon_array[132] = crc; + beacon_array[133] = crc >> 8; bool y; - y = FCTN_I2C_WRITE((char *)SC_HK_LBM_0,135); + y = FCTN_I2C_WRITE((char *)beacon_array,134); if(y == 0) gPC.printf("long Bcn sent\n\r"); else @@ -316,21 +341,17 @@ void VERIFY_RTC() { - if(RTC_STATUS == 0x00) { - if(RTC_FAULTCOUNT == 3) - return; SPI_mutex.lock(); gCS_RTC=1; gCS_RTC=0; spi.write(0x0F); if(spi.write(0x00) & 0x04 == 0x04) { - RTC_STATUS = 0x00; + RTC_STATUS = 0x01; RESET_RTC(); RTC_FAULTCOUNT++; } gCS_RTC=1; SPI_mutex.unlock(); - } } void HANDLE_HW_FAULTS()