working version
Dependencies: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
Diff: FMS_all.h
- Revision:
- 357:f3d48d62e00e
- Parent:
- 356:197c93dc2012
--- a/FMS_all.h Sat Feb 10 09:06:26 2018 +0000 +++ b/FMS_all.h Sun Apr 03 15:35:53 2022 +0000 @@ -35,8 +35,6 @@ void RST_BAE(); void RST_PL_BEE(); void CDMS_RESET(); -void SYS_PWR_RESET(); // Have to be decided with EPS team. -void sys_pwr_reset(void const *args); void EPS_V_A_EN(); void EPS_V_C_EN(); @@ -45,10 +43,6 @@ void CDMS_CALIB_RTC(uint8_t *); void TOTAL_RESET_WITH_CDMS(); -void sys_pwr_reset(void const *args){ - SYS_PWR_RESET(); -} - void P_PL_INIT() { @@ -81,11 +75,13 @@ void CDMS_SD_SW_ON() { + wait_ms(100); // SD_CARD_fromuC_ENA3 = 1; // SD_CARD_fromISO_ENA4 = 1; SD_SW_EN_DS = 1; SD_STATUS = DEVICE_POWERED; - FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED); + WRITE_TO_EEPROM(2,DEVICE_POWERED); + //FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED); gPC.printf("sw on sd\n"); } @@ -96,12 +92,16 @@ SD_SW_EN_DS = 0; SD_STATUS = DEVICE_DISABLED; // SD_STATUS = 0; - FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED); + //FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED); + WRITE_TO_EEPROM(2,DEVICE_DISABLED); + wait_ms(100); gPC.printf("sw off sd\n"); } void CDMS_RTC_ON() { + WRITE_TO_EEPROM(6,DEVICE_POWERED); + wait_ms(100); //FCTN_CDMS_INIT_RTC(); SPI_mutex.lock(); gCS_RTC=1; @@ -121,7 +121,7 @@ //EN_RTC = 0x01; CDMS_RTC_DISABLE =1; - FCTN_CDMS_WR_FLASH(6,DEVICE_POWERED); + //FCTN_CDMS_WR_FLASH(6,DEVICE_POWERED); // gPC.printf("0x%08X \n", READ_FROM_EERPOM(6)); SPI_mutex.unlock(); gPC.printf("sw on rtc\n"); @@ -147,7 +147,9 @@ //EN_RTC = 0x00; CDMS_RTC_DISABLE = 0; - FCTN_CDMS_WR_FLASH(6,0x00); + //FCTN_CDMS_WR_FLASH(6,0x00); + WRITE_TO_EEPROM(6,0x00); + wait_ms(100); SPI_mutex.unlock(); gPC.printf("sw off rtc\n"); } @@ -156,7 +158,9 @@ { BAE_SW_EN_DS = 1; BAE_STATUS = DEVICE_POWERED; - FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED); + //FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED); + WRITE_TO_EEPROM(1,DEVICE_POWERED); + wait_ms(100); gPC.printf("sw on bae\n"); } @@ -165,7 +169,9 @@ BAE_SW_EN_DS = 0; BAE_STATUS = DEVICE_DISABLED; // BAE_STATUS = 0; - FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED); + //FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED); + WRITE_TO_EEPROM(1,DEVICE_DISABLED); + wait_ms(100); gPC.printf("sw off bae\n"); } @@ -179,7 +185,10 @@ PYLD_DFF_CLK = 0; wait_us(1); PL_BEE_SW_STATUS = DEVICE_POWERED; - FCTN_CDMS_WR_FLASH(4,DEVICE_POWERED); + //PL_STATE = 0x01; //uncomment - JOel after figuring out PYLD startup state + //WRITE_TO_EEPROM(16,(int32_t)PL_STATE); + //FCTN_CDMS_WR_FLASH(4,DEVICE_POWERED); + WRITE_TO_EEPROM(4,DEVICE_POWERED); } void SW_OFF_PL_BEE() @@ -192,7 +201,10 @@ PYLD_DFF_CLK = 0; wait_us(1); PL_BEE_SW_STATUS = DEVICE_DISABLED; - FCTN_CDMS_WR_FLASH(4,DEVICE_DISABLED); + //FCTN_CDMS_WR_FLASH(4,DEVICE_DISABLED); + PL_STATE = 0x00; + WRITE_TO_EEPROM(16,(int32_t)PL_STATE); + WRITE_TO_EEPROM(4,DEVICE_DISABLED); } void SW_ON_PL_EPS() @@ -227,14 +239,16 @@ { V_A_EN = 1; EPS_V_A_EN_STATUS = 1; - FCTN_CDMS_WR_FLASH(0,1); + //FCTN_CDMS_WR_FLASH(0,1); + WRITE_TO_EEPROM(0,1); } void SW_OFF_V_A_EN() { V_A_EN = 0; EPS_V_A_EN_STATUS = 0; - FCTN_CDMS_WR_FLASH(0,0); + //FCTN_CDMS_WR_FLASH(0,0); + WRITE_TO_EEPROM(0,0); } void RST_SD() @@ -247,18 +261,22 @@ SD_CARD_fromISO_ENA4 = 1; SD_SW_EN_DS = 1; SD_STATUS = DEVICE_POWERED; - FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED); + //FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED); + WRITE_TO_EEPROM(2,DEVICE_POWERED); + wait_ms(100); gPC.printf("rst sd\n"); } void SW_RST_BAE() { - BAE_SW_EN_DS = 0; - wait(5); - BAE_SW_EN_DS = 1; + BAE_SW_EN_DS = 0; + wait(5); + BAE_SW_EN_DS = 1; BAE_STATUS = DEVICE_POWERED; - FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED); + //FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED); + WRITE_TO_EEPROM(1,DEVICE_POWERED); + wait_ms(100); gPC.printf("rst bae\n"); } @@ -276,6 +294,9 @@ RESET_TO_BAE = 0; wait_ms(10); RESET_TO_BAE = 1; + BAE_STATUS = DEVICE_POWERED; + + WRITE_TO_EEPROM(1,DEVICE_POWERED); } void RST_PL_BEE() @@ -290,11 +311,6 @@ NVIC_SystemReset(); } -void SYS_PWR_RESET() // Have to be decided with EPS team. -{ - //sys_pwr_rst = 1; -} - void EPS_V_A_EN() // This is a reset function { V_A_EN = 0; @@ -443,4 +459,82 @@ tm_pointer->TM_string[44+i] = TIME_LATEST_RTC >> (3-i)*8; } +void FCTN_CDMS_SCP_M0a(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<24; i++) + rmcpy(tm_pointer->TM_string+4*i+4, scp_threshold_m0+i, 4); + for(uint8_t i=24; i<32; i++) + rmcpy(tm_pointer->TM_string+4*i+4, scp_threshold_m0+i+8, 4); + + for(uint8_t i=0; i<128; i++) + gPC.printf("\r %d\n",tm_pointer->TM_string[i]); + + +} + +void FCTN_CDMS_SCP_M0b(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<12; i++) + rmcpy(tm_pointer->TM_string+4*i+4, scp_threshold_m0+i+40, 4); + +} + +void FCTN_CDMS_SCP_M1a(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<32; i++) + rmcpy(tm_pointer->TM_string+4*i+4, scp_threshold_m1+i, 4); + +} + +void FCTN_CDMS_SCP_M1b(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<20; i++) + rmcpy(tm_pointer->TM_string+4*i+4, scp_threshold_m1+i+32, 4); + +} + +void FCTN_CDMS_SCP_SFP_SUM(Base_tm *tm_pointer) +{ + rmcpy(tm_pointer->TM_string+4*0+4, scp_threshold_m0_1+7, 4); + rmcpy(tm_pointer->TM_string+4*1+4, scp_threshold_m0_1+5, 4); + rmcpy(tm_pointer->TM_string+4*2+4, scp_threshold_m0_1+8, 4); + rmcpy(tm_pointer->TM_string+4*3+4, scp_threshold_m0_1+6, 4); + for(uint8_t i=0; i<5; i++) + rmcpy(tm_pointer->TM_string+4*(i+4)+4, scp_threshold_m0_1+i, 4); + rmcpy(tm_pointer->TM_string+4*9+4, scp_sfp_threshold_m0_2+0, 4); + rmcpy(tm_pointer->TM_string+4*10+4, scp_sfp_threshold_m0_2+1, 4); + rmcpy(tm_pointer->TM_string+4*11+4, scp_sfp_threshold_m0_2+2, 4); + +} + +void FCTN_CDMS_SFP_M0a(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<24; i++) + rmcpy(tm_pointer->TM_string+4*i+4, sfp_threshold_m0+i, 4); + for(uint8_t i=24; i<32; i++) + rmcpy(tm_pointer->TM_string+4*i+4, sfp_threshold_m0+i+8, 4); + +} + +void FCTN_CDMS_SFP_M0b(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<12; i++) + rmcpy(tm_pointer->TM_string+4*i+4, sfp_threshold_m0+i+40, 4); + +} + +void FCTN_CDMS_SFP_M1a(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<32; i++) + rmcpy(tm_pointer->TM_string+4*i+4, sfp_threshold_m1+i, 4); + +} + +void FCTN_CDMS_SFP_M1b(Base_tm *tm_pointer) +{ + for(uint8_t i=0; i<20; i++) + rmcpy(tm_pointer->TM_string+4*i+4, sfp_threshold_m1+i+32, 4); + +} + #endif \ No newline at end of file