Changes: bbram Checking Function Registers Checking Funcrtion Indivisual Register checking Functions

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
ee12b079
Date:
Fri Jan 15 13:51:47 2016 +0000
Revision:
61:15a5dfe84945
Parent:
59:29a37f943ba6
Child:
63:4d13680673bc
Bypassing adf works, but crc failed is shows up for short tc headers

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aniruddhv 52:0bd68655c651 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};
aniruddhv 52:0bd68655c651 14 const unsigned char EXOR_SEQ[] = {0x55,0xF1,0x51,0x3D,0xA7,0x42,0xAE,0x2E,0x2E,0x28,0x76,0x80,0x62,0x41,0xC4,0x75,0x4D,0x87,0xDB,0xE1,0x02,0x61,0x60,0x96,0x9C,0xCB,0x8A,0xBD,0x37,0xE4,0x72,0x5D,0xF2,0x19,0x62,0x06,0x9A,0xF9,0x38,0xB0,0x49,0x75,0xD0,0x17,0x1B,0xCC,0x0B,0xEB,0x1B,0x50,0xA2,0x2A,0x8E,0xFA,0x4D,0x6F,0x1B,0xF8,0x0F,0x97,0x39,0x25,0x60,0x55,0x9A,0xDF,0x1D,0x10,0x7F,0xBD,0x3E,0xBF,0xE5,0x68,0x02,0xD1,0x99,0x0D,0xDF,0x84,0x2E,0x15,0xE3,0x08,0xD7,0x44,0x10,0x41,0xCE,0x93,0xF6,0x59,0x71,0xD2,0xF7,0x1C,0x4A,0x44,0x2D,0xA9,0x44,0x98,0x3A,0x00,0x71,0xCC,0x2A,0x35,0xC1,0x81,0xCF,0x44,0xF7,0x6A,0x0E,0xE4,0xF2,0xFC,0xD6,0x0B,0xA8,0x95,0x7B,0x86,0xB5,0xF8,0x33,0xE9,0xBF,0x6A,0x0E,0xE6,0x53,0x82};
ee12b079 57:bf998cb2a104 15
ee12b079 57:bf998cb2a104 16 #define print_tm(ptr) { for(int i=0 ; i<134; i++ ) gPC.putc(ptr[i]);}
ee12b079 9:e9eaada136c6 17
shreeshas95 1:a0055b3280c8 18 class SND_TM{
ee12b079 9:e9eaada136c6 19
ee12b079 9:e9eaada136c6 20 Base_tm * head_ptr;
ee12b079 9:e9eaada136c6 21
shreeshas95 1:a0055b3280c8 22 // transmit data variables
shreeshas95 1:a0055b3280c8 23 unsigned char Tframe_c; //_c represents counter, counts Tframe written in a segment
shreeshas95 1:a0055b3280c8 24 unsigned char EOS_c; //count no of bytes of eos have been weitten in the rolling buffer
shreeshas95 1:a0055b3280c8 25 unsigned char Sframe_c; //count no of bytes of Sframe have been weitten in the rolling buffer
shreeshas95 1:a0055b3280c8 26 unsigned char SCH40_c; //count no of bytes of SCH40 have been weitten in the rolling buffer
shreeshas95 1:a0055b3280c8 27 unsigned char data_c;
shreeshas95 1:a0055b3280c8 28 unsigned char FCCH80_c;
shreeshas95 1:a0055b3280c8 29 unsigned char RB_c; //rolling buffer counter
shreeshas95 1:a0055b3280c8 30 unsigned char segment_c; //counts the numver of segments sent
shreeshas95 1:a0055b3280c8 31 unsigned char MAX_SEGMENT;
shreeshas95 1:a0055b3280c8 32 bool Sframe; //Sframe = 1bit of CF1
shreeshas95 1:a0055b3280c8 33 bool SCH40_f;
shreeshas95 1:a0055b3280c8 34 bool FCCH80_f;
shreeshas95 1:a0055b3280c8 35 bool data_f;
ee12b079 9:e9eaada136c6 36 bool repeat_data_f;
shreeshas95 1:a0055b3280c8 37 bool transmit_data_f;
shreeshas95 1:a0055b3280c8 38 bool eos_f;
shreeshas95 1:a0055b3280c8 39 bool junk_f;
ee12b079 9:e9eaada136c6 40 bool segment_r; //flag checking if more sessions are required
ee12b079 9:e9eaada136c6 41
ee12b079 9:e9eaada136c6 42
shreeshas95 1:a0055b3280c8 43 // type 1 frame
ee12b079 9:e9eaada136c6 44
shreeshas95 1:a0055b3280c8 45 Base_tm *T0F_pointer ;
ee12b079 9:e9eaada136c6 46
shreeshas95 1:a0055b3280c8 47 int diff_prev;
shreeshas95 1:a0055b3280c8 48 void differential_encode(unsigned char* ptr, int length){
shreeshas95 1:a0055b3280c8 49 for(int i=0; i<length;i++){
shreeshas95 1:a0055b3280c8 50 unsigned char s = ptr[i] , t;
shreeshas95 1:a0055b3280c8 51 t = s ^ (s >> 1);
shreeshas95 1:a0055b3280c8 52 (diff_prev == 0) ? t=t^0x00 : t=t^0x80 ;
shreeshas95 1:a0055b3280c8 53 diff_prev = int(s & 0x01);
shreeshas95 1:a0055b3280c8 54 ptr[i] = t;
shreeshas95 1:a0055b3280c8 55 }
ee12b079 9:e9eaada136c6 56 }
ee12b079 9:e9eaada136c6 57
shreeshas95 1:a0055b3280c8 58 int type0_no; //number of type zero frames
ee12b079 9:e9eaada136c6 59 int type1_no;
shreeshas95 1:a0055b3280c8 60 int total_frames; //number of type one packe (TMP)
shreeshas95 1:a0055b3280c8 61 int SEGMENT_NO; //number of type one packe (TMP)
ee12b079 9:e9eaada136c6 62 int TOTAL_SEGMENT_NO;
ee12b079 9:e9eaada136c6 63 int LAST_SEGMENT_SIZE;
shreeshas95 1:a0055b3280c8 64 void inline data_number(){
shreeshas95 1:a0055b3280c8 65 int type1_frame_no;
shreeshas95 1:a0055b3280c8 66 Base_tm*head = head_ptr;
shreeshas95 1:a0055b3280c8 67 type0_no = 0;
shreeshas95 1:a0055b3280c8 68 type1_no = 0;
aniruddhv 52:0bd68655c651 69 while(head != NULL){
shreeshas95 1:a0055b3280c8 70 switch( GETshort_or_long_tm(head->fields) ){
shreeshas95 1:a0055b3280c8 71 case 0:
shreeshas95 1:a0055b3280c8 72 type0_no++;
shreeshas95 1:a0055b3280c8 73 break;
shreeshas95 1:a0055b3280c8 74 case 1:
shreeshas95 1:a0055b3280c8 75 type1_no++;
shreeshas95 1:a0055b3280c8 76 break;
shreeshas95 1:a0055b3280c8 77 }
ee12b079 9:e9eaada136c6 78
shreeshas95 1:a0055b3280c8 79 head=head->next_TM;
shreeshas95 1:a0055b3280c8 80 }
shreeshas95 1:a0055b3280c8 81 type1_frame_no = ( type1_no % 10 == 0 )? (type1_no / 10) : ( (type1_no / 10) + 1);
shreeshas95 1:a0055b3280c8 82 total_frames = type0_no + type1_frame_no ;
ee12b079 9:e9eaada136c6 83 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 84 SEGMENT_NO = TOTAL_SEGMENT_NO;
ee12b079 9:e9eaada136c6 85 if(SEGMENT_NO > MAX_SEGMENT)
ee12b079 9:e9eaada136c6 86 {
ee12b079 9:e9eaada136c6 87 SEGMENT_NO = MAX_SEGMENT;
ee12b079 9:e9eaada136c6 88 }
aniruddhv 52:0bd68655c651 89 if(SEGMENT_NO == 1) segment_r = 0; else segment_r = 1;
ee12b079 9:e9eaada136c6 90 TOTAL_SEGMENT_NO -= SEGMENT_NO;
aniruddhv 52:0bd68655c651 91 LAST_SEGMENT_SIZE = total_frames*2%ISR?total_frames*2%ISR:ISR;
shreeshas95 1:a0055b3280c8 92 }
ee12b079 9:e9eaada136c6 93
shreeshas95 1:a0055b3280c8 94 #define next_type_structure(ptr){\
shreeshas95 1:a0055b3280c8 95 unsigned char temp = GETshort_or_long_tm(ptr->fields);\
shreeshas95 1:a0055b3280c8 96 if((temp == 0) && (ptr->next_TM != NULL) ){\
shreeshas95 1:a0055b3280c8 97 do{\
shreeshas95 1:a0055b3280c8 98 ptr = ptr->next_TM;\
shreeshas95 1:a0055b3280c8 99 temp = GETshort_or_long_tm(ptr->fields);\
shreeshas95 1:a0055b3280c8 100 }\
shreeshas95 1:a0055b3280c8 101 while(temp == 1 && ptr->next_TM != NULL);\
shreeshas95 1:a0055b3280c8 102 if(temp == 1){\
shreeshas95 1:a0055b3280c8 103 ptr = NULL;\
shreeshas95 1:a0055b3280c8 104 }\
shreeshas95 1:a0055b3280c8 105 }\
shreeshas95 1:a0055b3280c8 106 else if((temp == 1) && (ptr->next_TM != NULL)){\
shreeshas95 1:a0055b3280c8 107 do{\
shreeshas95 1:a0055b3280c8 108 ptr = ptr->next_TM;\
shreeshas95 1:a0055b3280c8 109 temp = GETshort_or_long_tm(ptr->fields);\
shreeshas95 1:a0055b3280c8 110 }\
shreeshas95 1:a0055b3280c8 111 while(temp == 0 && ptr->next_TM != NULL);\
shreeshas95 1:a0055b3280c8 112 if(temp == 0){\
ee12b079 9:e9eaada136c6 113 ptr = NULL;\
shreeshas95 1:a0055b3280c8 114 }\
shreeshas95 1:a0055b3280c8 115 }\
shreeshas95 1:a0055b3280c8 116 else{\
ee12b079 9:e9eaada136c6 117 ptr = NULL;\
shreeshas95 1:a0055b3280c8 118 }\
shreeshas95 1:a0055b3280c8 119 }
ee12b079 9:e9eaada136c6 120
shreeshas95 1:a0055b3280c8 121 /*
shreeshas95 1:a0055b3280c8 122 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 123 parameter: type 0 or 1
ee12b079 9:e9eaada136c6 124 return: pointer of the first node having same type
shreeshas95 1:a0055b3280c8 125 */
aniruddhv 52:0bd68655c651 126 #define exor(ptr) { for(int i=0 ; i<134; i++ ) ptr[i]=ptr[i]^EXOR_SEQ[i];}
ee12b079 57:bf998cb2a104 127
ee12b079 9:e9eaada136c6 128
ee12b079 9:e9eaada136c6 129
shreeshas95 1:a0055b3280c8 130 #define first_type_structure( type,return_ptr) {\
shreeshas95 1:a0055b3280c8 131 Base_tm* temp_ptr = head_ptr;\
shreeshas95 1:a0055b3280c8 132 if(type == 0){\
shreeshas95 1:a0055b3280c8 133 while(GETshort_or_long_tm(temp_ptr->fields) == 1){\
shreeshas95 1:a0055b3280c8 134 temp_ptr = temp_ptr->next_TM;\
shreeshas95 1:a0055b3280c8 135 if(temp_ptr == NULL){\
shreeshas95 1:a0055b3280c8 136 return_ptr = NULL ;\
shreeshas95 1:a0055b3280c8 137 }\
shreeshas95 1:a0055b3280c8 138 }\
shreeshas95 1:a0055b3280c8 139 }\
shreeshas95 1:a0055b3280c8 140 else if(type == 1){\
shreeshas95 1:a0055b3280c8 141 while(GETshort_or_long_tm(temp_ptr->fields) == 0){\
shreeshas95 1:a0055b3280c8 142 temp_ptr = temp_ptr->next_TM;\
shreeshas95 1:a0055b3280c8 143 if(temp_ptr == NULL){\
shreeshas95 1:a0055b3280c8 144 return_ptr = NULL;\
shreeshas95 1:a0055b3280c8 145 }\
shreeshas95 1:a0055b3280c8 146 }\
shreeshas95 1:a0055b3280c8 147 }\
shreeshas95 1:a0055b3280c8 148 return_ptr = temp_ptr;\
shreeshas95 1:a0055b3280c8 149 }
ee12b079 9:e9eaada136c6 150
ee12b079 9:e9eaada136c6 151
ee12b079 9:e9eaada136c6 152
shreeshas95 1:a0055b3280c8 153 Base_tm *T1F_pointer ;
shreeshas95 1:a0055b3280c8 154 int T1F_counter;
shreeshas95 1:a0055b3280c8 155 unsigned char TMframe_type1[TM_FRAME_SIZE];
shreeshas95 1:a0055b3280c8 156 bool type1_frame_flag; //should be true for every new list
ee12b079 9:e9eaada136c6 157
shreeshas95 1:a0055b3280c8 158 #define type1_frame(ptr){\
shreeshas95 1:a0055b3280c8 159 int i=4;\
shreeshas95 1:a0055b3280c8 160 if(type1_frame_flag){\
shreeshas95 1:a0055b3280c8 161 first_type_structure(1,T1F_pointer);\
shreeshas95 1:a0055b3280c8 162 T1F_counter = 0;\
shreeshas95 1:a0055b3280c8 163 type1_frame_flag = false;\
shreeshas95 1:a0055b3280c8 164 }\
shreeshas95 1:a0055b3280c8 165 for(i = 4 ; (i < 134) && (T1F_pointer != NULL) ; i++){\
shreeshas95 1:a0055b3280c8 166 TMframe_type1[i] = T1F_pointer->TM_string[T1F_counter];\
shreeshas95 1:a0055b3280c8 167 if(T1F_counter++ == 12){\
shreeshas95 1:a0055b3280c8 168 T1F_counter = 0;\
shreeshas95 1:a0055b3280c8 169 next_type_structure(T1F_pointer);\
shreeshas95 1:a0055b3280c8 170 }\
shreeshas95 1:a0055b3280c8 171 }\
aniruddhv 52:0bd68655c651 172 TMframe_type1[0] = (1<<7) + (( (i-4)/13 )<<3);\
shreeshas95 1:a0055b3280c8 173 TMframe_type1[3] = crc16_gen(TMframe_type1,3);\
shreeshas95 1:a0055b3280c8 174 if(T1F_pointer == NULL && i>12){\
shreeshas95 1:a0055b3280c8 175 for( ; i < 134 ; i++){\
shreeshas95 1:a0055b3280c8 176 TMframe_type1[i] = TMframe_type1[i-13];\
shreeshas95 1:a0055b3280c8 177 }\
shreeshas95 1:a0055b3280c8 178 }\
ee12b079 9:e9eaada136c6 179 ptr=TMframe_type1;\
shreeshas95 1:a0055b3280c8 180 }
ee12b079 9:e9eaada136c6 181
ee12b079 9:e9eaada136c6 182
shreeshas95 1:a0055b3280c8 183 bool type0_frame_flag;
ee12b079 9:e9eaada136c6 184
ee12b079 9:e9eaada136c6 185
shreeshas95 1:a0055b3280c8 186 #define type0_frame(ptr){\
shreeshas95 1:a0055b3280c8 187 if(type0_frame_flag){\
shreeshas95 1:a0055b3280c8 188 first_type_structure(0,T0F_pointer);\
shreeshas95 1:a0055b3280c8 189 type0_frame_flag = false;\
shreeshas95 1:a0055b3280c8 190 }\
shreeshas95 1:a0055b3280c8 191 else {\
shreeshas95 1:a0055b3280c8 192 next_type_structure(T0F_pointer);\
shreeshas95 1:a0055b3280c8 193 }\
shreeshas95 1:a0055b3280c8 194 ptr = T0F_pointer->TM_string;\
shreeshas95 1:a0055b3280c8 195 }
ee12b079 53:18db568f1098 196
ee12b079 9:e9eaada136c6 197 unsigned char convoluted_frame[270];
shreeshas95 1:a0055b3280c8 198 Convolution ConvObj2;
shreeshas95 1:a0055b3280c8 199 void convolution (unsigned char * ptr){
shreeshas95 1:a0055b3280c8 200 ConvObj2.convolutionEncode(ptr, convoluted_frame);
shreeshas95 1:a0055b3280c8 201 ConvObj2.convolutionEncode(ptr + 67, convoluted_frame + 135);
shreeshas95 1:a0055b3280c8 202 }
ee12b079 9:e9eaada136c6 203
ee12b079 9:e9eaada136c6 204
ee12b079 9:e9eaada136c6 205 unsigned char interleave_data[2][144];
shreeshas95 1:a0055b3280c8 206 unsigned char DS_index;
shreeshas95 1:a0055b3280c8 207 bool DS_state;
shreeshas95 1:a0055b3280c8 208 int DS_counter;
shreeshas95 1:a0055b3280c8 209 bool DS_f;
shreeshas95 1:a0055b3280c8 210 bool make_DataStream_f;
ee12b079 9:e9eaada136c6 211
ee12b079 9:e9eaada136c6 212 #define make_DataStream {\
ee12b079 9:e9eaada136c6 213 unsigned char* ptr;\
ee12b079 9:e9eaada136c6 214 if(make_DataStream_f == true){\
ee12b079 9:e9eaada136c6 215 DS_state = true;\
ee12b079 9:e9eaada136c6 216 DS_counter = 0;\
ee12b079 9:e9eaada136c6 217 DS_f = false;\
ee12b079 9:e9eaada136c6 218 make_DataStream_f = false;\
ee12b079 9:e9eaada136c6 219 }\
ee12b079 9:e9eaada136c6 220 if(DS_state){\
ee12b079 9:e9eaada136c6 221 if(DS_counter < total_frames-type0_no){\
ee12b079 9:e9eaada136c6 222 type1_frame(ptr); \
ee12b079 9:e9eaada136c6 223 DS_f = true;\
ee12b079 9:e9eaada136c6 224 }\
ee12b079 9:e9eaada136c6 225 else if(DS_counter < total_frames ){\
ee12b079 9:e9eaada136c6 226 type0_frame(ptr);\
ee12b079 9:e9eaada136c6 227 DS_f = true;\
ee12b079 9:e9eaada136c6 228 }\
ee12b079 9:e9eaada136c6 229 DS_counter++;\
ee12b079 9:e9eaada136c6 230 }\
ee12b079 9:e9eaada136c6 231 DS_state = !DS_state;\
ee12b079 9:e9eaada136c6 232 if (DS_f){\
ee12b079 9:e9eaada136c6 233 DS_f = false;\
ee12b079 61:15a5dfe84945 234 if(bypass_adf == 1)\
ee12b079 57:bf998cb2a104 235 print_tm(ptr);\
aniruddhv 52:0bd68655c651 236 exor(ptr);\
ee12b079 9:e9eaada136c6 237 convolution(ptr);\
ee12b079 9:e9eaada136c6 238 interleave(convoluted_frame,interleave_data[0]);\
ee12b079 9:e9eaada136c6 239 interleave(convoluted_frame+ 135,interleave_data[1]);}\
ee12b079 9:e9eaada136c6 240 DS_index = (DS_state==true)?1:0;\
ee12b079 9:e9eaada136c6 241 }
ee12b079 9:e9eaada136c6 242
ee12b079 9:e9eaada136c6 243
ee12b079 9:e9eaada136c6 244 //
shreeshas95 1:a0055b3280c8 245 public:
ee12b079 9:e9eaada136c6 246
shreeshas95 1:a0055b3280c8 247 bool reset_adf;
shreeshas95 1:a0055b3280c8 248 SND_TM(){
rohit3342 11:83acbe8e0ad1 249 MAX_SEGMENT = (MAX_ADF_LEN-EOS_SIZE)/( S_FRAME_SIZE + ISR*T_FRAME_SIZE);
ee12b079 9:e9eaada136c6 250 //(max length - eos size)/(sframe length + tFrameLength*ISR)
shreeshas95 1:a0055b3280c8 251 }
ee12b079 9:e9eaada136c6 252
shreeshas95 1:a0055b3280c8 253
ee12b079 9:e9eaada136c6 254
shreeshas95 1:a0055b3280c8 255 void head_pointer(Base_tm* ptr){
shreeshas95 1:a0055b3280c8 256 head_ptr = ptr ;
shreeshas95 1:a0055b3280c8 257 type1_frame_flag = true;
shreeshas95 1:a0055b3280c8 258 type0_frame_flag = true;
shreeshas95 1:a0055b3280c8 259 make_DataStream_f = true;
shreeshas95 1:a0055b3280c8 260 transmit_data_f = true;
shreeshas95 1:a0055b3280c8 261 diff_prev = 0;
shreeshas95 1:a0055b3280c8 262 data_number();
shreeshas95 1:a0055b3280c8 263 }
ee12b079 9:e9eaada136c6 264
ee12b079 9:e9eaada136c6 265
shreeshas95 1:a0055b3280c8 266 void inline transmit_data(unsigned char * transmit , bool * last_buffer){
shreeshas95 1:a0055b3280c8 267 if(transmit_data_f){
shreeshas95 1:a0055b3280c8 268 RB_c = 0;
shreeshas95 1:a0055b3280c8 269 Sframe_c = 0;
shreeshas95 1:a0055b3280c8 270 SCH40_c = 0;
shreeshas95 1:a0055b3280c8 271 FCCH80_c = 0;
shreeshas95 1:a0055b3280c8 272 Tframe_c = 0;
shreeshas95 1:a0055b3280c8 273 EOS_c = 0;
shreeshas95 1:a0055b3280c8 274 segment_c = 0;
shreeshas95 1:a0055b3280c8 275 data_c = 0;
ee12b079 9:e9eaada136c6 276
shreeshas95 1:a0055b3280c8 277 Sframe = true;
shreeshas95 1:a0055b3280c8 278 SCH40_f = false;
shreeshas95 1:a0055b3280c8 279 data_f = false;
shreeshas95 1:a0055b3280c8 280 FCCH80_f = false;
shreeshas95 1:a0055b3280c8 281 transmit_data_f = false;
shreeshas95 1:a0055b3280c8 282 reset_adf = false;
shreeshas95 1:a0055b3280c8 283 *last_buffer = false;
shreeshas95 1:a0055b3280c8 284 }
ee12b079 9:e9eaada136c6 285
shreeshas95 1:a0055b3280c8 286 for(RB_c = 0 ; RB_c<112 ; RB_c++){
ee12b079 9:e9eaada136c6 287
ee12b079 9:e9eaada136c6 288 if(junk_f || *last_buffer){
ee12b079 9:e9eaada136c6 289 transmit[RB_c] = 0x00;
ee12b079 9:e9eaada136c6 290 continue;
shreeshas95 1:a0055b3280c8 291 }
ee12b079 9:e9eaada136c6 292
shreeshas95 1:a0055b3280c8 293 if(Sframe){
shreeshas95 1:a0055b3280c8 294 transmit[RB_c] = S_frame[Sframe_c++];
shreeshas95 1:a0055b3280c8 295 if(Sframe_c == 48){
shreeshas95 1:a0055b3280c8 296 // printf("exit s frame\n");
shreeshas95 1:a0055b3280c8 297 Sframe_c = 0;
shreeshas95 1:a0055b3280c8 298 Sframe = false;
shreeshas95 1:a0055b3280c8 299 SCH40_f =true;
shreeshas95 1:a0055b3280c8 300 }
shreeshas95 1:a0055b3280c8 301 continue;
shreeshas95 1:a0055b3280c8 302 }
ee12b079 9:e9eaada136c6 303 //
shreeshas95 1:a0055b3280c8 304 if(SCH40_f){
ee12b079 9:e9eaada136c6 305 transmit[RB_c] = SCH40[SCH40_c++];
shreeshas95 1:a0055b3280c8 306 if(SCH40_c == 5 ){
shreeshas95 1:a0055b3280c8 307 SCH40_c = 0;
ee12b079 9:e9eaada136c6 308 SCH40_f = false;
ee12b079 9:e9eaada136c6 309
ee12b079 9:e9eaada136c6 310
ee12b079 9:e9eaada136c6 311 if(Tframe_c >= LAST_SEGMENT_SIZE && segment_r == 0)
ee12b079 9:e9eaada136c6 312 {
ee12b079 9:e9eaada136c6 313 repeat_data_f = true;
ee12b079 9:e9eaada136c6 314 DS_index = !DS_index;
ee12b079 9:e9eaada136c6 315 }
ee12b079 9:e9eaada136c6 316 else
ee12b079 9:e9eaada136c6 317 {
ee12b079 9:e9eaada136c6 318 data_f = true;
ee12b079 9:e9eaada136c6 319 make_DataStream;
ee12b079 9:e9eaada136c6 320 }
shreeshas95 1:a0055b3280c8 321 // printf("exit SCH40 frame\n");
shreeshas95 1:a0055b3280c8 322 }
shreeshas95 1:a0055b3280c8 323 continue;
shreeshas95 1:a0055b3280c8 324 }
ee12b079 9:e9eaada136c6 325 //
shreeshas95 1:a0055b3280c8 326 if(data_f){
shreeshas95 1:a0055b3280c8 327 transmit[RB_c] = interleave_data[DS_index][data_c++];
shreeshas95 1:a0055b3280c8 328 if(data_c == 144){
shreeshas95 1:a0055b3280c8 329 data_c = 0;
shreeshas95 1:a0055b3280c8 330 FCCH80_f = true;
shreeshas95 1:a0055b3280c8 331 data_f = false;
shreeshas95 1:a0055b3280c8 332 // printf("exit Data\n");
shreeshas95 1:a0055b3280c8 333 }
shreeshas95 1:a0055b3280c8 334 continue;
shreeshas95 1:a0055b3280c8 335 }
ee12b079 9:e9eaada136c6 336 if(repeat_data_f){
ee12b079 9:e9eaada136c6 337 transmit[RB_c] = interleave_data[DS_index][data_c++];
ee12b079 9:e9eaada136c6 338 if(data_c == 144){
ee12b079 9:e9eaada136c6 339 data_c = 0;
ee12b079 9:e9eaada136c6 340 FCCH80_f = true;
ee12b079 9:e9eaada136c6 341 repeat_data_f = false;
ee12b079 9:e9eaada136c6 342 // printf("exit Data\n");
ee12b079 9:e9eaada136c6 343 }
ee12b079 9:e9eaada136c6 344 continue;
ee12b079 9:e9eaada136c6 345 }
ee12b079 9:e9eaada136c6 346
shreeshas95 1:a0055b3280c8 347 if(FCCH80_f){
shreeshas95 1:a0055b3280c8 348 transmit[RB_c] = FCCH80[FCCH80_c++];
shreeshas95 1:a0055b3280c8 349 if(FCCH80_c == 10){
shreeshas95 1:a0055b3280c8 350 FCCH80_c = 0;
shreeshas95 1:a0055b3280c8 351 FCCH80_f = false;
shreeshas95 1:a0055b3280c8 352 // printf("exit FCCH80\n");
shreeshas95 1:a0055b3280c8 353 if(++Tframe_c != ISR)
ee12b079 9:e9eaada136c6 354 SCH40_f = true;
shreeshas95 1:a0055b3280c8 355 else{
shreeshas95 1:a0055b3280c8 356 Tframe_c = 0;
shreeshas95 1:a0055b3280c8 357 segment_c++;
aniruddhv 52:0bd68655c651 358 if(segment_c >= SEGMENT_NO - 1 && TOTAL_SEGMENT_NO == 0) segment_r = 0; else segment_r = 1;
ee12b079 9:e9eaada136c6 359 if(segment_c == SEGMENT_NO)
shreeshas95 1:a0055b3280c8 360 {eos_f = true;}
shreeshas95 1:a0055b3280c8 361 else{
shreeshas95 1:a0055b3280c8 362 Sframe = true;
shreeshas95 1:a0055b3280c8 363 }
shreeshas95 1:a0055b3280c8 364 }
shreeshas95 1:a0055b3280c8 365 }
shreeshas95 1:a0055b3280c8 366 continue;
ee12b079 9:e9eaada136c6 367 }
ee12b079 9:e9eaada136c6 368
ee12b079 9:e9eaada136c6 369 if(eos_f){
shreeshas95 1:a0055b3280c8 370 transmit[RB_c] = EoS[EOS_c++];
shreeshas95 1:a0055b3280c8 371 if(EOS_c == EOS_SIZE){
shreeshas95 1:a0055b3280c8 372 EOS_c = 0;
shreeshas95 1:a0055b3280c8 373 eos_f = false;
ee12b079 9:e9eaada136c6 374 if(segment_c == SEGMENT_NO && segment_r == 0){
ee12b079 9:e9eaada136c6 375 *last_buffer = true;
ee12b079 9:e9eaada136c6 376 }
ee12b079 9:e9eaada136c6 377 else if(segment_c == SEGMENT_NO && segment_r != 0){
ee12b079 9:e9eaada136c6 378 segment_c = 0;
ee12b079 9:e9eaada136c6 379 SEGMENT_NO = TOTAL_SEGMENT_NO;
ee12b079 9:e9eaada136c6 380 if(SEGMENT_NO > MAX_SEGMENT)
ee12b079 9:e9eaada136c6 381 {
ee12b079 9:e9eaada136c6 382 SEGMENT_NO = MAX_SEGMENT;
ee12b079 9:e9eaada136c6 383 }
aniruddhv 52:0bd68655c651 384 if(SEGMENT_NO == 1) segment_r = 0; else segment_r = 1;
ee12b079 9:e9eaada136c6 385 TOTAL_SEGMENT_NO -= SEGMENT_NO;
ee12b079 9:e9eaada136c6 386 reset_adf = true;//what does this do??
ee12b079 9:e9eaada136c6 387 Sframe = true;
ee12b079 9:e9eaada136c6 388 }
shreeshas95 1:a0055b3280c8 389 junk_f = true;
shreeshas95 1:a0055b3280c8 390 }
shreeshas95 1:a0055b3280c8 391 continue;
ee12b079 9:e9eaada136c6 392 }
shreeshas95 1:a0055b3280c8 393 }
shreeshas95 1:a0055b3280c8 394 differential_encode(transmit,112);
shreeshas95 1:a0055b3280c8 395 if(reset_adf == true){
shreeshas95 1:a0055b3280c8 396 diff_prev = 0;
shreeshas95 1:a0055b3280c8 397 junk_f = false;
shreeshas95 1:a0055b3280c8 398 }
ee12b079 9:e9eaada136c6 399
shreeshas95 1:a0055b3280c8 400 }
ee12b079 9:e9eaada136c6 401
shreeshas95 1:a0055b3280c8 402 };
shreeshas95 1:a0055b3280c8 403 SND_TM snd_tm;