pl ack in tmtc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_pl123 by shubham c

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DefinitionsAndGlobals.h Source File

DefinitionsAndGlobals.h

00001 // **************DEFINITIONS*********************
00002 
00003 #define bypass_adf 1
00004 
00005 // COM_RX
00006     #define RX_TIMEOUT_LIMIT 0.5
00007     //#define COM_RX_UART_TX PTE20    // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_TX USBTX
00008     //#define COM_RX_UART_RX PTE21    // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_RX USBRX
00009     
00010     #define COM_RX_UART_TX USBTX
00011     #define COM_RX_UART_RX USBRX
00012     
00013 // COMMON SPI
00014     #define SPI_MOSI PTE1
00015     #define SPI_MISO PTE3
00016     #define SPI_CLK PTE2
00017     #define SPI_CS_ADF PTA15
00018     #define SPI_CS_SDC PIN20
00019     #define SPI_CS_RTC PIN26
00020     
00021 // COM_TX
00022     #define COM_TX_CONFIG_LIMIT 3
00023     #define COM_TX_TICKER_LIMIT 32
00024 
00025 // ADF INTERRUPUT
00026     #define ADF_IRQ PTA14
00027     
00028 //I2C - Payload to CDMS (need to change while using CDMS hardware)
00029 I2C master(D7,D6);
00030 InterruptIn PYLD_I2C_Int(PTA13);
00031 
00032 // TC LIST
00033     #define TCL_STATE_INCOMPLETE 0x00
00034     #define TCL_STATE_ABORTED 0x03
00035     #define TCL_STATE_EXECUTING 0x04   
00036     #define TCL_STATE_COMPLETED 0x05
00037     #define TCL_STATE_EXCEEDED_LIMIT 0x06
00038 
00039 // LIST OF FLAGS
00040     #define UART_INT_FLAG 0x0001
00041     #define NEW_TC_RECEIVED 0x0002
00042     #define COM_SESSION_FLAG 0x0004
00043     #define COM_RX_FLAG 0x0008
00044     #define COM_MNG_TMTC_RUNNING_FLAG 0x0010
00045     #define COM_SESSION_VALIDITY 0x0020
00046     #define ALL_CRC_PASS_FLAG 0x0040
00047     #define COM_PA_HOT_FLAG 0x0080
00048     #define COM_TX_FLAG 0x0100
00049     #define COM_SESSION_TIMEOUT_FLAG 0x0200
00050 
00051 // COM_MNG_TMTC THREAD
00052     #define SESSION_TIME_LIMIT 1500
00053     #define COM_MNG_TMTC_SIGNAL_UART_INT 0x01
00054     #define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02
00055     #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03
00056     #define SCIENCE_SIGNAL 0x04
00057 // COM_MNG_TMTC
00058     #define COM_PA_COOLING_TIME_LIMIT 20
00059     #define COM_MAX_TC_LIMIT 200
00060     #define TM_ACK_CODE_INDEX 2
00061     #define CRC_FAIL_NACK_CODE 0x01
00062     
00063     // call sign
00064     #define PSC_CALLSIGN 0x00
00065     #define APID_CALLSIGN 0x00
00066     
00067     // max value of telecommands in a tcl
00068     #define TCL_OVERFLOW_CONSTANT 256
00069     #define TM_OVERFLOW_CONSTANT 256
00070 
00071     // starting value of packet sequence count at each pass 
00072     #define PSC_START_VALUE 1
00073     
00074     // APID list
00075     #define APID_COM 0
00076     #define APID_BAE 1
00077     #define APID_CDMS 2
00078     #define APID_SPEED 3
00079     
00080     //SERVICE
00081     #define SERVICE_OBOSC 0xB
00082     #define SERVICE_OBSRS 0xF
00083     
00084     // HIGH PRIORITY TC - priority list
00085     // not correct values here
00086     #define HPTC1 5
00087     #define HPTC2 6
00088     // Add more entries above
00089     
00090     // SIZE of tc in bytes
00091     #define TC_SHORT_SIZE 11
00092     #define TC_LONG_SIZE 135
00093     
00094     // TMID list
00095     #define TMID_ACK_L1 0xA
00096     #define TMID_ACK_L234 0xB
00097     #define TMID_TCL 0x7
00098     #define TMID_CALL_SIGN 0xE
00099 
00100 // OBOSC SERVICE SUBTYPE
00101     #define OBOSC_TCL_MAX_SHORT_SIZE 11
00102     #define OBOSC_LONG_TC_FIRST_HALF_SIZE 67
00103     #define OBOSC_LONG_TC_SECOND_HALF_SIZE 68
00104     #define OBOSC_TCL_TAG_LONG_FIRST_HALF 0x10
00105     #define OBOSC_TCL_TAG_LONG_SECOND_HALF 0x11
00106 
00107     #define OBOSC_SUB_DISABLE 0x01
00108     #define OBOSC_SUB_RETRY 0x05
00109     #define OBOSC_SUB_REP_TCLD 0x06
00110     #define OBOSC_SUB_REP_LE 0x0F
00111     #define OBOSC_SUB_RESET 0x07
00112     
00113 // PAYLOAD or SCIENCE
00114     #define PAYLOAD_BUFFER_LENGTH 6723
00115     #define PAY_SPI_MOSI PTE18
00116     #define PAY_SPI_MISO PTE19
00117     #define PAY_SPI_CLK PTE17
00118     #define PAY_SPI_CS PTE16
00119     
00120     
00121 // ****************GLOBAL VARIABLES******************
00122 // DEBUG
00123 Serial gPC( USBTX, USBRX );
00124 DigitalOut gLEDR(LED_RED);
00125 DigitalOut gLEDG(LED_GREEN);
00126 
00127 // COM_RX
00128 RawSerial RX1M( COM_RX_UART_TX, COM_RX_UART_RX );
00129 COM_RX_DATA_NODE *gRX_HEAD_DATA_NODE = NULL;
00130 COM_RX_DATA_NODE *gRX_CURRENT_DATA_NODE = NULL;
00131 // uint8_t *gRX_CURRENT_PTR = NULL;
00132 uint32_t gRX_COUNT = 0;
00133 uint16_t gTOTAL_INCORRECT_SIZE_TC = 0x00;
00134 uint16_t gTOTAL_CRC_FAIL_TC = 0x00;
00135 uint16_t gTOTAL_REPEATED_TC = 0x00;
00136 
00137 // COMMON SPI
00138 SPI spi( SPI_MOSI, SPI_MISO, SPI_CLK );
00139 DigitalOut gCS_ADF(SPI_CS_ADF);
00140 DigitalOut cs_sd(SPI_CS_SDC);
00141 DigitalOut gCS_RTC(SPI_CS_RTC);
00142 Mutex SPI_mutex;
00143 
00144 // TC LIST
00145 Base_tc* gHEAD_NODE_TCL = NULL;
00146 Base_tc* gLAST_NODE_TCL = NULL;
00147 uint8_t gMASTER_STATE = TCL_STATE_INCOMPLETE;
00148 uint16_t gFLAGS = 0x0000;
00149 
00150 // COM_MNG_TMTC THREAD
00151 Thread* gCOM_MNG_TMTC_THREAD = NULL;
00152 Timeout gRX_TIMEOUT;
00153 Timeout gSESSION_TIMEOUT;
00154 
00155 // COM_MNG_TMTC
00156 
00157 // PA cooling timeout
00158 Timeout gCOM_PA_COOLING_TIMEOUT;
00159 
00160 // GS code for verification
00161 const uint8_t gGSCODE[] = {0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00162 
00163 uint8_t gTOTAL_VALID_TC = 0x00;
00164 // USE LAST_L1_ACK FOR GENERATING REPORT
00165 uint8_t gLAST_TM[TM_LONG_SIZE];
00166 uint8_t gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;
00167 
00168 // PAYLOAD OR SCIENCE_THREAD
00169 Thread* gSCIENCE_THREAD = NULL;
00170 dmaSPISlave gPAY_SPI(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS);
00171 uint8_t gPAYLOAD_BUFFER[PAYLOAD_BUFFER_LENGTH];
00172 
00173 // CALL SIGN TM
00174 const uint8_t gCALL_SIGN_STRING[TM_SHORT_SIZE] = {0xE0, 0x00, 0x00, 0x00, 0x56, 0x55, 0x32, 0x4E, 0x43, 0x46, 0x00, 0xAC, 0x11};
00175 
00176 // CDMS HK
00177 CDMS_HK_actual actual_data;
00178 CDMS_HK_quant quant_data;
00179 CDMS_HK_min_max min_max_data;
00180 bool firstCount=true;
00181 
00182