Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
Diff: FMS_functions.h
- Revision:
- 206:fba4aeebf004
diff -r 5f75962ae7ea -r fba4aeebf004 FMS_functions.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FMS_functions.h Thu Jun 30 14:00:33 2016 +0000
@@ -0,0 +1,187 @@
+#include "CDMS_HK.h"
+
+uint8_t ACK_CODE;
+
+void CDMS_standby_prcs();
+void CDMS_run_prcs();
+void CDMS_rst_pwr();
+void CDMS_swch_pwr_on();
+void CDMS_swch_pwr_off();
+void CDMS_rst_hk_counter();
+void CDMS_rd_rtc();
+void CDMS_mng_rtc();
+void CDMS_rd_sd_hk();
+
+extern uint8_t PL_STANDBY_STATE;
+extern bool STANDBY_PL;
+extern uint8_t CDMS_HK_STANDBY_STATE;
+extern bool STANDBY_CDMS_HK;
+
+extern bool SD_RD_ERROR;
+
+extern uint8_t BAE_STATUS;
+extern uint8_t PL_STATUS;
+extern uint8_t SD_STATUS;
+
+// These are defined in CDMS_HK.h Please check
+#define DEVICE_ENABLED 0x00;
+#define DEVICE_POWERED 0x01;
+#define DEVICE_OC_FAULT 0x02;
+#define DEVICE_DISABLED 0x03;
+DigitalOut SD_SW_EN_DS (PIN97);
+DigitalOut BAE_SW_EN_DS (PIN47);
+
+
+void CDMS_standby_prcs() // FID = 0x40
+{
+ if(PL_STANDBY_STATE = 0x00)
+ STANDBY_PL = 0;
+ if(PL_STANDBY_STATE = 0x01)
+ STANDBY_PL = 1;
+ if(CDMS_HK_STANDBY_STATE = 0x00)
+ STANDBY_CDMS_HK = 0;
+ if(CDMS_HK_STANDBY_STATE = 0x01)
+ STANDBY_CDMS_HK = 1;
+ if(RCV_SC_STANDBY_STATE = 0x00)
+ RCV_SC = 0;
+ if(RCV_SC_STANDBY_STATE = 0x01)
+ RCV_SC = 1;
+ ACK_CODE = 0xC0;
+ // Generate the TM
+}
+
+void CDMS_run_prcs() // FID = 0x0_
+{
+
+}
+
+void CDMS_rst_pwr(uint8_t FID) // FID = 0x3_
+{
+ switch(FID){
+ case 0x31 : //power reset SD
+ SD_SW_EN_DS = 0; //switching OFF
+ wait_ms(10);
+ SD_SW_EN_DS = 1; //switching ON
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+}
+
+void CDMS_swch_pwr_on(uint8_t FID) // FID = 0x1_
+{
+ if(FID = 0x14)
+ {
+ PL_STATUS = DEVICE_ENABLED;
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+ else if(FID = 0x13)
+ {
+ BAE_STATUS = DEVICE_POWERED;
+ BAE_SW_EN_DS = 1; //Power ON BAE
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+ else if(FID = 0x11)
+ {
+ SD_STATUS = DEVICE_POWERED;
+ SD_SW_EN_DS = 1; //Power ON SD
+ FCTN_CDMS_SD_INIT();
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+ else
+ {
+ ACK_CODE = 0x02;
+ // Generate TM
+ }
+}
+
+void CDMS_swch_pwr_off(uint8_t FID) // FID = 0x2_
+{
+ if(FID = 0x24)
+ {
+ PL_SW_EN_DS = 0; //switching OFF PL
+ PL_STATUS = DEVICE_DISABLED;
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+ else if(FID = 0x23)
+ {
+ BAE_SW_EN_DS = 0; //Switching OFF BAE
+ BAE_STATUS = DEVICE_DISABLED;
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+ else if(FID = 0x21)
+ {
+ SD_SW_EN_DS = 0; //Switching OFF SD
+ SD_STATUS = DEVICE_DISABLED;
+ FCTN_CDMS_SD_INIT();
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+ else
+ {
+ ACK_CODE = 0x02;
+ // Generate TM
+ }
+}
+
+void CDMS_rst_hk_counter() // FID = 0x41
+{
+
+}
+
+void CDMS_rd_rtc() // FID = 0xF1
+{
+ uint8_t time = FCTN_CDMS_RD_RTC();
+ // Check if time is read properly
+ if( /*if error in reading*/ )
+ {
+ ACK_CODE = 0x88;
+ // Generate TM
+ }
+ else if( /*if Time is read properly*/ )
+ {
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+}
+
+void CDMS_mng_rtc(uint64_t time)
+{
+
+}
+
+void CDMS_rd_sd_hk()
+{
+ uint8_t sd_statusbits[64];
+ uint8_t *p;
+ int i;
+ if(SD_SW_EN_DS != DEVICE_POWERED)
+ {
+ ACK_CODE = 0x89;
+ SD_RD_ERROR = 1;
+ //Generate TM
+ }
+ else
+ {
+ p = disk_read_statusbits();
+ if(p != NULL)
+ {
+ for(i = 0; i<64; i++)
+ sd_statusbits[i] = *(p + i);
+ SD_RD_ERROR = 0;
+ ACK_CODE = 0xA0;
+ // Generate TM
+ }
+ else
+ {
+ ACK_CODE = 0x89;
+ SD_RD_ERROR = 1;
+ //Generate TM
+ }
+ }
+}
+
