11th feb i2c checking chaitu's code

Dependencies:   SimpleDMA eeprom mbed-rtos mbed

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Committer:
ee12b079
Date:
Fri Jan 15 08:59:09 2016 +0000
Revision:
57:bf998cb2a104
Parent:
52:0bd68655c651
Child:
61:15a5dfe84945
Made changes for printing type1 and type0 tm frames in snd_tm. This is for bypassing adf and sending directly to APS.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shreeshas95 0:f016e9e8d48b 1 // **************DEFINITIONS*********************
shreeshas95 0:f016e9e8d48b 2 // COM_RX
shreeshas95 5:ab276a17ca07 3 #define RX_TIMEOUT_LIMIT 0.5
aniruddhv 52:0bd68655c651 4 #define COM_RX_UART_TX PTE20
aniruddhv 52:0bd68655c651 5 #define COM_RX_UART_RX PTE21
ee12b079 57:bf998cb2a104 6
ee12b079 57:bf998cb2a104 7 // For serial port printing(SET BAUD RATE 1200)
ee12b079 57:bf998cb2a104 8 // #define COM_RX_UART_TX USBTX
ee12b079 57:bf998cb2a104 9 // #define COM_RX_UART_RX USBRX
shreeshas95 0:f016e9e8d48b 10
shreeshas95 0:f016e9e8d48b 11 // COMMON SPI
shreeshas95 0:f016e9e8d48b 12 #define SPI_MOSI PTE1
shreeshas95 0:f016e9e8d48b 13 #define SPI_MISO PTE3
shreeshas95 0:f016e9e8d48b 14 #define SPI_CLK PTE2
shreeshas95 1:a0055b3280c8 15 #define SPI_CS_ADF PTA15
shreeshas95 2:2caf2a9a13aa 16 #define SPI_CS_SDC PTE22
shreeshas95 2:2caf2a9a13aa 17 #define SPI_CS_RTC PTE29
shreeshas95 2:2caf2a9a13aa 18
shreeshas95 4:104dd82c99b8 19 // COM_TX
shreeshas95 4:104dd82c99b8 20 #define COM_TX_CONFIG_LIMIT 3
aniruddhv 52:0bd68655c651 21 #define COM_TX_TICKER_LIMIT 32
shreeshas95 4:104dd82c99b8 22
shreeshas95 2:2caf2a9a13aa 23 // ADF INTERRUPUT
shreeshas95 2:2caf2a9a13aa 24 #define ADF_IRQ PTA14
shreeshas95 0:f016e9e8d48b 25
shreeshas95 0:f016e9e8d48b 26 // TC LIST
shreeshas95 2:2caf2a9a13aa 27 #define TCL_STATE_INCOMPLETE 0x00
shreeshas95 5:ab276a17ca07 28 #define TCL_STATE_ABORTED 0x03
shreeshas95 5:ab276a17ca07 29 #define TCL_STATE_EXECUTING 0x04
shreeshas95 5:ab276a17ca07 30 #define TCL_STATE_COMPLETED 0x05
shreeshas95 5:ab276a17ca07 31 #define TCL_STATE_EXCEEDED_LIMIT 0x06
shreeshas95 0:f016e9e8d48b 32
shreeshas95 0:f016e9e8d48b 33 // LIST OF FLAGS
shreeshas95 2:2caf2a9a13aa 34 #define UART_INT_FLAG 0x0001
shreeshas95 2:2caf2a9a13aa 35 #define NEW_TC_RECEIVED 0x0002
shreeshas95 2:2caf2a9a13aa 36 #define COM_SESSION_FLAG 0x0004
shreeshas95 2:2caf2a9a13aa 37 #define COM_RX_FLAG 0x0008
shreeshas95 2:2caf2a9a13aa 38 #define COM_MNG_TMTC_RUNNING_FLAG 0x0010
shreeshas95 2:2caf2a9a13aa 39 #define COM_SESSION_VALIDITY 0x0020
shreeshas95 2:2caf2a9a13aa 40 #define ALL_CRC_PASS_FLAG 0x0040
shreeshas95 2:2caf2a9a13aa 41 #define COM_PA_HOT_FLAG 0x0080
shreeshas95 2:2caf2a9a13aa 42 #define COM_TX_FLAG 0x0100
shreeshas95 6:79d422d1ed42 43 #define COM_SESSION_TIMEOUT_FLAG 0x0200
shreeshas95 0:f016e9e8d48b 44
shreeshas95 0:f016e9e8d48b 45 // COM_MNG_TMTC THREAD
shreeshas95 6:79d422d1ed42 46 #define SESSION_TIME_LIMIT 1500
shreeshas95 0:f016e9e8d48b 47 #define COM_MNG_TMTC_SIGNAL_UART_INT 0x01
shreeshas95 0:f016e9e8d48b 48 #define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02
shreeshas95 0:f016e9e8d48b 49 #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03
shreeshas95 0:f016e9e8d48b 50
shreeshas95 0:f016e9e8d48b 51 // COM_MNG_TMTC
shreeshas95 2:2caf2a9a13aa 52 #define COM_PA_COOLING_TIME_LIMIT 20
shreeshas95 4:104dd82c99b8 53 #define COM_MAX_TC_LIMIT 200
shreeshas95 4:104dd82c99b8 54 #define TM_ACK_CODE_INDEX 2
shreeshas95 5:ab276a17ca07 55 #define CRC_FAIL_NACK_CODE 0x01
shreeshas95 2:2caf2a9a13aa 56
shreeshas95 2:2caf2a9a13aa 57 // call sign
shreeshas95 2:2caf2a9a13aa 58 #define PSC_CALLSIGN 0x00
shreeshas95 2:2caf2a9a13aa 59 #define APID_CALLSIGN 0x00
shreeshas95 2:2caf2a9a13aa 60
shreeshas95 2:2caf2a9a13aa 61 // max value of telecommands in a tcl
shreeshas95 2:2caf2a9a13aa 62 #define TCL_OVERFLOW_CONSTANT 256
shreeshas95 4:104dd82c99b8 63 #define TM_OVERFLOW_CONSTANT 256
shreeshas95 2:2caf2a9a13aa 64
shreeshas95 0:f016e9e8d48b 65 // starting value of packet sequence count at each pass
shreeshas95 0:f016e9e8d48b 66 #define PSC_START_VALUE 1
shreeshas95 0:f016e9e8d48b 67
shreeshas95 0:f016e9e8d48b 68 // APID list
aniruddhv 52:0bd68655c651 69 #define APID_COM 0
shreeshas95 0:f016e9e8d48b 70 #define APID_BAE 1
shreeshas95 0:f016e9e8d48b 71 #define APID_CDMS 2
shreeshas95 0:f016e9e8d48b 72 #define APID_SPEED 3
shreeshas95 0:f016e9e8d48b 73
aniruddhv 52:0bd68655c651 74 //SERVICE
aniruddhv 52:0bd68655c651 75 #define SERVICE_OBOSC 0xB
aniruddhv 52:0bd68655c651 76 #define SERVICE_OBSRS 0xF
aniruddhv 52:0bd68655c651 77
shreeshas95 0:f016e9e8d48b 78 // HIGH PRIORITY TC - priority list
shreeshas95 0:f016e9e8d48b 79 // not correct values here
shreeshas95 0:f016e9e8d48b 80 #define HPTC1 5
shreeshas95 0:f016e9e8d48b 81 #define HPTC2 6
shreeshas95 0:f016e9e8d48b 82 // Add more entries above
shreeshas95 0:f016e9e8d48b 83
shreeshas95 0:f016e9e8d48b 84 // SIZE of tc in bytes
shreeshas95 0:f016e9e8d48b 85 #define TC_SHORT_SIZE 11
shreeshas95 0:f016e9e8d48b 86 #define TC_LONG_SIZE 135
shreeshas95 0:f016e9e8d48b 87
shreeshas95 0:f016e9e8d48b 88 // TMID list
shreeshas95 0:f016e9e8d48b 89 #define TMID_ACK_L1 0xA
shreeshas95 4:104dd82c99b8 90 #define TMID_ACK_L234 0xB
shreeshas95 4:104dd82c99b8 91 #define TMID_TCL 0x7
shreeshas95 4:104dd82c99b8 92 #define TMID_CALL_SIGN 0xE
shreeshas95 0:f016e9e8d48b 93
shreeshas95 0:f016e9e8d48b 94 // OBOSC SERVICE SUBTYPE
shreeshas95 4:104dd82c99b8 95 #define OBOSC_TCL_MAX_SHORT_SIZE 11
shreeshas95 4:104dd82c99b8 96 #define OBOSC_LONG_TC_FIRST_HALF_SIZE 67
shreeshas95 4:104dd82c99b8 97 #define OBOSC_LONG_TC_SECOND_HALF_SIZE 68
shreeshas95 4:104dd82c99b8 98 #define OBOSC_TCL_TAG_LONG_FIRST_HALF 0x10
shreeshas95 4:104dd82c99b8 99 #define OBOSC_TCL_TAG_LONG_SECOND_HALF 0x11
shreeshas95 4:104dd82c99b8 100
shreeshas95 0:f016e9e8d48b 101 #define OBOSC_SUB_DISABLE 0x01
shreeshas95 0:f016e9e8d48b 102 #define OBOSC_SUB_RETRY 0x05
shreeshas95 4:104dd82c99b8 103 #define OBOSC_SUB_REP_TCLD 0x06
shreeshas95 0:f016e9e8d48b 104 #define OBOSC_SUB_REP_LE 0x0F
shreeshas95 0:f016e9e8d48b 105 #define OBOSC_SUB_RESET 0x07
shreeshas95 0:f016e9e8d48b 106
shreeshas95 3:6c81fc8834e2 107 // PAYLOAD
shreeshas95 3:6c81fc8834e2 108 #define PAYLOAD_BUFFER_LENGTH 2190
shreeshas95 3:6c81fc8834e2 109
shreeshas95 0:f016e9e8d48b 110 // ****************GLOBAL VARIABLES******************
shreeshas95 0:f016e9e8d48b 111 // DEBUG
shreeshas95 0:f016e9e8d48b 112 Serial gPC( USBTX, USBRX );
shreeshas95 4:104dd82c99b8 113 DigitalOut gLEDR(LED_RED);
shreeshas95 4:104dd82c99b8 114 DigitalOut gLEDG(LED_GREEN);
shreeshas95 0:f016e9e8d48b 115
shreeshas95 0:f016e9e8d48b 116 // COM_RX
shreeshas95 0:f016e9e8d48b 117 RawSerial RX1M( COM_RX_UART_TX, COM_RX_UART_RX );
shreeshas95 0:f016e9e8d48b 118 COM_RX_DATA_NODE *gRX_HEAD_DATA_NODE = NULL;
shreeshas95 0:f016e9e8d48b 119 COM_RX_DATA_NODE *gRX_CURRENT_DATA_NODE = NULL;
shreeshas95 2:2caf2a9a13aa 120 // uint8_t *gRX_CURRENT_PTR = NULL;
shreeshas95 0:f016e9e8d48b 121 uint32_t gRX_COUNT = 0;
shreeshas95 0:f016e9e8d48b 122 uint16_t gTOTAL_INCORRECT_SIZE_TC = 0x00;
shreeshas95 0:f016e9e8d48b 123 uint16_t gTOTAL_CRC_FAIL_TC = 0x00;
shreeshas95 2:2caf2a9a13aa 124 uint16_t gTOTAL_REPEATED_TC = 0x00;
shreeshas95 0:f016e9e8d48b 125
shreeshas95 0:f016e9e8d48b 126 // COMMON SPI
shreeshas95 0:f016e9e8d48b 127 SPI spi( SPI_MOSI, SPI_MISO, SPI_CLK );
shreeshas95 1:a0055b3280c8 128 DigitalOut gCS_ADF(SPI_CS_ADF);
shreeshas95 1:a0055b3280c8 129 DigitalOut gCS_SDC(SPI_CS_SDC);
shreeshas95 2:2caf2a9a13aa 130 DigitalOut gCS_RTC(SPI_CS_RTC);
shreeshas95 0:f016e9e8d48b 131 Mutex SPI_mutex;
shreeshas95 0:f016e9e8d48b 132
shreeshas95 0:f016e9e8d48b 133 // TC LIST
shreeshas95 0:f016e9e8d48b 134 Base_tc* gHEAD_NODE_TCL = NULL;
shreeshas95 0:f016e9e8d48b 135 Base_tc* gLAST_NODE_TCL = NULL;
shreeshas95 2:2caf2a9a13aa 136 uint8_t gMASTER_STATE = TCL_STATE_INCOMPLETE;
shreeshas95 2:2caf2a9a13aa 137 uint16_t gFLAGS = 0x0000;
shreeshas95 0:f016e9e8d48b 138
shreeshas95 0:f016e9e8d48b 139 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 140 Thread* gCOM_MNG_TMTC_THREAD = NULL;
shreeshas95 0:f016e9e8d48b 141 Timeout gRX_TIMEOUT;
shreeshas95 0:f016e9e8d48b 142 Timeout gSESSION_TIMEOUT;
shreeshas95 0:f016e9e8d48b 143
shreeshas95 0:f016e9e8d48b 144 // COM_MNG_TMTC
shreeshas95 2:2caf2a9a13aa 145
shreeshas95 2:2caf2a9a13aa 146 // PA cooling timeout
shreeshas95 4:104dd82c99b8 147 Timeout gCOM_PA_COOLING_TIMEOUT;
shreeshas95 2:2caf2a9a13aa 148
shreeshas95 2:2caf2a9a13aa 149 // GS code for verification
aniruddhv 37:c9a739750806 150 const uint8_t gGSCODE[] = {0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
shreeshas95 2:2caf2a9a13aa 151
shreeshas95 0:f016e9e8d48b 152 uint8_t gTOTAL_VALID_TC = 0x00;
shreeshas95 0:f016e9e8d48b 153 // USE LAST_L1_ACK FOR GENERATING REPORT
shreeshas95 4:104dd82c99b8 154 uint8_t gLAST_TM[TM_LONG_SIZE];
shreeshas95 4:104dd82c99b8 155 uint8_t gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;
shreeshas95 3:6c81fc8834e2 156
shreeshas95 3:6c81fc8834e2 157 // SCIENCE_THREAD
shreeshas95 3:6c81fc8834e2 158 Thread* gSCIENCE_THREAD = NULL;
shreeshas95 4:104dd82c99b8 159 uint8_t gPAYLOAD_BUFFER[PAYLOAD_BUFFER_LENGTH];
shreeshas95 4:104dd82c99b8 160
shreeshas95 4:104dd82c99b8 161 // CALL SIGN TM
shreeshas95 4:104dd82c99b8 162 const uint8_t gCALL_SIGN_STRING[TM_SHORT_SIZE] = {0xE0, 0x00, 0x00, 0x00, 0x56, 0x55, 0x32, 0x4E, 0x43, 0x46, 0x00, 0xAC, 0x11};