working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Committer:
samp1234
Date:
Sun Apr 03 15:35:53 2022 +0000
Revision:
357:f3d48d62e00e
Parent:
356:197c93dc2012
First commit test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ee12b079 278:1d837d6dfb6e 1 ///639+................................++.300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002025555.
shreeshas95 0:f016e9e8d48b 2 // **************DEFINITIONS*********************
aniruddhv 69:20f09a0c3fd2 3
chaithanyarss 303:b49b486a7107 4 #define dma 1
samp1234 356:197c93dc2012 5 Base_tm *ack_head = NULL;
shreeshas95 0:f016e9e8d48b 6 // COM_RX
shreeshas95 5:ab276a17ca07 7 #define RX_TIMEOUT_LIMIT 0.5
ee12b079 268:ded5306a1fd1 8 #define COM_RX_UART_TX PTE20 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_TX USBTX
ee12b079 268:ded5306a1fd1 9 #define COM_RX_UART_RX PTE21 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_RX USBRX
ee12b079 81:1a39e9e14771 10
ee12b079 268:ded5306a1fd1 11 //#define COM_RX_UART_TX USBTX
ee12b079 268:ded5306a1fd1 12 //#define COM_RX_UART_RX USBRX
aniruddhv 56:a88e16f6c18e 13
shreeshas95 0:f016e9e8d48b 14 // COMMON SPI
shreeshas95 0:f016e9e8d48b 15 #define SPI_MOSI PTE1
ee12b079 185:3b3cd96a7811 16 #define SPI_MISO PTE3
shreeshas95 0:f016e9e8d48b 17 #define SPI_CLK PTE2
shreeshas95 1:a0055b3280c8 18 #define SPI_CS_ADF PTA15
ee12b079 114:9fb55057b13f 19 #define SPI_CS_SDC PIN20
samp1234 357:f3d48d62e00e 20 #define SPI_CS_RTC PIN26 // actual changed Mar 7 2018
samp1234 357:f3d48d62e00e 21 // #define SPI_CS_RTC PIN60 // sbc with jumper v1.0
shreeshas95 2:2caf2a9a13aa 22
shreeshas95 4:104dd82c99b8 23 // COM_TX
shreeshas95 4:104dd82c99b8 24 #define COM_TX_CONFIG_LIMIT 3
aniruddhv 52:0bd68655c651 25 #define COM_TX_TICKER_LIMIT 32
shreeshas95 4:104dd82c99b8 26
ee12b079 209:63e9c8f8b5d2 27 // ADF INTERRUPT
shreeshas95 2:2caf2a9a13aa 28 #define ADF_IRQ PTA14
ee12b079 161:a63672bf4423 29
ee12b079 162:48fda0b8d573 30 //I2C - Payload to CDMS (need to change while using CDMS hardware);
ee12b079 209:63e9c8f8b5d2 31 I2C master(PIN32,PIN31);
samp1234 354:eb6c863756a8 32 DigitalIn PL_I2C_Intr(PTC13); //PIN89
samp1234 354:eb6c863756a8 33 DigitalOut PL_I2C_GPIO(PTC1); //PIN71
ee12b079 209:63e9c8f8b5d2 34
ee12b079 162:48fda0b8d573 35 //I2C - CDMS to BAE
samp1234 352:022c513aee03 36 // DigitalOut CDMS_I2C_GPIO(PIN67);//PTB21 from bae to cdms
samp1234 352:022c513aee03 37 // DigitalIn BAE_I2C_GPIO(PIN39);//PTA5 from cdms to bae
aniruddhv 264:f7d8f9f361e3 38
samp1234 354:eb6c863756a8 39 #define SBC 1
aniruddhv 264:f7d8f9f361e3 40
samp1234 354:eb6c863756a8 41 // #if SBC
samp1234 357:f3d48d62e00e 42 // DigitalOut CDMS_I2C_GPIO(PIN67,1);
samp1234 357:f3d48d62e00e 43 // DigitalIn BAE_I2C_GPIO(PIN1);
samp1234 356:197c93dc2012 44 uint32_t pdir_ss1;
samp1234 356:197c93dc2012 45 uint8_t i2c_count_cdms_bae;
samp1234 354:eb6c863756a8 46 // #endif
aniruddhv 264:f7d8f9f361e3 47
samp1234 352:022c513aee03 48 // #if !SBC
samp1234 357:f3d48d62e00e 49 DigitalIn BAE_I2C_GPIO(PIN67);
samp1234 357:f3d48d62e00e 50 DigitalOut CDMS_I2C_GPIO(PIN39,0);
samp1234 354:eb6c863756a8 51 // #endif
ee12b079 162:48fda0b8d573 52
shreeshas95 0:f016e9e8d48b 53 // TC LIST
shreeshas95 2:2caf2a9a13aa 54 #define TCL_STATE_INCOMPLETE 0x00
aniruddhv 262:752c8689944a 55 #define TCL_STATE_ABORTED 0x01
aniruddhv 262:752c8689944a 56 #define TCL_STATE_EXECUTING 0x02
aniruddhv 262:752c8689944a 57 #define TCL_STATE_COMPLETED 0x03
shreeshas95 0:f016e9e8d48b 58
shreeshas95 0:f016e9e8d48b 59 // LIST OF FLAGS
samp1234 356:197c93dc2012 60 #define UART_INT_FLAG 0x0001//
shreeshas95 2:2caf2a9a13aa 61 #define NEW_TC_RECEIVED 0x0002
samp1234 356:197c93dc2012 62 #define COM_SESSION_FLAG 0x0004//
shreeshas95 2:2caf2a9a13aa 63 #define COM_RX_FLAG 0x0008
shreeshas95 2:2caf2a9a13aa 64 #define COM_MNG_TMTC_RUNNING_FLAG 0x0010
samp1234 356:197c93dc2012 65 #define COM_SESSION_VALIDITY 0x0020//
shreeshas95 2:2caf2a9a13aa 66 #define ALL_CRC_PASS_FLAG 0x0040
shreeshas95 2:2caf2a9a13aa 67 #define COM_PA_HOT_FLAG 0x0080
aniruddhv 262:752c8689944a 68 #define COM_PA_OC_FLAG 0x8000
shreeshas95 2:2caf2a9a13aa 69 #define COM_TX_FLAG 0x0100
shreeshas95 6:79d422d1ed42 70 #define COM_SESSION_TIMEOUT_FLAG 0x0200
ee12b079 209:63e9c8f8b5d2 71 #define COM_AUTO_POWER_OFF_BAE_FLAG 0x0400
samp1234 356:197c93dc2012 72 #define BAE_SW_EN_FLAG 0x0800//
ee12b079 209:63e9c8f8b5d2 73 #define RF_SW_STATUS_FLAG 0x1000
ee12b079 209:63e9c8f8b5d2 74 #define COM_INIT_STATUS_FLAG 0x2000
samp1234 356:197c93dc2012 75 #define COM_TX_STATUS_FLAG 0x4000//
ee12b079 209:63e9c8f8b5d2 76
ee12b079 209:63e9c8f8b5d2 77 //RF relay STATUS
ee12b079 209:63e9c8f8b5d2 78 #define RF_COM_TX 0
ee12b079 209:63e9c8f8b5d2 79 #define RF_BCN 1
shreeshas95 0:f016e9e8d48b 80
shreeshas95 0:f016e9e8d48b 81 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 82 #define COM_MNG_TMTC_SIGNAL_UART_INT 0x01
shreeshas95 0:f016e9e8d48b 83 #define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02
shreeshas95 0:f016e9e8d48b 84 #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03
aniruddhv 262:752c8689944a 85 #define cdms_reset_timeout 345600000
ee12b079 245:da9d1bd999da 86
shreeshas95 0:f016e9e8d48b 87 // COM_MNG_TMTC
shreeshas95 2:2caf2a9a13aa 88 #define COM_PA_COOLING_TIME_LIMIT 20
aniruddhv 262:752c8689944a 89 #define COM_MAX_TC_LIMIT 256
shreeshas95 4:104dd82c99b8 90 #define TM_ACK_CODE_INDEX 2
shreeshas95 5:ab276a17ca07 91 #define CRC_FAIL_NACK_CODE 0x01
shreeshas95 2:2caf2a9a13aa 92
shreeshas95 2:2caf2a9a13aa 93 // call sign
shreeshas95 2:2caf2a9a13aa 94 #define PSC_CALLSIGN 0x00
shreeshas95 2:2caf2a9a13aa 95 #define APID_CALLSIGN 0x00
shreeshas95 2:2caf2a9a13aa 96
shreeshas95 2:2caf2a9a13aa 97 // max value of telecommands in a tcl
shreeshas95 2:2caf2a9a13aa 98 #define TCL_OVERFLOW_CONSTANT 256
shreeshas95 4:104dd82c99b8 99 #define TM_OVERFLOW_CONSTANT 256
aniruddhv 262:752c8689944a 100 #define BYTE_OVERFLOW_CONSTANT 35000
shreeshas95 2:2caf2a9a13aa 101
shreeshas95 0:f016e9e8d48b 102 // starting value of packet sequence count at each pass
shreeshas95 0:f016e9e8d48b 103 #define PSC_START_VALUE 1
shreeshas95 0:f016e9e8d48b 104
shreeshas95 0:f016e9e8d48b 105 // APID list
aniruddhv 52:0bd68655c651 106 #define APID_COM 0
shreeshas95 0:f016e9e8d48b 107 #define APID_BAE 1
shreeshas95 0:f016e9e8d48b 108 #define APID_CDMS 2
shreeshas95 0:f016e9e8d48b 109 #define APID_SPEED 3
shreeshas95 0:f016e9e8d48b 110
aniruddhv 52:0bd68655c651 111 //SERVICE
aniruddhv 52:0bd68655c651 112 #define SERVICE_OBOSC 0xB
aniruddhv 52:0bd68655c651 113 #define SERVICE_OBSRS 0xF
aniruddhv 52:0bd68655c651 114
shreeshas95 0:f016e9e8d48b 115 // HIGH PRIORITY TC - priority list
shreeshas95 0:f016e9e8d48b 116 // not correct values here
shreeshas95 0:f016e9e8d48b 117 #define HPTC1 5
shreeshas95 0:f016e9e8d48b 118 #define HPTC2 6
shreeshas95 0:f016e9e8d48b 119 // Add more entries above
shreeshas95 0:f016e9e8d48b 120
shreeshas95 0:f016e9e8d48b 121 // TMID list
shreeshas95 0:f016e9e8d48b 122 #define TMID_ACK_L1 0xA
shreeshas95 4:104dd82c99b8 123 #define TMID_ACK_L234 0xB
shreeshas95 4:104dd82c99b8 124 #define TMID_TCL 0x7
shreeshas95 4:104dd82c99b8 125 #define TMID_CALL_SIGN 0xE
shreeshas95 0:f016e9e8d48b 126
shreeshas95 0:f016e9e8d48b 127 // OBOSC SERVICE SUBTYPE
shreeshas95 4:104dd82c99b8 128 #define OBOSC_TCL_MAX_SHORT_SIZE 11
shreeshas95 4:104dd82c99b8 129 #define OBOSC_LONG_TC_FIRST_HALF_SIZE 67
shreeshas95 4:104dd82c99b8 130 #define OBOSC_LONG_TC_SECOND_HALF_SIZE 68
shreeshas95 4:104dd82c99b8 131 #define OBOSC_TCL_TAG_LONG_FIRST_HALF 0x10
shreeshas95 4:104dd82c99b8 132 #define OBOSC_TCL_TAG_LONG_SECOND_HALF 0x11
shreeshas95 4:104dd82c99b8 133
shreeshas95 0:f016e9e8d48b 134 #define OBOSC_SUB_DISABLE 0x01
shreeshas95 0:f016e9e8d48b 135 #define OBOSC_SUB_RETRY 0x05
shreeshas95 4:104dd82c99b8 136 #define OBOSC_SUB_REP_TCLD 0x06
shreeshas95 0:f016e9e8d48b 137 #define OBOSC_SUB_REP_LE 0x0F
shreeshas95 0:f016e9e8d48b 138 #define OBOSC_SUB_RESET 0x07
shreeshas95 0:f016e9e8d48b 139
shreeshas95 101:bece931236a2 140 // PAYLOAD or SCIENCE
samp1234 357:f3d48d62e00e 141 #define PAYLOAD_BUFFER_LENGTH 3363 // 6723
ee12b079 113:b8991d9e3b6c 142 #define PAY_SPI_MOSI PTE18
ee12b079 113:b8991d9e3b6c 143 #define PAY_SPI_MISO PTE19
ee12b079 113:b8991d9e3b6c 144 #define PAY_SPI_CLK PTE17
ee12b079 113:b8991d9e3b6c 145 #define PAY_SPI_CS PTE16
ee12b079 245:da9d1bd999da 146 #define SCIENCE_SIGNAL 0x04
ee12b079 209:63e9c8f8b5d2 147
ee12b079 209:63e9c8f8b5d2 148 //BEACON
ee12b079 209:63e9c8f8b5d2 149 #define BCN_APID_SOURCE 0x41
ee12b079 209:63e9c8f8b5d2 150 #define BCN_SERVICE 0x81
shreeshas95 101:bece931236a2 151
ee12b079 209:63e9c8f8b5d2 152 //BAE
ee12b079 209:63e9c8f8b5d2 153 #define BAE_APID_SOURCE 0x81
ee12b079 209:63e9c8f8b5d2 154 #define BAE_SERVICE 0x81
ee12b079 209:63e9c8f8b5d2 155 #define BAE_POWER_ON_PID 0x13
ee12b079 209:63e9c8f8b5d2 156 #define BAE_POWER_OFF_PID 0x23
ee12b079 209:63e9c8f8b5d2 157 #define BAE_RESET_PID 0x33
ee12b079 209:63e9c8f8b5d2 158
ee12b079 209:63e9c8f8b5d2 159 //RF RELAY
samp1234 357:f3d48d62e00e 160 #define RF_RELAY_CNTRL_TX PTA12 //chenged Mar 07 2018
samp1234 357:f3d48d62e00e 161 #define RF_RELAY_CNTRL_BCN PTA7
samp1234 357:f3d48d62e00e 162 //#define RF_RELAY_CNTRL_TX PTB7
samp1234 357:f3d48d62e00e 163 //#define RF_RELAY_CNTRL_BCN PTB17
chaithanyarss 224:3ac1f91e0ebc 164
chaithanyarss 224:3ac1f91e0ebc 165 //CDMS HK
ee12b079 246:565458eefd94 166 #define HK_SIGNAL 0x05
chaithanyarss 224:3ac1f91e0ebc 167 #define COMRX_ALIVE 0x01
chaithanyarss 224:3ac1f91e0ebc 168 #define COMRX_DEAD 0x00
chaithanyarss 224:3ac1f91e0ebc 169 #define DEVICE_ENABLED 0x00
chaithanyarss 224:3ac1f91e0ebc 170 #define DEVICE_POWERED 0x01
chaithanyarss 224:3ac1f91e0ebc 171 #define DEVICE_OC_FAULT 0x02
chaithanyarss 224:3ac1f91e0ebc 172 #define DEVICE_DISABLED 0x03
chaithanyarss 224:3ac1f91e0ebc 173
samp1234 357:f3d48d62e00e 174 //CDMS HK SYS_RESET
samp1234 357:f3d48d62e00e 175 #define T_WAIT_RST 0x00
samp1234 357:f3d48d62e00e 176 #define T_OFF_RST 0x0A
samp1234 357:f3d48d62e00e 177 #define T_RST 0x02
samp1234 357:f3d48d62e00e 178 #define T_RETRY_RST 0x1E
samp1234 357:f3d48d62e00e 179
samp1234 357:f3d48d62e00e 180 //CDMS TIME_INIT
samp1234 357:f3d48d62e00e 181 #define T_INI 0x02
samp1234 357:f3d48d62e00e 182
ee12b079 209:63e9c8f8b5d2 183
shreeshas95 3:6c81fc8834e2 184
shreeshas95 0:f016e9e8d48b 185 // ****************GLOBAL VARIABLES******************
chaithanyarss 251:c766afa330a3 186
chaithanyarss 251:c766afa330a3 187 //Global
chaithanyarss 251:c766afa330a3 188 Mutex gMutex;
chaithanyarss 251:c766afa330a3 189
chaithanyarss 251:c766afa330a3 190
shreeshas95 0:f016e9e8d48b 191 // DEBUG
shreeshas95 0:f016e9e8d48b 192 Serial gPC( USBTX, USBRX );
shreeshas95 4:104dd82c99b8 193 DigitalOut gLEDR(LED_RED);
shreeshas95 4:104dd82c99b8 194 DigitalOut gLEDG(LED_GREEN);
shreeshas95 0:f016e9e8d48b 195
samp1234 352:022c513aee03 196
shreeshas95 0:f016e9e8d48b 197 // COM_RX
shreeshas95 0:f016e9e8d48b 198 RawSerial RX1M( COM_RX_UART_TX, COM_RX_UART_RX );
shreeshas95 0:f016e9e8d48b 199 COM_RX_DATA_NODE *gRX_HEAD_DATA_NODE = NULL;
shreeshas95 0:f016e9e8d48b 200 COM_RX_DATA_NODE *gRX_CURRENT_DATA_NODE = NULL;
shreeshas95 2:2caf2a9a13aa 201 // uint8_t *gRX_CURRENT_PTR = NULL;
shreeshas95 0:f016e9e8d48b 202 uint32_t gRX_COUNT = 0;
aniruddhv 262:752c8689944a 203 uint16_t gTOTAL_RAW_BYTES = 0;
shreeshas95 0:f016e9e8d48b 204 uint16_t gTOTAL_INCORRECT_SIZE_TC = 0x00;
shreeshas95 0:f016e9e8d48b 205 uint16_t gTOTAL_CRC_FAIL_TC = 0x00;
shreeshas95 2:2caf2a9a13aa 206 uint16_t gTOTAL_REPEATED_TC = 0x00;
shreeshas95 0:f016e9e8d48b 207
shreeshas95 0:f016e9e8d48b 208 // COMMON SPI
shreeshas95 0:f016e9e8d48b 209 SPI spi( SPI_MOSI, SPI_MISO, SPI_CLK );
shreeshas95 1:a0055b3280c8 210 DigitalOut gCS_ADF(SPI_CS_ADF);
ee12b079 86:a26f5f22631d 211 DigitalOut cs_sd(SPI_CS_SDC);
shreeshas95 2:2caf2a9a13aa 212 DigitalOut gCS_RTC(SPI_CS_RTC);
shreeshas95 0:f016e9e8d48b 213 Mutex SPI_mutex;
shreeshas95 0:f016e9e8d48b 214
ee12b079 209:63e9c8f8b5d2 215 //I2C
ee12b079 209:63e9c8f8b5d2 216 Mutex BAE_I2C_mutex;
ee12b079 209:63e9c8f8b5d2 217
ee12b079 209:63e9c8f8b5d2 218 //RF Relay
ee12b079 209:63e9c8f8b5d2 219 DigitalOut RF_SW_CNTRL_BCN(RF_RELAY_CNTRL_BCN);
ee12b079 209:63e9c8f8b5d2 220 DigitalOut RF_SW_CNTRL_TX(RF_RELAY_CNTRL_TX);
ee12b079 209:63e9c8f8b5d2 221
ee12b079 209:63e9c8f8b5d2 222 //COM_RX
ee12b079 338:d63eb331a67d 223 DigitalOut COM_RX_CNTRL(PIN55,1);//changed!! earlier version had PIN72
samp1234 356:197c93dc2012 224 DigitalOut COM_TX_CNTRL(PIN56,0);
samp1234 311:af5ab655ba00 225 //DigitalIn COM_TX_OC_FAULT(PIN69);
samp1234 311:af5ab655ba00 226 DigitalIn COM_TX_OC_FAULT(PIN58);
ee12b079 209:63e9c8f8b5d2 227
shreeshas95 0:f016e9e8d48b 228 // TC LIST
shreeshas95 0:f016e9e8d48b 229 Base_tc* gHEAD_NODE_TCL = NULL;
shreeshas95 0:f016e9e8d48b 230 Base_tc* gLAST_NODE_TCL = NULL;
shreeshas95 2:2caf2a9a13aa 231 uint8_t gMASTER_STATE = TCL_STATE_INCOMPLETE;
shreeshas95 2:2caf2a9a13aa 232 uint16_t gFLAGS = 0x0000;
shreeshas95 0:f016e9e8d48b 233
shreeshas95 0:f016e9e8d48b 234 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 235 Thread* gCOM_MNG_TMTC_THREAD = NULL;
shreeshas95 0:f016e9e8d48b 236 Timeout gRX_TIMEOUT;
shreeshas95 0:f016e9e8d48b 237 Timeout gSESSION_TIMEOUT;
aniruddhv 262:752c8689944a 238 Timeout gCOM_RX_DISABLE;
shreeshas95 0:f016e9e8d48b 239
shreeshas95 0:f016e9e8d48b 240 // COM_MNG_TMTC
aniruddhv 262:752c8689944a 241 RtosTimer *sys_reset_cdms_timer;
ee12b079 209:63e9c8f8b5d2 242
shreeshas95 2:2caf2a9a13aa 243 // PA cooling timeout
shreeshas95 4:104dd82c99b8 244 Timeout gCOM_PA_COOLING_TIMEOUT;
shreeshas95 2:2caf2a9a13aa 245
shreeshas95 2:2caf2a9a13aa 246 // GS code for verification
aniruddhv 37:c9a739750806 247 const uint8_t gGSCODE[] = {0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
shreeshas95 2:2caf2a9a13aa 248
shreeshas95 0:f016e9e8d48b 249 uint8_t gTOTAL_VALID_TC = 0x00;
shreeshas95 0:f016e9e8d48b 250 // USE LAST_L1_ACK FOR GENERATING REPORT
shreeshas95 4:104dd82c99b8 251 uint8_t gLAST_TM[TM_LONG_SIZE];
shreeshas95 4:104dd82c99b8 252 uint8_t gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;
shreeshas95 3:6c81fc8834e2 253
shreeshas95 101:bece931236a2 254 // PAYLOAD OR SCIENCE_THREAD
shreeshas95 3:6c81fc8834e2 255 Thread* gSCIENCE_THREAD = NULL;
ee12b079 295:699801854b71 256 uint8_t gPAYLOAD_BUFFER[PAYLOAD_BUFFER_LENGTH] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,1,44,1,44,1,44,1,44,1,44,1,188,2,188,2,188,2,188,2,88,2,88,2,88,2,88,2,100,0,100,0,200,0,200,0,244,1,244,1,88,2,88,2,208,2,208,2,246,0,246,0,10,0,250,0,250,0,250,0,120,0,0,0,172,13,0,0,184,11,0,0,160,15,0,0};
samp1234 357:f3d48d62e00e 257 //uint8_t gPAYLOAD_BUFFER[PAYLOAD_BUFFER_LENGTH] = {0};
chaithanyarss 251:c766afa330a3 258 RtosTimer *PL_wo_dma;
ee12b079 209:63e9c8f8b5d2 259
shreeshas95 4:104dd82c99b8 260 // CALL SIGN TM
shreeshas95 103:b55559925dc1 261 const uint8_t gCALL_SIGN_STRING[TM_SHORT_SIZE] = {0xE0, 0x00, 0x00, 0x00, 0x56, 0x55, 0x32, 0x4E, 0x43, 0x46, 0x00, 0xAC, 0x11};
shreeshas95 103:b55559925dc1 262
ee12b079 245:da9d1bd999da 263 //HK Thread
ee12b079 245:da9d1bd999da 264 Thread* gHK_THREAD = NULL;
ee12b079 245:da9d1bd999da 265 RtosTimer *HK_counter;
samp1234 357:f3d48d62e00e 266 /*
samp1234 357:f3d48d62e00e 267 Startup_timer
samp1234 357:f3d48d62e00e 268 Thread* gST_UP = NULL;
samp1234 357:f3d48d62e00e 269 RtosTimer *St_upTimer
samp1234 357:f3d48d62e00e 270 */
shreeshas95 103:b55559925dc1 271 // CDMS HK
ee12b079 209:63e9c8f8b5d2 272 uint8_t CDMS_STANDBY;
ee12b079 209:63e9c8f8b5d2 273 uint8_t CDMS_HEALTH_DATA[128];
samp1234 356:197c93dc2012 274 uint8_t CDMS_RAM[84] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ee12b079 209:63e9c8f8b5d2 275 uint16_t GPIO_STATUS;
samp1234 356:197c93dc2012 276 uint16_t GPIO_FAULTS;
ee12b079 209:63e9c8f8b5d2 277 uint8_t CDMS_HK_MAIN_STATUS;
ee12b079 209:63e9c8f8b5d2 278 uint8_t COMRX_STATUS;
ee12b079 289:9bd62b69874c 279 uint8_t RTC_FAULTCOUNT = 0;
ee12b079 289:9bd62b69874c 280 uint16_t SD_FAULTCOUNT = 0;
ee12b079 209:63e9c8f8b5d2 281 uint8_t SD_STATUS;
ee12b079 289:9bd62b69874c 282 uint8_t BAE_FAULTCOUNT = 0;
ee12b079 209:63e9c8f8b5d2 283 uint8_t BAE_STATUS;
ee12b079 209:63e9c8f8b5d2 284 uint8_t PL_STATUS;
ee12b079 289:9bd62b69874c 285 uint16_t PL_FAULTCOUNT = 0;
ee12b079 209:63e9c8f8b5d2 286 bool BAE_HK_I2C;
ee12b079 209:63e9c8f8b5d2 287 uint8_t RTC_STATUS;
chaithanyarss 333:cddef120cae3 288 float RSSI_VOLTAGE;
samp1234 354:eb6c863756a8 289 float RSSI_MAX;
ee12b079 318:978d72f191f9 290 uint8_t COM_ADF_TMP = 0;
ee12b079 318:978d72f191f9 291 uint8_t COM_PA_IC_TMP = 0;
samp1234 352:022c513aee03 292 uint8_t BAE_HK_SD_DATA_READY = 0;
samp1234 352:022c513aee03 293 uint8_t CDMS_HK_SD_DATA_READY = 0;
ee12b079 209:63e9c8f8b5d2 294
shreeshas95 103:b55559925dc1 295 CDMS_HK_actual actual_data;
shreeshas95 103:b55559925dc1 296 CDMS_HK_quant quant_data;
shreeshas95 103:b55559925dc1 297 CDMS_HK_min_max min_max_data;
chaithanyarss 333:cddef120cae3 298 uint8_t MAX_COM_ADF_TMP;
chaithanyarss 333:cddef120cae3 299 uint8_t MIN_COM_ADF_TMP;
chaithanyarss 333:cddef120cae3 300 float MAX_RSSI_VOLTAGE;
chaithanyarss 333:cddef120cae3 301 float MIN_RSSI_VOLTAGE;
ee12b079 194:ab528911780d 302 bool firstCount=true;
ee12b079 194:ab528911780d 303
ee12b079 209:63e9c8f8b5d2 304 //GPIO PINS
ee12b079 209:63e9c8f8b5d2 305 DigitalIn V_A_PGOOD (PIN88);
ee12b079 209:63e9c8f8b5d2 306 DigitalIn V_B_PGOOD_1 (PIN6);
ee12b079 209:63e9c8f8b5d2 307 DigitalIn V_B_PGOOD_2 (PIN7);
ee12b079 338:d63eb331a67d 308 AnalogIn V_C_PGOOD (PIN54);
ee12b079 209:63e9c8f8b5d2 309 DigitalIn COMRX_OC_FAULT (PIN68);
chaithanyarss 290:3159ff1081a2 310 //DigitalIn COMTX_OC_FAULT (PIN69);
ee12b079 209:63e9c8f8b5d2 311 DigitalIn BAE_OC_FAULT (PIN92);
samp1234 353:e1803e801e20 312 DigitalOut PL_GPIO_1_STATUS (PIN71); // PYLD EPS CNTRL Signal1 / PYLD_EPS_CNTRL_SIG1
samp1234 356:197c93dc2012 313 DigitalOut PL_GPIO_2_STATUS (PIN81,0);//PYLD EPS CNTRL 2 / PYLD_EPS_CNTRL_2
samp1234 353:e1803e801e20 314 DigitalOut PL_GPIO_3_STATUS (PIN80,1);// PYLD EPS CNTRL 3 / PYLD_EPS_CNTRL_3
chaithanyarss 224:3ac1f91e0ebc 315 DigitalIn PL_BEE_SW_OC_FAULT (PIN91);
chaithanyarss 224:3ac1f91e0ebc 316 DigitalIn PL_EPS_LATCH_SW_OC_FAULT (PIN5);
ee12b079 289:9bd62b69874c 317 //DigitalOut EPS_V_C_EN_STATUS (PIN72,1);//COMM RX PWR CNTRL
ee12b079 289:9bd62b69874c 318 //DigitalOut EPS_V_D_EN_STATUS (PIN56,1);//3V6_EN
ee12b079 209:63e9c8f8b5d2 319
ee12b079 209:63e9c8f8b5d2 320
ee12b079 209:63e9c8f8b5d2 321 DigitalIn SD_OC_FAULT (PIN90);
ee12b079 278:1d837d6dfb6e 322 DigitalOut SD_SW_EN_DS (PIN97,1);//SD CARD SW EN/DIS or SD_CARD_SW_EN_DIS
ee12b079 272:5be8e2449dc3 323 DigitalOut BAE_SW_EN_DS (PIN47,1);//BAE_SW_EN_DIS
ee12b079 289:9bd62b69874c 324 //DigitalOut TRXY_EN (PIN84);//TRXY EN
ee12b079 289:9bd62b69874c 325 //DigitalOut TRZ_EN (PIN88);//TRZ EN
ee12b079 289:9bd62b69874c 326 DigitalOut V_A_EN (PIN99,1);//TRZ FLT (no INTR capability)
samp1234 357:f3d48d62e00e 327 DigitalInOut sys_pwr_rst (PIN46, PIN_INPUT, PullNone, 0);//PTA16
ee12b079 245:da9d1bd999da 328
ee12b079 272:5be8e2449dc3 329 DigitalOut PYLD_DFF (PIN73);//PYLD_SW_PWR_EN_DIS
ee12b079 272:5be8e2449dc3 330 DigitalOut PYLD_DFF_CLK (PIN65);//PL_3V3_EN_CLK
ee12b079 272:5be8e2449dc3 331 DigitalOut PYLD_EPS_DFF_PWR (PIN64);//TPS_SW_PL_LAT_ENA_DIS
ee12b079 272:5be8e2449dc3 332 DigitalOut PYLD_EPS_DFF_PWR_CLK (PIN40);//PYLD_EPS_LATCH_CLK
ee12b079 245:da9d1bd999da 333
ee12b079 272:5be8e2449dc3 334 DigitalOut RESET_TO_BAE(PIN93,1);//RESET_BAE_FROM_CDMS
ee12b079 278:1d837d6dfb6e 335 DigitalOut RESET_TO_PYLD(PIN21,1);//RESET_PYLD
ee12b079 209:63e9c8f8b5d2 336
spacelab 308:7c3872365d58 337 DigitalOut DMA_LED1(PIN61,0);
spacelab 309:6ed5535ac465 338 DigitalOut SCI_LED1(PIN62,0);
samp1234 352:022c513aee03 339 DigitalOut WDTrigger(PIN33,0);
samp1234 352:022c513aee03 340
samp1234 352:022c513aee03 341 // Digital Isolator SD card
samp1234 352:022c513aee03 342 DigitalOut SD_CARD_fromuC_ENA3(PIN85,1);
samp1234 352:022c513aee03 343 DigitalOut SD_CARD_fromISO_ENA4 (PIN84,1);
samp1234 352:022c513aee03 344
samp1234 352:022c513aee03 345 // COM TX Digital Isolator
samp1234 352:022c513aee03 346 DigitalOut COM_DATA_fromuC_ENAIN(PIN6,0);
samp1234 352:022c513aee03 347 DigitalOut COM_DATA_fromISO_ENAOUT(PIN7,0);
spacelab 308:7c3872365d58 348
ee12b079 194:ab528911780d 349 //SD HK
ee12b079 194:ab528911780d 350 uint32_t FSC_CURRENT[6];
chaithanyarss 327:5a967a66c10f 351 uint32_t FSC_OLD[6];
ee12b079 209:63e9c8f8b5d2 352 uint8_t SD_RD_ERROR;
ee12b079 209:63e9c8f8b5d2 353
ee12b079 209:63e9c8f8b5d2 354 //Time's
ee12b079 209:63e9c8f8b5d2 355 uint32_t TIME_LATEST_RTC;
ee12b079 209:63e9c8f8b5d2 356 uint32_t TIME_LATEST_I2C_BAE;
ee12b079 209:63e9c8f8b5d2 357 uint32_t TIME_LATEST_I2C_SPEED;
ee12b079 209:63e9c8f8b5d2 358 uint32_t TIME_LATEST_SD_WR;
ee12b079 209:63e9c8f8b5d2 359 uint32_t TIME_LATEST_SD_RD;
ee12b079 209:63e9c8f8b5d2 360 uint32_t TIME_LATEST_SPI_SPEED;
samp1234 357:f3d48d62e00e 361 uint64_t TIME_LATEST_CDMS_EPS_RST;
samp1234 357:f3d48d62e00e 362 uint64_t TIME_LATEST_CDMS_EPS_RST_BACKUP;
ee12b079 209:63e9c8f8b5d2 363
ee12b079 209:63e9c8f8b5d2 364 //Counter's
chaithanyarss 290:3159ff1081a2 365 uint16_t CDMS_I2C_ERR_SPEED_COUNTER = 0;
chaithanyarss 290:3159ff1081a2 366 uint16_t CDMS_I2C_ERR_BAE_COUNTER = 0;
samp1234 356:197c93dc2012 367 uint16_t CDMS_I2C_ERR_BAE_CURRENT = 0;
samp1234 356:197c93dc2012 368 uint8_t KILL_BAE_COUNTER = 0;
samp1234 356:197c93dc2012 369 uint8_t GIVE_UP_ON_BAE = 0;
chaithanyarss 290:3159ff1081a2 370 uint16_t CDMS_HK_MAIN_COUNTER = 0;
samp1234 356:197c93dc2012 371 uint16_t CDMS_I2C_ERR_HK_LATEST = 0;
chaithanyarss 290:3159ff1081a2 372 uint16_t COMRX_RESET_COUNTER = 0;
chaithanyarss 290:3159ff1081a2 373 uint16_t PL_MAIN_COUNTER = 0;
chaithanyarss 290:3159ff1081a2 374 uint16_t PL_RCV_SC_DATA_COUNTER = 0;
chaithanyarss 290:3159ff1081a2 375 uint16_t CDMS_WR_SD_FAULT_COUNTER = 0;
chaithanyarss 257:7d404e9dc9e2 376 uint16_t SD_LIB_WRITES = 0;
ee12b079 209:63e9c8f8b5d2 377
ee12b079 209:63e9c8f8b5d2 378 //CDMS RAM parameters
chaithanyarss 290:3159ff1081a2 379 uint8_t PL_INIT_STATUS = 0;
chaithanyarss 290:3159ff1081a2 380 uint8_t PL_MAIN_status;
chaithanyarss 303:b49b486a7107 381 uint8_t PL_LOW_power;
ee12b079 209:63e9c8f8b5d2 382 uint8_t PL_STATE;
chaithanyarss 290:3159ff1081a2 383 uint8_t PL_RCV_SC_DATA_STATUS = 0;
ee12b079 209:63e9c8f8b5d2 384 uint8_t COM_SESSION;
ee12b079 209:63e9c8f8b5d2 385 uint8_t COM_RX;
ee12b079 209:63e9c8f8b5d2 386 uint8_t RF_SW_STATUS;
ee12b079 209:63e9c8f8b5d2 387 uint8_t COM_TX;
ee12b079 209:63e9c8f8b5d2 388 uint8_t COM_TX_STATUS;
ee12b079 209:63e9c8f8b5d2 389 uint8_t COM_MNG_TMTC;
chaithanyarss 290:3159ff1081a2 390 uint8_t EN_CDMS_HK = 1;
chaithanyarss 290:3159ff1081a2 391 uint8_t EN_PL = 1;
chaithanyarss 290:3159ff1081a2 392 uint8_t EN_RCV_SC = 1;
samp1234 357:f3d48d62e00e 393 uint8_t EN_P_MGMT = 0;
ee12b079 209:63e9c8f8b5d2 394 uint8_t CDMS_INIT_STATUS;
ee12b079 209:63e9c8f8b5d2 395 uint8_t CDMS_HK_STATUS;
chaithanyarss 257:7d404e9dc9e2 396 uint8_t COM_RX_STATUS;
chaithanyarss 257:7d404e9dc9e2 397 uint8_t CDMS_RTC_BL;
chaithanyarss 257:7d404e9dc9e2 398
ee12b079 318:978d72f191f9 399
samp1234 357:f3d48d62e00e 400 //CDMS EEPROM parameters
ee12b079 289:9bd62b69874c 401
chaithanyarss 257:7d404e9dc9e2 402 uint8_t EPS_V_A_EN_STATUS;
ee12b079 289:9bd62b69874c 403 //uint8_t BAE_SW_STATUS;
ee12b079 289:9bd62b69874c 404 //uint8_t CDMS_SD_SW_STATUS;
samp1234 356:197c93dc2012 405 uint8_t PL_BEE_SW_STATUS;
chaithanyarss 257:7d404e9dc9e2 406 uint8_t PL_EPS_LATCH_SW_EN;
samp1234 356:197c93dc2012 407 uint8_t RTC_INIT_STATUS; //added on 27-5-2017 - Joel
chaithanyarss 257:7d404e9dc9e2 408 uint8_t CDMS_RTC_DISABLE;
chaithanyarss 257:7d404e9dc9e2 409 uint16_t CDMS_RESET_COUNTER;
chaithanyarss 257:7d404e9dc9e2 410 uint32_t TIME_LATEST_CDSMS_RESET;
chaithanyarss 257:7d404e9dc9e2 411 uint16_t COM_TC_BYTES_LIMIT;
chaithanyarss 257:7d404e9dc9e2 412 uint8_t COM_RX_CURRENT_MAX;
chaithanyarss 257:7d404e9dc9e2 413 uint8_t COM_RX_DISABLE_TIMEOUT;
chaithanyarss 257:7d404e9dc9e2 414 uint8_t COM_PA_TMP_HIGH;
samp1234 354:eb6c863756a8 415 uint8_t COM_PA_TMP_IN_TX;
chaithanyarss 257:7d404e9dc9e2 416 uint8_t COM_PA_RECOVERY_TIMEOUT;
samp1234 356:197c93dc2012 417 uint8_t COM_SESSION_TIMEOUT = 240; //confirm with Anirudh
chaithanyarss 257:7d404e9dc9e2 418 uint8_t COM_RSSI_MIN;
samp1234 357:f3d48d62e00e 419 uint8_t TC_count;
samp1234 356:197c93dc2012 420 //uint16_t SD_LIB_BLK_CURRENT_1;
samp1234 356:197c93dc2012 421 //uint16_t SD_LIB_BLK_CURRENT_2;
samp1234 357:f3d48d62e00e 422 //COM threshold
samp1234 356:197c93dc2012 423 uint32_t SD_LIB_BLK_CURRENT;
samp1234 357:f3d48d62e00e 424 uint32_t sfp_threshold_m0[52] = {124,124,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,4032,252,252,252,252,252,4032,8128,8128,8128,8128,8128,8128,8128,8128,960,960,960,960,960,960,960,960,960,960,960,960,4032,4032,4032,4032,8128,8128,8128,8128};
samp1234 357:f3d48d62e00e 425 uint32_t scp_threshold_m0[52] = {4032,4032,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,114688,8128,4032,4032,4032,4032,114688,245760,245760,245760,245760,245760,245760,245760,245760,49152,49152,49152,49152,49152,49152,49152,49152,49152,49152,49152,49152,114688,114688,114688,114688,245760,245760,245760,245760};
samp1234 357:f3d48d62e00e 426 uint32_t scp_threshold_m0_1[9] = {114688,245760,245760,245760,245760,114688,114688,65472,65472} ; //for callibrated mode with data conservation
samp1234 357:f3d48d62e00e 427 uint32_t scp_sfp_threshold_m0_2[3] = {245760,65472,65472};
samp1234 357:f3d48d62e00e 428 uint32_t sfp_threshold_m1[52] = {1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,1984,8128,8128,8128,8128};
samp1234 357:f3d48d62e00e 429 uint32_t scp_threshold_m1[52] = {114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,114688,245760,245760,245760,245760};
samp1234 357:f3d48d62e00e 430
ee12b079 289:9bd62b69874c 431
ee12b079 289:9bd62b69874c 432 // Ambigouties
ee12b079 338:d63eb331a67d 433 uint8_t EN_RTC = 0x01;
ee12b079 338:d63eb331a67d 434
ee12b079 338:d63eb331a67d 435 //Variables used by shubham (02-01-2017)
ee12b079 338:d63eb331a67d 436 uint8_t com_oc_sw_status = 1;
ee12b079 338:d63eb331a67d 437 uint8_t COM_OC_SET = 0;
ee12b079 338:d63eb331a67d 438 uint8_t COM_RSSI_SET = 0;
ee12b079 338:d63eb331a67d 439 uint8_t resume_pl_dma = 0;
samp1234 357:f3d48d62e00e 440
samp1234 357:f3d48d62e00e 441 //For power mode MGMT
samp1234 357:f3d48d62e00e 442 uint8_t POWER_MODE;
samp1234 357:f3d48d62e00e 443
samp1234 357:f3d48d62e00e 444 //For sleep
samp1234 357:f3d48d62e00e 445 bool expired;