Changes: bbram Checking Function Registers Checking Funcrtion Indivisual Register checking Functions
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of COM_MNG_TMTC_SIMPLE by
COM_SND_TM.h@70:c4a9b78d1c89, 2016-01-14 (annotated)
- Committer:
- krishanprajapat
- Date:
- Thu Jan 14 14:47:06 2016 +0000
- Revision:
- 70:c4a9b78d1c89
- Parent:
- 11:83acbe8e0ad1
14 jan just a copy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shreeshas95 | 1:a0055b3280c8 | 1 | void adf_not_SDcard(); |
shreeshas95 | 1:a0055b3280c8 | 2 | |
shreeshas95 | 1:a0055b3280c8 | 3 | #define S_FRAME_SIZE 48 |
ee12b079 | 9:e9eaada136c6 | 4 | #define ISR 40 |
shreeshas95 | 1:a0055b3280c8 | 5 | #define TM_FRAME_SIZE 134 //in bytes |
shreeshas95 | 1:a0055b3280c8 | 6 | #define T_FRAME_SIZE 159 |
shreeshas95 | 1:a0055b3280c8 | 7 | #define EOS_SIZE 120 |
ee12b079 | 9:e9eaada136c6 | 8 | #define MAX_ADF_LEN 65535 |
ee12b079 | 9:e9eaada136c6 | 9 | |
shreeshas95 | 1:a0055b3280c8 | 10 | const unsigned char S_frame[] = {0x46,0x9D,0xFB,0xF0,0xD2,0xBA,0x89,0xE4,0x46,0x9D,0xFB,0xF0,0xD2,0xBA,0x89,0xE4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
shreeshas95 | 1:a0055b3280c8 | 11 | const unsigned char EoS[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x91,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x91,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
shreeshas95 | 1:a0055b3280c8 | 12 | const unsigned char FCCH80[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
shreeshas95 | 1:a0055b3280c8 | 13 | const unsigned char SCH40[] = {0x0a,0x3f,0x46,0xb4,0x00}; |
krishanprajapat | 70:c4a9b78d1c89 | 14 | |
shreeshas95 | 1:a0055b3280c8 | 15 | class SND_TM{ |
ee12b079 | 9:e9eaada136c6 | 16 | |
ee12b079 | 9:e9eaada136c6 | 17 | Base_tm * head_ptr; |
ee12b079 | 9:e9eaada136c6 | 18 | |
shreeshas95 | 1:a0055b3280c8 | 19 | // transmit data variables |
shreeshas95 | 1:a0055b3280c8 | 20 | unsigned char Tframe_c; //_c represents counter, counts Tframe written in a segment |
shreeshas95 | 1:a0055b3280c8 | 21 | unsigned char EOS_c; //count no of bytes of eos have been weitten in the rolling buffer |
shreeshas95 | 1:a0055b3280c8 | 22 | unsigned char Sframe_c; //count no of bytes of Sframe have been weitten in the rolling buffer |
shreeshas95 | 1:a0055b3280c8 | 23 | unsigned char SCH40_c; //count no of bytes of SCH40 have been weitten in the rolling buffer |
shreeshas95 | 1:a0055b3280c8 | 24 | unsigned char data_c; |
shreeshas95 | 1:a0055b3280c8 | 25 | unsigned char FCCH80_c; |
shreeshas95 | 1:a0055b3280c8 | 26 | unsigned char RB_c; //rolling buffer counter |
shreeshas95 | 1:a0055b3280c8 | 27 | unsigned char segment_c; //counts the numver of segments sent |
shreeshas95 | 1:a0055b3280c8 | 28 | unsigned char MAX_SEGMENT; |
shreeshas95 | 1:a0055b3280c8 | 29 | bool Sframe; //Sframe = 1bit of CF1 |
shreeshas95 | 1:a0055b3280c8 | 30 | bool SCH40_f; |
shreeshas95 | 1:a0055b3280c8 | 31 | bool FCCH80_f; |
shreeshas95 | 1:a0055b3280c8 | 32 | bool data_f; |
ee12b079 | 9:e9eaada136c6 | 33 | bool repeat_data_f; |
shreeshas95 | 1:a0055b3280c8 | 34 | bool transmit_data_f; |
shreeshas95 | 1:a0055b3280c8 | 35 | bool eos_f; |
shreeshas95 | 1:a0055b3280c8 | 36 | bool junk_f; |
ee12b079 | 9:e9eaada136c6 | 37 | bool segment_r; //flag checking if more sessions are required |
ee12b079 | 9:e9eaada136c6 | 38 | |
ee12b079 | 9:e9eaada136c6 | 39 | |
shreeshas95 | 1:a0055b3280c8 | 40 | // type 1 frame |
ee12b079 | 9:e9eaada136c6 | 41 | |
shreeshas95 | 1:a0055b3280c8 | 42 | Base_tm *T0F_pointer ; |
ee12b079 | 9:e9eaada136c6 | 43 | |
shreeshas95 | 1:a0055b3280c8 | 44 | int diff_prev; |
shreeshas95 | 1:a0055b3280c8 | 45 | void differential_encode(unsigned char* ptr, int length){ |
shreeshas95 | 1:a0055b3280c8 | 46 | for(int i=0; i<length;i++){ |
shreeshas95 | 1:a0055b3280c8 | 47 | unsigned char s = ptr[i] , t; |
shreeshas95 | 1:a0055b3280c8 | 48 | t = s ^ (s >> 1); |
shreeshas95 | 1:a0055b3280c8 | 49 | (diff_prev == 0) ? t=t^0x00 : t=t^0x80 ; |
shreeshas95 | 1:a0055b3280c8 | 50 | diff_prev = int(s & 0x01); |
shreeshas95 | 1:a0055b3280c8 | 51 | ptr[i] = t; |
shreeshas95 | 1:a0055b3280c8 | 52 | } |
ee12b079 | 9:e9eaada136c6 | 53 | } |
ee12b079 | 9:e9eaada136c6 | 54 | |
shreeshas95 | 1:a0055b3280c8 | 55 | int type0_no; //number of type zero frames |
ee12b079 | 9:e9eaada136c6 | 56 | int type1_no; |
shreeshas95 | 1:a0055b3280c8 | 57 | int total_frames; //number of type one packe (TMP) |
shreeshas95 | 1:a0055b3280c8 | 58 | int SEGMENT_NO; //number of type one packe (TMP) |
ee12b079 | 9:e9eaada136c6 | 59 | int TOTAL_SEGMENT_NO; |
ee12b079 | 9:e9eaada136c6 | 60 | int LAST_SEGMENT_SIZE; |
shreeshas95 | 1:a0055b3280c8 | 61 | void inline data_number(){ |
shreeshas95 | 1:a0055b3280c8 | 62 | int type1_frame_no; |
shreeshas95 | 1:a0055b3280c8 | 63 | Base_tm*head = head_ptr; |
shreeshas95 | 1:a0055b3280c8 | 64 | type0_no = 0; |
shreeshas95 | 1:a0055b3280c8 | 65 | type1_no = 0; |
ee12b079 | 9:e9eaada136c6 | 66 | while(head->next_TM != NULL){ |
shreeshas95 | 1:a0055b3280c8 | 67 | switch( GETshort_or_long_tm(head->fields) ){ |
shreeshas95 | 1:a0055b3280c8 | 68 | case 0: |
shreeshas95 | 1:a0055b3280c8 | 69 | type0_no++; |
shreeshas95 | 1:a0055b3280c8 | 70 | break; |
shreeshas95 | 1:a0055b3280c8 | 71 | case 1: |
shreeshas95 | 1:a0055b3280c8 | 72 | type1_no++; |
shreeshas95 | 1:a0055b3280c8 | 73 | break; |
shreeshas95 | 1:a0055b3280c8 | 74 | } |
ee12b079 | 9:e9eaada136c6 | 75 | |
shreeshas95 | 1:a0055b3280c8 | 76 | head=head->next_TM; |
shreeshas95 | 1:a0055b3280c8 | 77 | } |
shreeshas95 | 1:a0055b3280c8 | 78 | type1_frame_no = ( type1_no % 10 == 0 )? (type1_no / 10) : ( (type1_no / 10) + 1); |
shreeshas95 | 1:a0055b3280c8 | 79 | total_frames = type0_no + type1_frame_no ; |
ee12b079 | 9:e9eaada136c6 | 80 | TOTAL_SEGMENT_NO = (total_frames*2 % (ISR) == 0) ? ( total_frames*2/(ISR) ) : (total_frames*2/(ISR) + 1); //subtracting 1 since the last SCH40_f is not detected |
ee12b079 | 9:e9eaada136c6 | 81 | SEGMENT_NO = TOTAL_SEGMENT_NO; |
ee12b079 | 9:e9eaada136c6 | 82 | if(SEGMENT_NO > MAX_SEGMENT) |
ee12b079 | 9:e9eaada136c6 | 83 | { |
ee12b079 | 9:e9eaada136c6 | 84 | SEGMENT_NO = MAX_SEGMENT; |
ee12b079 | 9:e9eaada136c6 | 85 | segment_r = 1; |
ee12b079 | 9:e9eaada136c6 | 86 | } |
ee12b079 | 9:e9eaada136c6 | 87 | else segment_r = 0; |
ee12b079 | 9:e9eaada136c6 | 88 | TOTAL_SEGMENT_NO -= SEGMENT_NO; |
ee12b079 | 9:e9eaada136c6 | 89 | LAST_SEGMENT_SIZE = total_frames*2%ISR; |
shreeshas95 | 1:a0055b3280c8 | 90 | } |
ee12b079 | 9:e9eaada136c6 | 91 | |
shreeshas95 | 1:a0055b3280c8 | 92 | #define next_type_structure(ptr){\ |
shreeshas95 | 1:a0055b3280c8 | 93 | unsigned char temp = GETshort_or_long_tm(ptr->fields);\ |
shreeshas95 | 1:a0055b3280c8 | 94 | if((temp == 0) && (ptr->next_TM != NULL) ){\ |
shreeshas95 | 1:a0055b3280c8 | 95 | do{\ |
shreeshas95 | 1:a0055b3280c8 | 96 | ptr = ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 97 | temp = GETshort_or_long_tm(ptr->fields);\ |
shreeshas95 | 1:a0055b3280c8 | 98 | }\ |
shreeshas95 | 1:a0055b3280c8 | 99 | while(temp == 1 && ptr->next_TM != NULL);\ |
shreeshas95 | 1:a0055b3280c8 | 100 | if(temp == 1){\ |
shreeshas95 | 1:a0055b3280c8 | 101 | ptr = NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 102 | }\ |
shreeshas95 | 1:a0055b3280c8 | 103 | }\ |
shreeshas95 | 1:a0055b3280c8 | 104 | else if((temp == 1) && (ptr->next_TM != NULL)){\ |
shreeshas95 | 1:a0055b3280c8 | 105 | do{\ |
shreeshas95 | 1:a0055b3280c8 | 106 | ptr = ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 107 | temp = GETshort_or_long_tm(ptr->fields);\ |
shreeshas95 | 1:a0055b3280c8 | 108 | }\ |
shreeshas95 | 1:a0055b3280c8 | 109 | while(temp == 0 && ptr->next_TM != NULL);\ |
shreeshas95 | 1:a0055b3280c8 | 110 | if(temp == 0){\ |
ee12b079 | 9:e9eaada136c6 | 111 | ptr = NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 112 | }\ |
shreeshas95 | 1:a0055b3280c8 | 113 | }\ |
shreeshas95 | 1:a0055b3280c8 | 114 | else{\ |
ee12b079 | 9:e9eaada136c6 | 115 | ptr = NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 116 | }\ |
shreeshas95 | 1:a0055b3280c8 | 117 | } |
ee12b079 | 9:e9eaada136c6 | 118 | |
shreeshas95 | 1:a0055b3280c8 | 119 | /* |
shreeshas95 | 1:a0055b3280c8 | 120 | brief: take input type 0 or 1 and return the address of the first node in the list that have that type |
shreeshas95 | 1:a0055b3280c8 | 121 | parameter: type 0 or 1 |
ee12b079 | 9:e9eaada136c6 | 122 | return: pointer of the first node having same type |
shreeshas95 | 1:a0055b3280c8 | 123 | */ |
shreeshas95 | 1:a0055b3280c8 | 124 | // Base_tm* first_type_structure(int type){ |
shreeshas95 | 1:a0055b3280c8 | 125 | // Base_tm* temp_ptr = head_ptr; |
shreeshas95 | 1:a0055b3280c8 | 126 | // if(type == 0){ |
shreeshas95 | 1:a0055b3280c8 | 127 | // while(GETshort_or_long_tm(temp_ptr->fields) == 1){ |
shreeshas95 | 1:a0055b3280c8 | 128 | // temp_ptr = temp_ptr->next_TM; |
shreeshas95 | 1:a0055b3280c8 | 129 | // if(temp_ptr == NULL){ |
shreeshas95 | 1:a0055b3280c8 | 130 | // return NULL ; |
ee12b079 | 9:e9eaada136c6 | 131 | // } |
ee12b079 | 9:e9eaada136c6 | 132 | // } |
shreeshas95 | 1:a0055b3280c8 | 133 | // } |
shreeshas95 | 1:a0055b3280c8 | 134 | // else if(type == 1){ |
shreeshas95 | 1:a0055b3280c8 | 135 | // while(GETshort_or_long_tm(temp_ptr->fields) == 0){ |
shreeshas95 | 1:a0055b3280c8 | 136 | // temp_ptr = temp_ptr->next_TM; |
shreeshas95 | 1:a0055b3280c8 | 137 | // if(temp_ptr == NULL){ |
ee12b079 | 9:e9eaada136c6 | 138 | // return NULL; |
ee12b079 | 9:e9eaada136c6 | 139 | // } |
ee12b079 | 9:e9eaada136c6 | 140 | // } |
ee12b079 | 9:e9eaada136c6 | 141 | // } |
shreeshas95 | 1:a0055b3280c8 | 142 | // return temp_ptr; |
shreeshas95 | 1:a0055b3280c8 | 143 | // } |
ee12b079 | 9:e9eaada136c6 | 144 | |
ee12b079 | 9:e9eaada136c6 | 145 | |
shreeshas95 | 1:a0055b3280c8 | 146 | #define first_type_structure( type,return_ptr) {\ |
shreeshas95 | 1:a0055b3280c8 | 147 | Base_tm* temp_ptr = head_ptr;\ |
shreeshas95 | 1:a0055b3280c8 | 148 | if(type == 0){\ |
shreeshas95 | 1:a0055b3280c8 | 149 | while(GETshort_or_long_tm(temp_ptr->fields) == 1){\ |
shreeshas95 | 1:a0055b3280c8 | 150 | temp_ptr = temp_ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 151 | if(temp_ptr == NULL){\ |
shreeshas95 | 1:a0055b3280c8 | 152 | return_ptr = NULL ;\ |
shreeshas95 | 1:a0055b3280c8 | 153 | }\ |
shreeshas95 | 1:a0055b3280c8 | 154 | }\ |
shreeshas95 | 1:a0055b3280c8 | 155 | }\ |
shreeshas95 | 1:a0055b3280c8 | 156 | else if(type == 1){\ |
shreeshas95 | 1:a0055b3280c8 | 157 | while(GETshort_or_long_tm(temp_ptr->fields) == 0){\ |
shreeshas95 | 1:a0055b3280c8 | 158 | temp_ptr = temp_ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 159 | if(temp_ptr == NULL){\ |
shreeshas95 | 1:a0055b3280c8 | 160 | return_ptr = NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 161 | }\ |
shreeshas95 | 1:a0055b3280c8 | 162 | }\ |
shreeshas95 | 1:a0055b3280c8 | 163 | }\ |
shreeshas95 | 1:a0055b3280c8 | 164 | return_ptr = temp_ptr;\ |
shreeshas95 | 1:a0055b3280c8 | 165 | } |
ee12b079 | 9:e9eaada136c6 | 166 | |
ee12b079 | 9:e9eaada136c6 | 167 | |
ee12b079 | 9:e9eaada136c6 | 168 | |
shreeshas95 | 1:a0055b3280c8 | 169 | Base_tm *T1F_pointer ; |
shreeshas95 | 1:a0055b3280c8 | 170 | int T1F_counter; |
shreeshas95 | 1:a0055b3280c8 | 171 | unsigned char TMframe_type1[TM_FRAME_SIZE]; |
shreeshas95 | 1:a0055b3280c8 | 172 | bool type1_frame_flag; //should be true for every new list |
ee12b079 | 9:e9eaada136c6 | 173 | |
shreeshas95 | 1:a0055b3280c8 | 174 | #define type1_frame(ptr){\ |
shreeshas95 | 1:a0055b3280c8 | 175 | int i=4;\ |
shreeshas95 | 1:a0055b3280c8 | 176 | if(type1_frame_flag){\ |
shreeshas95 | 1:a0055b3280c8 | 177 | first_type_structure(1,T1F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 178 | T1F_counter = 0;\ |
shreeshas95 | 1:a0055b3280c8 | 179 | type1_frame_flag = false;\ |
shreeshas95 | 1:a0055b3280c8 | 180 | }\ |
shreeshas95 | 1:a0055b3280c8 | 181 | for(i = 4 ; (i < 134) && (T1F_pointer != NULL) ; i++){\ |
shreeshas95 | 1:a0055b3280c8 | 182 | TMframe_type1[i] = T1F_pointer->TM_string[T1F_counter];\ |
shreeshas95 | 1:a0055b3280c8 | 183 | if(T1F_counter++ == 12){\ |
shreeshas95 | 1:a0055b3280c8 | 184 | T1F_counter = 0;\ |
shreeshas95 | 1:a0055b3280c8 | 185 | next_type_structure(T1F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 186 | }\ |
shreeshas95 | 1:a0055b3280c8 | 187 | }\ |
shreeshas95 | 1:a0055b3280c8 | 188 | TMframe_type1[0] = 1<<7 + ( (i-4)/10 )<<3;\ |
shreeshas95 | 1:a0055b3280c8 | 189 | TMframe_type1[3] = crc16_gen(TMframe_type1,3);\ |
shreeshas95 | 1:a0055b3280c8 | 190 | if(T1F_pointer == NULL && i>12){\ |
shreeshas95 | 1:a0055b3280c8 | 191 | for( ; i < 134 ; i++){\ |
shreeshas95 | 1:a0055b3280c8 | 192 | TMframe_type1[i] = TMframe_type1[i-13];\ |
shreeshas95 | 1:a0055b3280c8 | 193 | }\ |
shreeshas95 | 1:a0055b3280c8 | 194 | }\ |
ee12b079 | 9:e9eaada136c6 | 195 | ptr=TMframe_type1;\ |
shreeshas95 | 1:a0055b3280c8 | 196 | } |
ee12b079 | 9:e9eaada136c6 | 197 | |
ee12b079 | 9:e9eaada136c6 | 198 | |
shreeshas95 | 1:a0055b3280c8 | 199 | // unsigned char * type1_frame(){ |
shreeshas95 | 1:a0055b3280c8 | 200 | // int i=4; |
shreeshas95 | 1:a0055b3280c8 | 201 | // if(type1_frame_flag){ |
shreeshas95 | 1:a0055b3280c8 | 202 | // T1F_pointer = first_type_structure(1); |
shreeshas95 | 1:a0055b3280c8 | 203 | // T1F_counter = 0; |
shreeshas95 | 1:a0055b3280c8 | 204 | // type1_frame_flag = false; |
shreeshas95 | 1:a0055b3280c8 | 205 | // } |
shreeshas95 | 1:a0055b3280c8 | 206 | // for(i = 4 ; (i < 134) && (T1F_pointer != NULL) ; i++){ |
shreeshas95 | 1:a0055b3280c8 | 207 | // TMframe_type1[i] = T1F_pointer->TM_string[T1F_counter]; |
shreeshas95 | 1:a0055b3280c8 | 208 | // if(T1F_counter++ == 12){ |
shreeshas95 | 1:a0055b3280c8 | 209 | // T1F_counter = 0; |
shreeshas95 | 1:a0055b3280c8 | 210 | // T1F_pointer = next_type_structure(T1F_pointer); |
shreeshas95 | 1:a0055b3280c8 | 211 | // } |
shreeshas95 | 1:a0055b3280c8 | 212 | // } |
shreeshas95 | 1:a0055b3280c8 | 213 | // // header |
shreeshas95 | 1:a0055b3280c8 | 214 | // TMframe_type1[0] = 1<<7 + ( (i-4)/10 )<<3; //( (i-4)/10 ) gives number of packets in the frame |
shreeshas95 | 1:a0055b3280c8 | 215 | // //insert time ; |
shreeshas95 | 1:a0055b3280c8 | 216 | // TMframe_type1[3] = CRC::crc16_gen(TMframe_type1,3); |
shreeshas95 | 1:a0055b3280c8 | 217 | // //end header |
shreeshas95 | 1:a0055b3280c8 | 218 | // if(T1F_pointer == NULL && i>12){ |
shreeshas95 | 1:a0055b3280c8 | 219 | // for( ; i < 134 ; i++){ //repeating ;ast packet to fill up the extra space |
ee12b079 | 9:e9eaada136c6 | 220 | // TMframe_type1[i] = TMframe_type1[i-13]; |
shreeshas95 | 1:a0055b3280c8 | 221 | // } |
shreeshas95 | 1:a0055b3280c8 | 222 | // } |
shreeshas95 | 1:a0055b3280c8 | 223 | // return TMframe_type1; |
shreeshas95 | 1:a0055b3280c8 | 224 | // } |
ee12b079 | 9:e9eaada136c6 | 225 | |
shreeshas95 | 1:a0055b3280c8 | 226 | bool type0_frame_flag; |
ee12b079 | 9:e9eaada136c6 | 227 | |
ee12b079 | 9:e9eaada136c6 | 228 | |
shreeshas95 | 1:a0055b3280c8 | 229 | #define type0_frame(ptr){\ |
shreeshas95 | 1:a0055b3280c8 | 230 | if(type0_frame_flag){\ |
shreeshas95 | 1:a0055b3280c8 | 231 | first_type_structure(0,T0F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 232 | type0_frame_flag = false;\ |
shreeshas95 | 1:a0055b3280c8 | 233 | }\ |
shreeshas95 | 1:a0055b3280c8 | 234 | else {\ |
shreeshas95 | 1:a0055b3280c8 | 235 | next_type_structure(T0F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 236 | }\ |
shreeshas95 | 1:a0055b3280c8 | 237 | ptr = T0F_pointer->TM_string;\ |
shreeshas95 | 1:a0055b3280c8 | 238 | } |
ee12b079 | 9:e9eaada136c6 | 239 | |
ee12b079 | 9:e9eaada136c6 | 240 | |
shreeshas95 | 1:a0055b3280c8 | 241 | // unsigned char* type0_frame(){ |
shreeshas95 | 1:a0055b3280c8 | 242 | // if(type0_frame_flag){ |
ee12b079 | 9:e9eaada136c6 | 243 | // T0F_pointer = first_type_structure(0); |
shreeshas95 | 1:a0055b3280c8 | 244 | // type0_frame_flag = false; |
ee12b079 | 9:e9eaada136c6 | 245 | // } |
shreeshas95 | 1:a0055b3280c8 | 246 | // else { |
shreeshas95 | 1:a0055b3280c8 | 247 | // T0F_pointer = next_type_structure(T0F_pointer); |
shreeshas95 | 1:a0055b3280c8 | 248 | // } |
shreeshas95 | 1:a0055b3280c8 | 249 | // return T0F_pointer->TM_string; |
shreeshas95 | 1:a0055b3280c8 | 250 | // } |
ee12b079 | 9:e9eaada136c6 | 251 | |
ee12b079 | 9:e9eaada136c6 | 252 | unsigned char convoluted_frame[270]; |
shreeshas95 | 1:a0055b3280c8 | 253 | Convolution ConvObj2; |
shreeshas95 | 1:a0055b3280c8 | 254 | void convolution (unsigned char * ptr){ |
shreeshas95 | 1:a0055b3280c8 | 255 | ConvObj2.convolutionEncode(ptr, convoluted_frame); |
shreeshas95 | 1:a0055b3280c8 | 256 | ConvObj2.convolutionEncode(ptr + 67, convoluted_frame + 135); |
shreeshas95 | 1:a0055b3280c8 | 257 | } |
ee12b079 | 9:e9eaada136c6 | 258 | |
ee12b079 | 9:e9eaada136c6 | 259 | |
ee12b079 | 9:e9eaada136c6 | 260 | unsigned char interleave_data[2][144]; |
shreeshas95 | 1:a0055b3280c8 | 261 | unsigned char DS_index; |
shreeshas95 | 1:a0055b3280c8 | 262 | bool DS_state; |
shreeshas95 | 1:a0055b3280c8 | 263 | int DS_counter; |
shreeshas95 | 1:a0055b3280c8 | 264 | bool DS_f; |
shreeshas95 | 1:a0055b3280c8 | 265 | bool make_DataStream_f; |
shreeshas95 | 1:a0055b3280c8 | 266 | // #define make_DataStream {\ |
shreeshas95 | 1:a0055b3280c8 | 267 | // unsigned char* ptr;\ |
shreeshas95 | 1:a0055b3280c8 | 268 | // if(make_DataStream_f == true){\ |
shreeshas95 | 1:a0055b3280c8 | 269 | // DS_state = true;\ |
shreeshas95 | 1:a0055b3280c8 | 270 | // DS_counter = 0;\ |
shreeshas95 | 1:a0055b3280c8 | 271 | // DS_f = false;\ |
shreeshas95 | 1:a0055b3280c8 | 272 | // make_DataStream_f = false;\ |
shreeshas95 | 1:a0055b3280c8 | 273 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 274 | // if(DS_state){\ |
shreeshas95 | 1:a0055b3280c8 | 275 | // if(DS_counter < total_frames-type0_no){\ |
shreeshas95 | 1:a0055b3280c8 | 276 | // type1_frame(ptr); \ |
shreeshas95 | 1:a0055b3280c8 | 277 | // DS_f = true;\ |
shreeshas95 | 1:a0055b3280c8 | 278 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 279 | // else if(DS_counter < total_frames ){\ |
shreeshas95 | 1:a0055b3280c8 | 280 | // type0_frame(ptr);\ |
shreeshas95 | 1:a0055b3280c8 | 281 | // DS_f = true;\ |
shreeshas95 | 1:a0055b3280c8 | 282 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 283 | // DS_counter++;\ |
shreeshas95 | 1:a0055b3280c8 | 284 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 285 | // DS_state = !DS_state;\ |
shreeshas95 | 1:a0055b3280c8 | 286 | // if (DS_f){\ |
shreeshas95 | 1:a0055b3280c8 | 287 | // DS_f = false;\ |
shreeshas95 | 1:a0055b3280c8 | 288 | // convolution(ptr);\ |
shreeshas95 | 1:a0055b3280c8 | 289 | // interleave(convoluted_frame,interleave_data[0]);\ |
shreeshas95 | 1:a0055b3280c8 | 290 | // interleave(convoluted_frame+ 135,interleave_data[1]);\ |
shreeshas95 | 1:a0055b3280c8 | 291 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 292 | // DS_index = (DS_state==true)?1:0;\ |
shreeshas95 | 1:a0055b3280c8 | 293 | // } |
ee12b079 | 9:e9eaada136c6 | 294 | |
ee12b079 | 9:e9eaada136c6 | 295 | #define make_DataStream {\ |
ee12b079 | 9:e9eaada136c6 | 296 | unsigned char* ptr;\ |
ee12b079 | 9:e9eaada136c6 | 297 | if(make_DataStream_f == true){\ |
ee12b079 | 9:e9eaada136c6 | 298 | DS_state = true;\ |
ee12b079 | 9:e9eaada136c6 | 299 | DS_counter = 0;\ |
ee12b079 | 9:e9eaada136c6 | 300 | DS_f = false;\ |
ee12b079 | 9:e9eaada136c6 | 301 | make_DataStream_f = false;\ |
ee12b079 | 9:e9eaada136c6 | 302 | }\ |
ee12b079 | 9:e9eaada136c6 | 303 | if(DS_state){\ |
ee12b079 | 9:e9eaada136c6 | 304 | if(DS_counter < total_frames-type0_no){\ |
ee12b079 | 9:e9eaada136c6 | 305 | type1_frame(ptr); \ |
ee12b079 | 9:e9eaada136c6 | 306 | DS_f = true;\ |
ee12b079 | 9:e9eaada136c6 | 307 | }\ |
ee12b079 | 9:e9eaada136c6 | 308 | else if(DS_counter < total_frames ){\ |
ee12b079 | 9:e9eaada136c6 | 309 | type0_frame(ptr);\ |
ee12b079 | 9:e9eaada136c6 | 310 | DS_f = true;\ |
ee12b079 | 9:e9eaada136c6 | 311 | }\ |
ee12b079 | 9:e9eaada136c6 | 312 | DS_counter++;\ |
ee12b079 | 9:e9eaada136c6 | 313 | }\ |
ee12b079 | 9:e9eaada136c6 | 314 | DS_state = !DS_state;\ |
ee12b079 | 9:e9eaada136c6 | 315 | if (DS_f){\ |
ee12b079 | 9:e9eaada136c6 | 316 | DS_f = false;\ |
ee12b079 | 9:e9eaada136c6 | 317 | convolution(ptr);\ |
ee12b079 | 9:e9eaada136c6 | 318 | interleave(convoluted_frame,interleave_data[0]);\ |
ee12b079 | 9:e9eaada136c6 | 319 | interleave(convoluted_frame+ 135,interleave_data[1]);}\ |
ee12b079 | 9:e9eaada136c6 | 320 | DS_index = (DS_state==true)?1:0;\ |
ee12b079 | 9:e9eaada136c6 | 321 | } |
ee12b079 | 9:e9eaada136c6 | 322 | |
ee12b079 | 9:e9eaada136c6 | 323 | |
ee12b079 | 9:e9eaada136c6 | 324 | // |
shreeshas95 | 1:a0055b3280c8 | 325 | public: |
ee12b079 | 9:e9eaada136c6 | 326 | |
shreeshas95 | 1:a0055b3280c8 | 327 | bool reset_adf; |
shreeshas95 | 1:a0055b3280c8 | 328 | SND_TM(){ |
rohit3342 | 11:83acbe8e0ad1 | 329 | MAX_SEGMENT = (MAX_ADF_LEN-EOS_SIZE)/( S_FRAME_SIZE + ISR*T_FRAME_SIZE); |
ee12b079 | 9:e9eaada136c6 | 330 | //MAX_SEGMENT = 1; |
ee12b079 | 9:e9eaada136c6 | 331 | //(max length - eos size)/(sframe length + tFrameLength*ISR) |
shreeshas95 | 1:a0055b3280c8 | 332 | // cout<<int(MAX_SEGMENT)<<endl; |
shreeshas95 | 1:a0055b3280c8 | 333 | } |
ee12b079 | 9:e9eaada136c6 | 334 | |
shreeshas95 | 1:a0055b3280c8 | 335 | |
ee12b079 | 9:e9eaada136c6 | 336 | |
shreeshas95 | 1:a0055b3280c8 | 337 | void head_pointer(Base_tm* ptr){ |
shreeshas95 | 1:a0055b3280c8 | 338 | head_ptr = ptr ; |
shreeshas95 | 1:a0055b3280c8 | 339 | type1_frame_flag = true; |
shreeshas95 | 1:a0055b3280c8 | 340 | type0_frame_flag = true; |
shreeshas95 | 1:a0055b3280c8 | 341 | make_DataStream_f = true; |
shreeshas95 | 1:a0055b3280c8 | 342 | transmit_data_f = true; |
shreeshas95 | 1:a0055b3280c8 | 343 | diff_prev = 0; |
shreeshas95 | 1:a0055b3280c8 | 344 | data_number(); |
ee12b079 | 9:e9eaada136c6 | 345 | // make_DataStream; |
ee12b079 | 9:e9eaada136c6 | 346 | // gPC.putc('z'); |
shreeshas95 | 1:a0055b3280c8 | 347 | } |
ee12b079 | 9:e9eaada136c6 | 348 | |
ee12b079 | 9:e9eaada136c6 | 349 | |
shreeshas95 | 1:a0055b3280c8 | 350 | void inline transmit_data(unsigned char * transmit , bool * last_buffer){ |
shreeshas95 | 1:a0055b3280c8 | 351 | if(transmit_data_f){ |
shreeshas95 | 1:a0055b3280c8 | 352 | RB_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 353 | Sframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 354 | SCH40_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 355 | FCCH80_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 356 | Tframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 357 | EOS_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 358 | segment_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 359 | data_c = 0; |
ee12b079 | 9:e9eaada136c6 | 360 | |
shreeshas95 | 1:a0055b3280c8 | 361 | Sframe = true; |
shreeshas95 | 1:a0055b3280c8 | 362 | SCH40_f = false; |
shreeshas95 | 1:a0055b3280c8 | 363 | data_f = false; |
shreeshas95 | 1:a0055b3280c8 | 364 | FCCH80_f = false; |
shreeshas95 | 1:a0055b3280c8 | 365 | transmit_data_f = false; |
shreeshas95 | 1:a0055b3280c8 | 366 | reset_adf = false; |
shreeshas95 | 1:a0055b3280c8 | 367 | *last_buffer = false; |
shreeshas95 | 1:a0055b3280c8 | 368 | } |
ee12b079 | 9:e9eaada136c6 | 369 | |
shreeshas95 | 1:a0055b3280c8 | 370 | for(RB_c = 0 ; RB_c<112 ; RB_c++){ |
ee12b079 | 9:e9eaada136c6 | 371 | |
ee12b079 | 9:e9eaada136c6 | 372 | if(junk_f || *last_buffer){ |
ee12b079 | 9:e9eaada136c6 | 373 | transmit[RB_c] = 0x00; |
ee12b079 | 9:e9eaada136c6 | 374 | continue; |
shreeshas95 | 1:a0055b3280c8 | 375 | } |
ee12b079 | 9:e9eaada136c6 | 376 | |
shreeshas95 | 1:a0055b3280c8 | 377 | if(Sframe){ |
shreeshas95 | 1:a0055b3280c8 | 378 | transmit[RB_c] = S_frame[Sframe_c++]; |
shreeshas95 | 1:a0055b3280c8 | 379 | if(Sframe_c == 48){ |
shreeshas95 | 1:a0055b3280c8 | 380 | // printf("exit s frame\n"); |
shreeshas95 | 1:a0055b3280c8 | 381 | Sframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 382 | Sframe = false; |
shreeshas95 | 1:a0055b3280c8 | 383 | SCH40_f =true; |
shreeshas95 | 1:a0055b3280c8 | 384 | } |
shreeshas95 | 1:a0055b3280c8 | 385 | continue; |
shreeshas95 | 1:a0055b3280c8 | 386 | } |
ee12b079 | 9:e9eaada136c6 | 387 | // |
shreeshas95 | 1:a0055b3280c8 | 388 | if(SCH40_f){ |
ee12b079 | 9:e9eaada136c6 | 389 | transmit[RB_c] = SCH40[SCH40_c++]; |
shreeshas95 | 1:a0055b3280c8 | 390 | if(SCH40_c == 5 ){ |
shreeshas95 | 1:a0055b3280c8 | 391 | SCH40_c = 0; |
ee12b079 | 9:e9eaada136c6 | 392 | SCH40_f = false; |
ee12b079 | 9:e9eaada136c6 | 393 | |
ee12b079 | 9:e9eaada136c6 | 394 | |
ee12b079 | 9:e9eaada136c6 | 395 | if(Tframe_c >= LAST_SEGMENT_SIZE && segment_r == 0) |
ee12b079 | 9:e9eaada136c6 | 396 | { |
ee12b079 | 9:e9eaada136c6 | 397 | repeat_data_f = true; |
ee12b079 | 9:e9eaada136c6 | 398 | DS_index = !DS_index; |
ee12b079 | 9:e9eaada136c6 | 399 | } |
ee12b079 | 9:e9eaada136c6 | 400 | else |
ee12b079 | 9:e9eaada136c6 | 401 | { |
ee12b079 | 9:e9eaada136c6 | 402 | data_f = true; |
ee12b079 | 9:e9eaada136c6 | 403 | make_DataStream; |
ee12b079 | 9:e9eaada136c6 | 404 | } |
shreeshas95 | 1:a0055b3280c8 | 405 | // printf("exit SCH40 frame\n"); |
shreeshas95 | 1:a0055b3280c8 | 406 | } |
shreeshas95 | 1:a0055b3280c8 | 407 | continue; |
shreeshas95 | 1:a0055b3280c8 | 408 | } |
ee12b079 | 9:e9eaada136c6 | 409 | // |
shreeshas95 | 1:a0055b3280c8 | 410 | if(data_f){ |
shreeshas95 | 1:a0055b3280c8 | 411 | transmit[RB_c] = interleave_data[DS_index][data_c++]; |
shreeshas95 | 1:a0055b3280c8 | 412 | if(data_c == 144){ |
shreeshas95 | 1:a0055b3280c8 | 413 | data_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 414 | FCCH80_f = true; |
shreeshas95 | 1:a0055b3280c8 | 415 | data_f = false; |
shreeshas95 | 1:a0055b3280c8 | 416 | // printf("exit Data\n"); |
shreeshas95 | 1:a0055b3280c8 | 417 | } |
shreeshas95 | 1:a0055b3280c8 | 418 | continue; |
shreeshas95 | 1:a0055b3280c8 | 419 | } |
ee12b079 | 9:e9eaada136c6 | 420 | if(repeat_data_f){ |
ee12b079 | 9:e9eaada136c6 | 421 | transmit[RB_c] = interleave_data[DS_index][data_c++]; |
ee12b079 | 9:e9eaada136c6 | 422 | if(data_c == 144){ |
ee12b079 | 9:e9eaada136c6 | 423 | data_c = 0; |
ee12b079 | 9:e9eaada136c6 | 424 | FCCH80_f = true; |
ee12b079 | 9:e9eaada136c6 | 425 | repeat_data_f = false; |
ee12b079 | 9:e9eaada136c6 | 426 | // printf("exit Data\n"); |
ee12b079 | 9:e9eaada136c6 | 427 | } |
ee12b079 | 9:e9eaada136c6 | 428 | continue; |
ee12b079 | 9:e9eaada136c6 | 429 | } |
ee12b079 | 9:e9eaada136c6 | 430 | |
shreeshas95 | 1:a0055b3280c8 | 431 | if(FCCH80_f){ |
shreeshas95 | 1:a0055b3280c8 | 432 | transmit[RB_c] = FCCH80[FCCH80_c++]; |
shreeshas95 | 1:a0055b3280c8 | 433 | if(FCCH80_c == 10){ |
shreeshas95 | 1:a0055b3280c8 | 434 | FCCH80_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 435 | FCCH80_f = false; |
shreeshas95 | 1:a0055b3280c8 | 436 | // printf("exit FCCH80\n"); |
shreeshas95 | 1:a0055b3280c8 | 437 | if(++Tframe_c != ISR) |
ee12b079 | 9:e9eaada136c6 | 438 | SCH40_f = true; |
shreeshas95 | 1:a0055b3280c8 | 439 | else{ |
shreeshas95 | 1:a0055b3280c8 | 440 | Tframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 441 | segment_c++; |
ee12b079 | 9:e9eaada136c6 | 442 | if(segment_c == SEGMENT_NO) |
shreeshas95 | 1:a0055b3280c8 | 443 | {eos_f = true;} |
shreeshas95 | 1:a0055b3280c8 | 444 | else{ |
shreeshas95 | 1:a0055b3280c8 | 445 | Sframe = true; |
shreeshas95 | 1:a0055b3280c8 | 446 | } |
shreeshas95 | 1:a0055b3280c8 | 447 | } |
shreeshas95 | 1:a0055b3280c8 | 448 | } |
shreeshas95 | 1:a0055b3280c8 | 449 | continue; |
ee12b079 | 9:e9eaada136c6 | 450 | } |
ee12b079 | 9:e9eaada136c6 | 451 | |
ee12b079 | 9:e9eaada136c6 | 452 | if(eos_f){ |
shreeshas95 | 1:a0055b3280c8 | 453 | transmit[RB_c] = EoS[EOS_c++]; |
shreeshas95 | 1:a0055b3280c8 | 454 | if(EOS_c == EOS_SIZE){ |
shreeshas95 | 1:a0055b3280c8 | 455 | EOS_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 456 | eos_f = false; |
shreeshas95 | 1:a0055b3280c8 | 457 | // printf("exit EOS\n"); |
ee12b079 | 9:e9eaada136c6 | 458 | // if(segment_c == MAX_SEGMENT){ |
ee12b079 | 9:e9eaada136c6 | 459 | // segment_c = 0; |
ee12b079 | 9:e9eaada136c6 | 460 | // SEGMENT_NO = SEGMENT_NO - MAX_SEGMENT; |
ee12b079 | 9:e9eaada136c6 | 461 | // reset_adf = true;//what does this do?? |
ee12b079 | 9:e9eaada136c6 | 462 | // Sframe = true; |
ee12b079 | 9:e9eaada136c6 | 463 | // }else{ |
ee12b079 | 9:e9eaada136c6 | 464 | // *last_buffer = true; |
ee12b079 | 9:e9eaada136c6 | 465 | // } |
ee12b079 | 9:e9eaada136c6 | 466 | if(segment_c == SEGMENT_NO && segment_r == 0){ |
ee12b079 | 9:e9eaada136c6 | 467 | *last_buffer = true; |
ee12b079 | 9:e9eaada136c6 | 468 | } |
ee12b079 | 9:e9eaada136c6 | 469 | else if(segment_c == SEGMENT_NO && segment_r != 0){ |
ee12b079 | 9:e9eaada136c6 | 470 | segment_c = 0; |
ee12b079 | 9:e9eaada136c6 | 471 | SEGMENT_NO = TOTAL_SEGMENT_NO; |
ee12b079 | 9:e9eaada136c6 | 472 | if(SEGMENT_NO > MAX_SEGMENT) |
ee12b079 | 9:e9eaada136c6 | 473 | { |
ee12b079 | 9:e9eaada136c6 | 474 | SEGMENT_NO = MAX_SEGMENT; |
ee12b079 | 9:e9eaada136c6 | 475 | segment_r = 1; |
ee12b079 | 9:e9eaada136c6 | 476 | } |
ee12b079 | 9:e9eaada136c6 | 477 | else segment_r = 0; |
ee12b079 | 9:e9eaada136c6 | 478 | TOTAL_SEGMENT_NO -= SEGMENT_NO; |
ee12b079 | 9:e9eaada136c6 | 479 | reset_adf = true;//what does this do?? |
ee12b079 | 9:e9eaada136c6 | 480 | Sframe = true; |
ee12b079 | 9:e9eaada136c6 | 481 | } |
shreeshas95 | 1:a0055b3280c8 | 482 | junk_f = true; |
shreeshas95 | 1:a0055b3280c8 | 483 | } |
shreeshas95 | 1:a0055b3280c8 | 484 | continue; |
ee12b079 | 9:e9eaada136c6 | 485 | } |
shreeshas95 | 1:a0055b3280c8 | 486 | } |
shreeshas95 | 1:a0055b3280c8 | 487 | differential_encode(transmit,112); |
shreeshas95 | 1:a0055b3280c8 | 488 | if(reset_adf == true){ |
shreeshas95 | 1:a0055b3280c8 | 489 | diff_prev = 0; |
shreeshas95 | 1:a0055b3280c8 | 490 | junk_f = false; |
shreeshas95 | 1:a0055b3280c8 | 491 | } |
ee12b079 | 9:e9eaada136c6 | 492 | |
shreeshas95 | 1:a0055b3280c8 | 493 | } |
ee12b079 | 9:e9eaada136c6 | 494 | |
shreeshas95 | 1:a0055b3280c8 | 495 | }; |
shreeshas95 | 1:a0055b3280c8 | 496 | SND_TM snd_tm; |