To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: DefinitionsAndGlobals.h
- Revision:
- 2:2caf2a9a13aa
- Parent:
- 1:a0055b3280c8
- Child:
- 3:6c81fc8834e2
--- a/DefinitionsAndGlobals.h Mon Dec 14 12:04:01 2015 +0000 +++ b/DefinitionsAndGlobals.h Tue Dec 22 06:09:48 2015 +0000 @@ -1,18 +1,22 @@ // **************DEFINITIONS********************* // COM_RX #define RX_TIMEOUT_LIMIT 1.0 - #define COM_RX_UART_TX PTE22 - #define COM_RX_UART_RX PTE23 + #define COM_RX_UART_TX PTE20 + #define COM_RX_UART_RX PTE21 // COMMON SPI #define SPI_MOSI PTE1 #define SPI_MISO PTE3 #define SPI_CLK PTE2 #define SPI_CS_ADF PTA15 - #define SPI_CS_SDC PTB1 + #define SPI_CS_SDC PTE22 + #define SPI_CS_RTC PTE29 + +// ADF INTERRUPUT + #define ADF_IRQ PTA14 // TC LIST - #define TCL_STATE_IDLE 0x00 + #define TCL_STATE_INCOMPLETE 0x00 #define TCL_STATE_EXECUTING 0x01 #define TCL_STATE_COMPLETED 0x03 #define TCL_STATE_ABORTED 0x02 @@ -24,12 +28,15 @@ */ // LIST OF FLAGS - #define UART_INT_FLAG 0x01 - #define NEW_TC_RECEIVED 0x02 - #define START_SESSION 0x03 - #define END_SESSION 0x04 - #define ALL_CRC_PASS_FLAG 0x05 - #define EXECUTE_OBOSC_FLAG 0x06 + #define UART_INT_FLAG 0x0001 + #define NEW_TC_RECEIVED 0x0002 + #define COM_SESSION_FLAG 0x0004 + #define COM_RX_FLAG 0x0008 + #define COM_MNG_TMTC_RUNNING_FLAG 0x0010 + #define COM_SESSION_VALIDITY 0x0020 + #define ALL_CRC_PASS_FLAG 0x0040 + #define COM_PA_HOT_FLAG 0x0080 + #define COM_TX_FLAG 0x0100 // COM_MNG_TMTC THREAD #define SESSION_TIME_LIMIT 1200 @@ -38,11 +45,19 @@ #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03 // COM_MNG_TMTC + #define COM_PA_COOLING_TIME_LIMIT 20 + + // call sign + #define PSC_CALLSIGN 0x00 + #define APID_CALLSIGN 0x00 + + // max value of telecommands in a tcl + #define TCL_OVERFLOW_CONSTANT 256 + // starting value of packet sequence count at each pass #define PSC_START_VALUE 1 // APID list - #define APID_CALLSIGN 0 #define APID_BAE 1 #define APID_CDMS 2 #define APID_SPEED 3 @@ -68,35 +83,34 @@ #define OBOSC_SUB_REP_LE 0x0F #define OBOSC_SUB_RESET 0x07 - - // ****************GLOBAL VARIABLES****************** // DEBUG Serial gPC( USBTX, USBRX ); -DigitalOut gLEDR(LED_RED); -DigitalOut gLEDG(LED_GREEN); +//DigitalOut gLEDR(LED_RED); +//DigitalOut gLEDG(LED_GREEN); // COM_RX RawSerial RX1M( COM_RX_UART_TX, COM_RX_UART_RX ); COM_RX_DATA_NODE *gRX_HEAD_DATA_NODE = NULL; COM_RX_DATA_NODE *gRX_CURRENT_DATA_NODE = NULL; -uint8_t *gRX_CURRENT_PTR = NULL; +// uint8_t *gRX_CURRENT_PTR = NULL; uint32_t gRX_COUNT = 0; uint16_t gTOTAL_INCORRECT_SIZE_TC = 0x00; uint16_t gTOTAL_CRC_FAIL_TC = 0x00; - +uint16_t gTOTAL_REPEATED_TC = 0x00; // COMMON SPI SPI spi( SPI_MOSI, SPI_MISO, SPI_CLK ); DigitalOut gCS_ADF(SPI_CS_ADF); DigitalOut gCS_SDC(SPI_CS_SDC); +DigitalOut gCS_RTC(SPI_CS_RTC); Mutex SPI_mutex; // TC LIST Base_tc* gHEAD_NODE_TCL = NULL; Base_tc* gLAST_NODE_TCL = NULL; -uint8_t gMASTER_STATE = TCL_STATE_IDLE; -uint8_t gFLAGS = 0x00; +uint8_t gMASTER_STATE = TCL_STATE_INCOMPLETE; +uint16_t gFLAGS = 0x0000; // COM_MNG_TMTC THREAD Thread* gCOM_MNG_TMTC_THREAD = NULL; @@ -104,6 +118,13 @@ Timeout gSESSION_TIMEOUT; // COM_MNG_TMTC + +// PA cooling timeout +Timeout gCOM_PA_COOLING_TIMER; + +// GS code for verification +const uint8_t gGSCODE[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t gTOTAL_VALID_TC = 0x00; // USE LAST_L1_ACK FOR GENERATING REPORT uint8_t gLAST_L1_ACK[TM_SHORT_SIZE];