sd 32 update

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Structures.h Source File

Structures.h

00001 // TC TM
00002     #define TC_SHORT_SIZE 11
00003     #define TC_LONG_SIZE 135
00004     #define TM_LONG_SIZE 134
00005     #define TM_SHORT_SIZE 13
00006 
00007     #define SHORT_TC_CODE 0
00008     #define LONG_TC_CODE 1
00009 
00010     #define SHORT_TM_CODE 1
00011     #define LONG_TM_CODE 0
00012 
00013 // COM_RX
00014     #define RX_BUFFER_LENGTH 60
00015     // 60+4 = 64
00016 
00017 struct data_node{
00018    uint8_t values[RX_BUFFER_LENGTH];
00019    struct data_node* next_node;
00020 };
00021 typedef struct data_node COM_RX_DATA_NODE;
00022 
00023 //TELECOMMAND:
00024 
00025 /*
00026 exec_status:
00027 0: unexecuted
00028 1: successfully executed
00029 2: Execution Failed
00030 3: Disabled
00031 4: Marked For retry
00032 */
00033 #define TC_STATE_UNEXECUTED 0x00
00034 #define TC_STATE_SUCCESSFULLY_EXECUTED 0x01
00035 #define TC_STATE_EXECUTION_FAILED 0x02
00036 #define TC_STATE_DISABLED 0x04
00037 #define TC_STATE_MARKED_RETRY 0x05
00038 
00039 //MASKS
00040 #define SHORT_LONG_TC_MASK 0x10
00041 #define CRC_MASK 0x08
00042 #define EXEC_STATUS_MASK 0x07
00043 
00044 //USE ONLY THE BELOW MACROS TO MODIFY 'flags' VARIABLE
00045 //x should be a Base_tc pointer
00046 #define GETshort_or_long_tc(x) ( ( (x->flags) & SHORT_LONG_TC_MASK ) >> 4 )
00047 #define GETcrc_pass(x) ( ( (x->flags) & CRC_MASK ) >> 3 )
00048 #define GETabort_on_nack(x) ( ( (x->TC_string[1]) & 0x08 ) >> 3 )
00049 #define GETapid(x) ( ( (x->TC_string[1]) & 0xA0 ) >> 6 )
00050 #define GETexec_status(x) ( (x->flags) & EXEC_STATUS_MASK )
00051 #define GETpacket_seq_count(x) (x->TC_string[0])
00052 #define GETservice_type(x) ( (x->TC_string[2]) & 0xF0 )
00053 #define GETservice_subtype(x) ( (x->TC_string[2]) & 0x0F )
00054 #define GETpid(x) (x->TC_string[3])
00055 
00056 //x should be a Base_tc pointer
00057 //y should be a 8-bit number with relevant data in LSB
00058 //use in a seperate line with ; at the end: similar to a function
00059 #define PUTshort_or_long(x,y) x->flags = ( (x->flags) & ~(SHORT_LONG_TC_MASK)) | ( (y << 4) & SHORT_LONG_TC_MASK )
00060 #define PUTcrc_pass(x,y) x->flags = ( (x->flags) & ~(CRC_MASK)) | ( (y << 3) & CRC_MASK)
00061 #define PUTexec_status(x,y) x->flags = ( (x->flags) & ~(EXEC_STATUS_MASK)) | ( y & EXEC_STATUS_MASK)
00062 
00063 //PARENT TELECOMMAND CLASS 
00064 class Base_tc{
00065 public:
00066     uint8_t flags;
00067     uint8_t *TC_string;
00068     Base_tc *next_TC;
00069     
00070     virtual ~Base_tc(){}
00071 };
00072 
00073 //DERIVED CLASS - SHORT TC
00074 class Short_tc : public Base_tc{
00075 private:
00076     uint8_t fix_str[TC_SHORT_SIZE];
00077 public:
00078     Short_tc(){
00079         TC_string = fix_str;
00080         flags = 0;
00081     }
00082     
00083     ~Short_tc(){}
00084 };
00085 
00086 //DERIVED CLASS - LONG TC
00087 class Long_tc : public Base_tc{
00088 private:
00089     uint8_t fix_str[TC_LONG_SIZE];
00090 public:
00091     Long_tc(){
00092         TC_string = fix_str;
00093         flags = 0;
00094     }
00095     
00096     ~Long_tc(){}
00097 };
00098 
00099 // TELEMETRY:
00100 // MASKS
00101 #define SHORT_LONG_TM_MASK 0x10
00102 #define TMID_MASK 0x0F
00103 
00104 //x should be 'fields' variable defined in the Base_tm
00105 #define GETshort_or_long_tm(x) ((x & SHORT_LONG_TM_MASK) >> 4)
00106 #define GETtmid(x) (x & TMID_MASK)
00107 
00108 //x should be 'fields' variable defines in the Base_tm
00109 //y should be an 8-bit number with relevent data at LSB
00110 #define PUTshort_or_long_tm(x,y) x = (x & ~(SHORT_LONG_TM_MASK)) | ((y<<4) & SHORT_LONG_TM_MASK)
00111 #define PUTtmid(x,y) x = (x & ~(TMID_MASK)) | (y & TMID_MASK)
00112 
00113 // PARENT TELEMETRY CLASS
00114 class Base_tm{
00115 public:
00116     uint8_t fields;
00117     uint8_t *TM_string;
00118     Base_tm *next_TM;
00119     
00120     virtual ~Base_tm(){}
00121 };
00122 
00123 // DERIVED CLASS : Long tm [type 0]
00124 // type 0
00125 class Long_tm : public Base_tm{
00126 private:
00127     uint8_t fix_str[TM_LONG_SIZE];
00128 public:
00129     Long_tm(){
00130         TM_string = fix_str;
00131         // type 0
00132         fields = 0;
00133     }
00134     
00135     ~Long_tm(){}
00136 };
00137 
00138 // DERIVED CLASS : Short tm [type 1]
00139 // type 1
00140 class Short_tm : public Base_tm{
00141 private:
00142     uint8_t fix_str[TM_SHORT_SIZE];
00143 public:
00144     Short_tm(){
00145         TM_string = fix_str;
00146         // type 1
00147         fields = 0x10;
00148     }
00149     
00150     ~Short_tm(){}
00151 };