![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
vr1.1
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_RTOS_v1_1 by
Diff: PL.cpp
- Revision:
- 13:ba5dca9e18d8
- Parent:
- 12:cb3ee1ac3638
- Child:
- 15:2c8629da6ec9
diff -r cb3ee1ac3638 -r ba5dca9e18d8 PL.cpp --- a/PL.cpp Mon Jul 06 10:31:29 2015 +0000 +++ b/PL.cpp Mon Jul 06 11:26:57 2015 +0000 @@ -52,7 +52,7 @@ { //FCTN_WR_SD(const uint8_t *, uint64_t) //FCTN_CDMS_WR_FLASH(); - PL_SCIENCE_FLAG &=~(PL_FRAME_SIZE_CORRECT); + all_flags&=~(PL_FRAME_SIZE_CORRECT); } if(TIME_ELAPSED_LAST_SRP>4) { @@ -74,13 +74,13 @@ all_flags = all_flags|((all_flags&PL_STATE)<<2); //pl_prev_state = pl_state; if(all_flags&IS_PL_SCHEDULE == 1) //is pl_schedule == 1 { - (all_flags&PL_STATE) = pl_schedule_TC; + all_flags = (all_flags&(~PL_STATE))|pl_schedule_TC; } else { if((all_flags&PL_PREV_STATE) == PL_SCIENCE) { - pl_state= PL_HIBERNATE; + all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; } else { @@ -116,35 +116,34 @@ } else { - if(pl_prev_state!=PL_OFF) + if(all_flags&PL_PREV_STATE!=PL_OFF) { sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); sr.printf("Power OFF SPEED PMTs\r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) { - pl_status=PL_STANDBY; - } + all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } else { sr.printf("Power on SPPED DL\r\n"); sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) { - pl_status=PL_STANDBY; + all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } } } @@ -152,195 +151,186 @@ { if(power_level<1) { - pl_main_flags|=PL_LOW_POWER; + all_flags = all_flags|PL_LOW_POWER; if(power_level<0) { - pl_main_flags|=PL_LOW_POWER; - if(pl_prev_state!=PL_OFF) + if(all_flags&PL_PREV_STATE!=PL_OFF) { sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); } sr.printf("Power off SPEED\r\n"); - pl_status=PL_OFF; + all_flags = (all_flags&(~PL_STATUS))|PL_OFF; sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } else { - if(pl_prev_state!=PL_OFF) + if(all_flags&PL_PREV_STATE!=PL_OFF) { sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); sr.printf("Power OFF SPEED PMTs\r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) { - pl_status=PL_STANDBY; - } + all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } else { sr.printf("Power on SPPED DL\r\n"); sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); - if(I2C_acknowledgement==1) { - pl_status=PL_STANDBY; + if(all_flags&IS_I2C_ACK == 1) + { + all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } } } - if(power_level>1) + else if(power_level>1) { - if(pl_prev_state==PL_OFF) + if(all_flags&PL_PREV_STATE==PL_OFF) { sr.printf("Power on SPEED DL\r\n"); } sr.printf("Power on Speed PMT with reduced Voltage\r\n"); sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) { - pl_status=PL_HIBERNATE; + all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } } - case PL_SCIENCE: { - if(power_level<2) { if(power_level<1) { - pl_main_flags|=PL_LOW_POWER; + all_flags = all_flags|PL_LOW_POWER; if(power_level<0) { - pl_main_flags|=PL_LOW_POWER; - if(pl_prev_state!=PL_OFF) + if(all_flags&PL_PREV_STATE!=PL_OFF) { sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); } sr.printf("Power off SPEED\r\n"); - pl_status=PL_OFF; + all_flags = (all_flags&(~PL_STATUS))|PL_OFF; sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } else { - if(pl_prev_state!=PL_OFF) + if(all_flags&PL_PREV_STATE!=PL_OFF) { sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); sr.printf("Power OFF SPEED PMTs\r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) { - pl_status=PL_STANDBY; - } + all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } else { sr.printf("Power on SPPED DL\r\n"); sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) { - pl_status=PL_STANDBY; + all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } } } - if(power_level>1) + else if(power_level>1) { - if(pl_prev_state==PL_OFF) + if(all_flags&PL_PREV_STATE==PL_OFF) { sr.printf("Power on SPEED DL\r\n"); } sr.printf("Power on Speed PMT with reduced Voltage\r\n"); sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) + { + all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; } + else { - pl_status=PL_HIBERNATE; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; + } + sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); + all_flags = all_flags&(~PL_MAIN_STATUS); + } + } + else if(power_level>2) + { + if(all_flags&PL_PREV_STATE==PL_SCIENCE) + { + all_flags = (all_flags&(~PL_STATUS))|PL_SCIENCE; + all_flags = all_flags&(~PL_MAIN_STATUS); + } + else if(all_flags&PL_PREV_STATE==PL_HIBERNATE) + { + sr.printf("Power on SPEED PMT with high voltage \r\n"); + sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); + if(all_flags&IS_I2C_ACK == 1) + { + sr.printf("Enable SRP_INTERVAL_COUNTER\r\n"); + all_flags = (all_flags&(~PL_STATUS))|PL_SCIENCE; + all_flags = all_flags&(~PL_MAIN_STATUS); } else { - pl_status=PL_ERR_I2C; - } - sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); - } - } - if(power_level>2) - { - if(pl_prev_state==PL_SCIENCE) - { - pl_status=PL_SCIENCE; - pl_main_flags&=~(PL_MAIN_STATUS); - } - else if(pl_prev_state==PL_HIBERNATE) - { - sr.printf("Power on SPEED PMT with high voltage \r\n"); - sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); - if(I2C_acknowledgement==1) - { - sr.printf("Enable SRP_INTERVAL_COUNTER\r\n"); - pl_status=PL_SCIENCE; - pl_main_flags&=~(PL_MAIN_STATUS); - } - else - { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } } else { - if(pl_prev_state==PL_OFF) + if(all_flags&PL_PREV_STATE!=PL_OFF) { sr.printf("Power on SPEED DL\r\n"); } sr.printf("Power on Speed PMT with reduced Voltage\r\n"); sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); - if(I2C_acknowledgement==1) + if(all_flags&IS_I2C_ACK == 1) { - pl_status=PL_HIBERNATE; + all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; } else { - pl_status=PL_ERR_I2C; + all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; } sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); - pl_main_flags&=~(PL_MAIN_STATUS); + all_flags = all_flags&(~PL_MAIN_STATUS); } } - - } - } } \ No newline at end of file