![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
vr1.1
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_RTOS_v1_1 by
PL.cpp@16:7428828a5da2, 2015-07-17 (annotated)
- Committer:
- cholletisaik777
- Date:
- Fri Jul 17 06:35:40 2015 +0000
- Revision:
- 16:7428828a5da2
- Parent:
- 15:2c8629da6ec9
COM INTEGRATION
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cholletisaik777 | 0:d6e3d1e21484 | 1 | #include "mbed.h" |
cholletisaik777 | 8:607ae92fa6af | 2 | #include "PL.h" |
cholletisaik777 | 8:607ae92fa6af | 3 | #include "all_funcs.h" |
pradeepvk2208 | 9:7ff6d75cc09e | 4 | #include "Flags.h" |
cholletisaik777 | 16:7428828a5da2 | 5 | #include "pin_config.h" |
cholletisaik777 | 0:d6e3d1e21484 | 6 | |
cholletisaik777 | 15:2c8629da6ec9 | 7 | SPISlave pl_spi(PIN16, PIN17, PIN15, PIN14); // mosi, miso, sclk, ssel --> using SPI1 |
cholletisaik777 | 12:cb3ee1ac3638 | 8 | |
cholletisaik777 | 0:d6e3d1e21484 | 9 | Serial sr(USBTX,USBRX); |
cholletisaik777 | 0:d6e3d1e21484 | 10 | |
cholletisaik777 | 7:c270a9e37290 | 11 | void FCTN_PL_RCV_SC_DATA() |
cholletisaik777 | 0:d6e3d1e21484 | 12 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 13 | sr.printf("in FCTN_PL_RCV_SC_DATA\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 14 | uint8_t scienceRawPacket[payloadBins]; |
pradeepvk2208 | 9:7ff6d75cc09e | 15 | for(int i=0; i<payloadBins; i++) |
pradeepvk2208 | 9:7ff6d75cc09e | 16 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 17 | while(!pl_spi.receive()); // blocking statement --> waiting for data from Payload |
pradeepvk2208 | 9:7ff6d75cc09e | 18 | uint8_t v = pl_spi.read(); // Read byte from master |
pradeepvk2208 | 9:7ff6d75cc09e | 19 | scienceRawPacket[i] = v; |
pradeepvk2208 | 9:7ff6d75cc09e | 20 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 21 | // serial feedback |
pradeepvk2208 | 9:7ff6d75cc09e | 22 | sr.printf("Packet recieved\r\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 23 | for(int i=0; i<payloadBins; i++) |
pradeepvk2208 | 9:7ff6d75cc09e | 24 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 25 | sr.printf("%0x\t",scienceRawPacket[i]); |
pradeepvk2208 | 9:7ff6d75cc09e | 26 | scienceRawPacket[i] = 0; |
pradeepvk2208 | 9:7ff6d75cc09e | 27 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 28 | sr.printf("\r\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 29 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 30 | |
cholletisaik777 | 12:cb3ee1ac3638 | 31 | void FCTN_PL_SCIENCE() |
cholletisaik777 | 12:cb3ee1ac3638 | 32 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 33 | all_flags|=PL_SCIENCE_STATUS; |
cholletisaik777 | 12:cb3ee1ac3638 | 34 | FCTN_PL_RCV_SC_DATA(); |
cholletisaik777 | 12:cb3ee1ac3638 | 35 | if(all_flags&IS_FIRST_TIME_SC_DATA == 0) //What happens to TIME_ELAPSED_LAST_SRP on reset? Should it be stored in Flash? |
cholletisaik777 | 12:cb3ee1ac3638 | 36 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 37 | TIME_ELAPSED_LAST_SRP=SRP_INTER_VAL_COUNTER; |
cholletisaik777 | 12:cb3ee1ac3638 | 38 | SRP_INTER_VAL_COUNTER.reset(); |
cholletisaik777 | 12:cb3ee1ac3638 | 39 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 40 | else |
cholletisaik777 | 12:cb3ee1ac3638 | 41 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 42 | SRP_INTER_VAL_COUNTER.start(); |
cholletisaik777 | 12:cb3ee1ac3638 | 43 | all_flags&=(~IS_FIRST_TIME_SC_DATA); |
cholletisaik777 | 12:cb3ee1ac3638 | 44 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 45 | if(all_flags&IS_PL_FRAME_SIZE_CORRECT == 1) //How to identify FRAME_SIZE or size of data that is received via SPI? |
cholletisaik777 | 12:cb3ee1ac3638 | 46 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 47 | //FCTN_COM_COMP_SC_DATA(scienceRawPacket); |
cholletisaik777 | 12:cb3ee1ac3638 | 48 | //FCTN_WR_SD(const uint8_t *, uint64_t) //Store SD |
cholletisaik777 | 12:cb3ee1ac3638 | 49 | //FCTN_CDMS_WR_FLASH(); // |
cholletisaik777 | 12:cb3ee1ac3638 | 50 | all_flags|=PL_FRAME_SIZE_CORRECT; |
cholletisaik777 | 12:cb3ee1ac3638 | 51 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 52 | if(all_flags&IS_PL_FRAME_SIZE_CORRECT == 0) |
cholletisaik777 | 12:cb3ee1ac3638 | 53 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 54 | //FCTN_WR_SD(const uint8_t *, uint64_t) |
cholletisaik777 | 12:cb3ee1ac3638 | 55 | //FCTN_CDMS_WR_FLASH(); |
cholletisaik777 | 13:ba5dca9e18d8 | 56 | all_flags&=~(PL_FRAME_SIZE_CORRECT); |
cholletisaik777 | 12:cb3ee1ac3638 | 57 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 58 | if(TIME_ELAPSED_LAST_SRP>4) |
cholletisaik777 | 12:cb3ee1ac3638 | 59 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 60 | //FCTN_CDMS_WR_FLASH(); |
cholletisaik777 | 12:cb3ee1ac3638 | 61 | all_flags|= TIME_ELAPSED_LAST_SRP_INTERVAL_HIGH; |
cholletisaik777 | 12:cb3ee1ac3638 | 62 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 63 | if(TIME_ELAPSED_LAST_SRP<2) |
cholletisaik777 | 12:cb3ee1ac3638 | 64 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 65 | //FCTN_CDMS_WR_FLASH(); |
cholletisaik777 | 12:cb3ee1ac3638 | 66 | all_flags|= TIME_ELAPSED_LAST_SRP_INTERVAL_LOW; |
cholletisaik777 | 12:cb3ee1ac3638 | 67 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 68 | all_flags&=~(PL_SCIENCE_STATUS); |
cholletisaik777 | 12:cb3ee1ac3638 | 69 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 70 | |
pradeepvk2208 | 9:7ff6d75cc09e | 71 | void FCTN_PL_MAIN() |
pradeepvk2208 | 9:7ff6d75cc09e | 72 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 73 | all_flags|=PL_MAIN_STATUS; |
cholletisaik777 | 12:cb3ee1ac3638 | 74 | all_flags&=~(PL_LOW_POWER); |
cholletisaik777 | 12:cb3ee1ac3638 | 75 | all_flags = all_flags|((all_flags&PL_STATE)<<2); //pl_prev_state = pl_state; |
cholletisaik777 | 12:cb3ee1ac3638 | 76 | if(all_flags&IS_PL_SCHEDULE == 1) //is pl_schedule == 1 |
pradeepvk2208 | 9:7ff6d75cc09e | 77 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 78 | all_flags = (all_flags&(~PL_STATE))|pl_schedule_TC; |
pradeepvk2208 | 9:7ff6d75cc09e | 79 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 80 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 81 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 82 | if((all_flags&PL_PREV_STATE) == PL_SCIENCE) |
pradeepvk2208 | 9:7ff6d75cc09e | 83 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 84 | all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; |
pradeepvk2208 | 9:7ff6d75cc09e | 85 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 86 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 87 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 88 | all_flags = (all_flags&(~PL_STATE))|((all_flags&PL_PREV_STATE)>>2); //pl_state = pl_prev_state; |
pradeepvk2208 | 9:7ff6d75cc09e | 89 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 90 | } |
cholletisaik777 | 12:cb3ee1ac3638 | 91 | switch(all_flags&PL_STATE) |
pradeepvk2208 | 9:7ff6d75cc09e | 92 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 93 | case PL_OFF: |
cholletisaik777 | 0:d6e3d1e21484 | 94 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 95 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 96 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 97 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 98 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 99 | sr.printf("Power off SPEED\r\n"); |
cholletisaik777 | 12:cb3ee1ac3638 | 100 | all_flags = (all_flags&(~PL_STATUS))|PL_OFF; |
pradeepvk2208 | 9:7ff6d75cc09e | 101 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 12:cb3ee1ac3638 | 102 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 103 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 104 | case PL_STANDBY: |
pradeepvk2208 | 9:7ff6d75cc09e | 105 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 106 | if(power_level<0) |
pradeepvk2208 | 9:7ff6d75cc09e | 107 | { |
cholletisaik777 | 12:cb3ee1ac3638 | 108 | all_flags = all_flags|PL_LOW_POWER; |
cholletisaik777 | 12:cb3ee1ac3638 | 109 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 110 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 111 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 112 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 113 | sr.printf("Power off SPEED\r\n"); |
cholletisaik777 | 12:cb3ee1ac3638 | 114 | all_flags = (all_flags&(~PL_STATUS))|PL_OFF; |
pradeepvk2208 | 9:7ff6d75cc09e | 115 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 12:cb3ee1ac3638 | 116 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 117 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 118 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 119 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 120 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 121 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 122 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 123 | sr.printf("Power OFF SPEED PMTs\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 124 | if(all_flags&IS_I2C_ACK == 1) |
pradeepvk2208 | 9:7ff6d75cc09e | 125 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 126 | all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } |
pradeepvk2208 | 9:7ff6d75cc09e | 127 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 128 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 129 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 130 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 131 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 132 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 133 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 134 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 135 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 136 | sr.printf("Power on SPPED DL\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 137 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 138 | if(all_flags&IS_I2C_ACK == 1) |
pradeepvk2208 | 9:7ff6d75cc09e | 139 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 140 | all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; |
pradeepvk2208 | 9:7ff6d75cc09e | 141 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 142 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 143 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 144 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 145 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 146 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 147 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 148 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 149 | } |
cholletisaik777 | 0:d6e3d1e21484 | 150 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 151 | case PL_HIBERNATE: |
pradeepvk2208 | 9:7ff6d75cc09e | 152 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 153 | if(power_level<1) |
pradeepvk2208 | 9:7ff6d75cc09e | 154 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 155 | all_flags = all_flags|PL_LOW_POWER; |
pradeepvk2208 | 9:7ff6d75cc09e | 156 | if(power_level<0) |
pradeepvk2208 | 9:7ff6d75cc09e | 157 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 158 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 159 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 160 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 161 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 162 | sr.printf("Power off SPEED\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 163 | all_flags = (all_flags&(~PL_STATUS))|PL_OFF; |
pradeepvk2208 | 9:7ff6d75cc09e | 164 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 165 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 166 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 167 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 168 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 169 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 170 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 171 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 172 | sr.printf("Power OFF SPEED PMTs\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 173 | if(all_flags&IS_I2C_ACK == 1) |
pradeepvk2208 | 9:7ff6d75cc09e | 174 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 175 | all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } |
pradeepvk2208 | 9:7ff6d75cc09e | 176 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 177 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 178 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 179 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 180 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 181 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 182 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 183 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 184 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 185 | sr.printf("Power on SPPED DL\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 186 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 187 | if(all_flags&IS_I2C_ACK == 1) |
cholletisaik777 | 13:ba5dca9e18d8 | 188 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 189 | all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; |
pradeepvk2208 | 9:7ff6d75cc09e | 190 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 191 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 192 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 193 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 194 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 195 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 196 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 197 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 198 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 199 | } |
cholletisaik777 | 13:ba5dca9e18d8 | 200 | else if(power_level>1) |
pradeepvk2208 | 9:7ff6d75cc09e | 201 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 202 | if(all_flags&PL_PREV_STATE==PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 203 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 204 | sr.printf("Power on SPEED DL\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 205 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 206 | sr.printf("Power on Speed PMT with reduced Voltage\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 207 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 208 | if(all_flags&IS_I2C_ACK == 1) |
pradeepvk2208 | 9:7ff6d75cc09e | 209 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 210 | all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; |
pradeepvk2208 | 9:7ff6d75cc09e | 211 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 212 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 213 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 214 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 215 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 216 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 217 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 218 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 219 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 220 | case PL_SCIENCE: |
cholletisaik777 | 0:d6e3d1e21484 | 221 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 222 | if(power_level<2) |
pradeepvk2208 | 9:7ff6d75cc09e | 223 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 224 | if(power_level<1) |
pradeepvk2208 | 9:7ff6d75cc09e | 225 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 226 | all_flags = all_flags|PL_LOW_POWER; |
pradeepvk2208 | 9:7ff6d75cc09e | 227 | if(power_level<0) |
pradeepvk2208 | 9:7ff6d75cc09e | 228 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 229 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 230 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 231 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 232 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 233 | sr.printf("Power off SPEED\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 234 | all_flags = (all_flags&(~PL_STATUS))|PL_OFF; |
pradeepvk2208 | 9:7ff6d75cc09e | 235 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 236 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 237 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 238 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 239 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 240 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 241 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 242 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 243 | sr.printf("Power OFF SPEED PMTs\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 244 | if(all_flags&IS_I2C_ACK == 1) |
pradeepvk2208 | 9:7ff6d75cc09e | 245 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 246 | all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; } |
pradeepvk2208 | 9:7ff6d75cc09e | 247 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 248 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 249 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 250 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 251 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 252 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 253 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 254 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 255 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 256 | sr.printf("Power on SPPED DL\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 257 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 258 | if(all_flags&IS_I2C_ACK == 1) |
pradeepvk2208 | 9:7ff6d75cc09e | 259 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 260 | all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY; |
pradeepvk2208 | 9:7ff6d75cc09e | 261 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 262 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 263 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 264 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 265 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 266 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 267 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 268 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 269 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 270 | } |
cholletisaik777 | 13:ba5dca9e18d8 | 271 | else if(power_level>1) |
pradeepvk2208 | 9:7ff6d75cc09e | 272 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 273 | if(all_flags&PL_PREV_STATE==PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 274 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 275 | sr.printf("Power on SPEED DL\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 276 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 277 | sr.printf("Power on Speed PMT with reduced Voltage\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 278 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 279 | if(all_flags&IS_I2C_ACK == 1) |
cholletisaik777 | 13:ba5dca9e18d8 | 280 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 281 | all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; } |
cholletisaik777 | 13:ba5dca9e18d8 | 282 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 283 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 284 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
cholletisaik777 | 13:ba5dca9e18d8 | 285 | } |
cholletisaik777 | 13:ba5dca9e18d8 | 286 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 287 | all_flags = all_flags&(~PL_MAIN_STATUS); |
cholletisaik777 | 13:ba5dca9e18d8 | 288 | } |
cholletisaik777 | 13:ba5dca9e18d8 | 289 | } |
cholletisaik777 | 13:ba5dca9e18d8 | 290 | else if(power_level>2) |
cholletisaik777 | 13:ba5dca9e18d8 | 291 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 292 | if(all_flags&PL_PREV_STATE==PL_SCIENCE) |
cholletisaik777 | 13:ba5dca9e18d8 | 293 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 294 | all_flags = (all_flags&(~PL_STATUS))|PL_SCIENCE; |
cholletisaik777 | 13:ba5dca9e18d8 | 295 | all_flags = all_flags&(~PL_MAIN_STATUS); |
cholletisaik777 | 13:ba5dca9e18d8 | 296 | } |
cholletisaik777 | 13:ba5dca9e18d8 | 297 | else if(all_flags&PL_PREV_STATE==PL_HIBERNATE) |
cholletisaik777 | 13:ba5dca9e18d8 | 298 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 299 | sr.printf("Power on SPEED PMT with high voltage \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 300 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 301 | if(all_flags&IS_I2C_ACK == 1) |
cholletisaik777 | 13:ba5dca9e18d8 | 302 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 303 | sr.printf("Enable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 304 | all_flags = (all_flags&(~PL_STATUS))|PL_SCIENCE; |
cholletisaik777 | 13:ba5dca9e18d8 | 305 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 306 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 307 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 308 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 309 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 310 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 311 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 312 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 313 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 314 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 315 | |
pradeepvk2208 | 9:7ff6d75cc09e | 316 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 317 | if(all_flags&PL_PREV_STATE!=PL_OFF) |
pradeepvk2208 | 9:7ff6d75cc09e | 318 | { |
pradeepvk2208 | 9:7ff6d75cc09e | 319 | sr.printf("Power on SPEED DL\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 320 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 321 | sr.printf("Power on Speed PMT with reduced Voltage\r\n"); |
pradeepvk2208 | 9:7ff6d75cc09e | 322 | sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 323 | if(all_flags&IS_I2C_ACK == 1) |
pradeepvk2208 | 9:7ff6d75cc09e | 324 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 325 | all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE; |
pradeepvk2208 | 9:7ff6d75cc09e | 326 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 327 | else |
pradeepvk2208 | 9:7ff6d75cc09e | 328 | { |
cholletisaik777 | 13:ba5dca9e18d8 | 329 | all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C; |
pradeepvk2208 | 9:7ff6d75cc09e | 330 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 331 | sr.printf("Disable SRP_INTERVAL_COUNTER\r\n"); |
cholletisaik777 | 13:ba5dca9e18d8 | 332 | all_flags = all_flags&(~PL_MAIN_STATUS); |
pradeepvk2208 | 9:7ff6d75cc09e | 333 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 334 | } |
cholletisaik777 | 0:d6e3d1e21484 | 335 | } |
pradeepvk2208 | 9:7ff6d75cc09e | 336 | } |
cholletisaik777 | 0:d6e3d1e21484 | 337 | } |