publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Committer:
shreeshas95
Date:
Fri Jan 29 17:09:41 2016 +0000
Revision:
102:80c911a6e736
Parent:
95:42d6747900cb
Child:
118:60c5de4cb8ad
Child:
128:a232a4352664
Changed Structures.h: removed Base_tm functions and corresponding errors everywhere

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aniruddhv 52:0bd68655c651 1 //void adf_not_SDcard();
shreeshas95 1:a0055b3280c8 2
ee12b079 84:b0f7a241ddf3 3 //~ #include"SDcard.h"
ee12b079 86:a26f5f22631d 4 /*#define T_frames 30
ee12b079 84:b0f7a241ddf3 5 unsigned char buffer_112_counter,sent_tm = 0;
ee12b079 84:b0f7a241ddf3 6 int disk_read(uint8_t *, uint64_t),j;
ee12b079 84:b0f7a241ddf3 7 bool new_session = true;
ee12b079 84:b0f7a241ddf3 8 bool last_buffer = false;
ee12b079 84:b0f7a241ddf3 9 bool first_block = true;
ee12b079 84:b0f7a241ddf3 10 bool last_block =false;
ee12b079 84:b0f7a241ddf3 11 bool repeat_T_frame = false;
ee12b079 84:b0f7a241ddf3 12 unsigned int counter_in_block=0,diff_prev=0;
ee12b079 84:b0f7a241ddf3 13 unsigned char EOS_counter = 0;
ee12b079 84:b0f7a241ddf3 14 unsigned char enable_T_frame = false;
ee12b079 84:b0f7a241ddf3 15 uint64_t start_block_num ; // Read from TC
ee12b079 84:b0f7a241ddf3 16 uint64_t end_block_num ; // Read from TC
ee12b079 84:b0f7a241ddf3 17 uint64_t Number_of_blocks_to_read ;
ee12b079 84:b0f7a241ddf3 18 uint64_t block_counter = 0;
ee12b079 84:b0f7a241ddf3 19 unsigned char buffer_512[512], buffer_112[112],counter_in_S_frame=0,counter_in_SCH=0;
ee12b079 84:b0f7a241ddf3 20 unsigned char make_EOS_flag = true;
ee12b079 86:a26f5f22631d 21 bool reset = false; */
ee12b079 84:b0f7a241ddf3 22
ee12b079 84:b0f7a241ddf3 23
ee12b079 84:b0f7a241ddf3 24
ee12b079 84:b0f7a241ddf3 25
ee12b079 84:b0f7a241ddf3 26
ee12b079 84:b0f7a241ddf3 27
ee12b079 84:b0f7a241ddf3 28
ee12b079 95:42d6747900cb 29 bool sent_tmfrom_SDcard;
ee12b079 84:b0f7a241ddf3 30
ee12b079 84:b0f7a241ddf3 31
ee12b079 84:b0f7a241ddf3 32
shreeshas95 1:a0055b3280c8 33 #define S_FRAME_SIZE 48
ee12b079 9:e9eaada136c6 34 #define ISR 40
shreeshas95 1:a0055b3280c8 35 #define TM_FRAME_SIZE 134 //in bytes
shreeshas95 1:a0055b3280c8 36 #define T_FRAME_SIZE 159
shreeshas95 1:a0055b3280c8 37 #define EOS_SIZE 120
ee12b079 9:e9eaada136c6 38 #define MAX_ADF_LEN 65535
ee12b079 9:e9eaada136c6 39
shreeshas95 1:a0055b3280c8 40 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 41 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 42 const unsigned char FCCH80[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
shreeshas95 1:a0055b3280c8 43 const unsigned char SCH40[] = {0x0a,0x3f,0x46,0xb4,0x00};
aniruddhv 52:0bd68655c651 44 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 9:e9eaada136c6 45
aniruddhv 69:20f09a0c3fd2 46 #define print_tm(ptr) {\
aniruddhv 69:20f09a0c3fd2 47 for( int i = 0; i < 134; i++ ){\
aniruddhv 69:20f09a0c3fd2 48 gPC.putc(ptr[i]);\
aniruddhv 69:20f09a0c3fd2 49 }\
aniruddhv 69:20f09a0c3fd2 50 }
aniruddhv 69:20f09a0c3fd2 51
ee12b079 86:a26f5f22631d 52 //void send_tm_from_SD_card(){}
ee12b079 84:b0f7a241ddf3 53
shreeshas95 1:a0055b3280c8 54 class SND_TM{
ee12b079 9:e9eaada136c6 55
ee12b079 9:e9eaada136c6 56 Base_tm * head_ptr;
ee12b079 9:e9eaada136c6 57
shreeshas95 1:a0055b3280c8 58 // transmit data variables
shreeshas95 1:a0055b3280c8 59 unsigned char Tframe_c; //_c represents counter, counts Tframe written in a segment
shreeshas95 1:a0055b3280c8 60 unsigned char EOS_c; //count no of bytes of eos have been weitten in the rolling buffer
shreeshas95 1:a0055b3280c8 61 unsigned char Sframe_c; //count no of bytes of Sframe have been weitten in the rolling buffer
shreeshas95 1:a0055b3280c8 62 unsigned char SCH40_c; //count no of bytes of SCH40 have been weitten in the rolling buffer
shreeshas95 1:a0055b3280c8 63 unsigned char data_c;
shreeshas95 1:a0055b3280c8 64 unsigned char FCCH80_c;
shreeshas95 1:a0055b3280c8 65 unsigned char RB_c; //rolling buffer counter
shreeshas95 1:a0055b3280c8 66 unsigned char segment_c; //counts the numver of segments sent
shreeshas95 1:a0055b3280c8 67 unsigned char MAX_SEGMENT;
shreeshas95 1:a0055b3280c8 68 bool Sframe; //Sframe = 1bit of CF1
shreeshas95 1:a0055b3280c8 69 bool SCH40_f;
shreeshas95 1:a0055b3280c8 70 bool FCCH80_f;
shreeshas95 1:a0055b3280c8 71 bool data_f;
ee12b079 9:e9eaada136c6 72 bool repeat_data_f;
shreeshas95 1:a0055b3280c8 73 bool transmit_data_f;
shreeshas95 1:a0055b3280c8 74 bool eos_f;
shreeshas95 1:a0055b3280c8 75 bool junk_f;
ee12b079 9:e9eaada136c6 76 bool segment_r; //flag checking if more sessions are required
ee12b079 9:e9eaada136c6 77
ee12b079 9:e9eaada136c6 78
shreeshas95 1:a0055b3280c8 79 // type 1 frame
ee12b079 9:e9eaada136c6 80
shreeshas95 1:a0055b3280c8 81 Base_tm *T0F_pointer ;
ee12b079 9:e9eaada136c6 82
shreeshas95 1:a0055b3280c8 83 int diff_prev;
shreeshas95 1:a0055b3280c8 84 void differential_encode(unsigned char* ptr, int length){
shreeshas95 1:a0055b3280c8 85 for(int i=0; i<length;i++){
shreeshas95 1:a0055b3280c8 86 unsigned char s = ptr[i] , t;
shreeshas95 1:a0055b3280c8 87 t = s ^ (s >> 1);
shreeshas95 1:a0055b3280c8 88 (diff_prev == 0) ? t=t^0x00 : t=t^0x80 ;
shreeshas95 1:a0055b3280c8 89 diff_prev = int(s & 0x01);
shreeshas95 1:a0055b3280c8 90 ptr[i] = t;
shreeshas95 1:a0055b3280c8 91 }
ee12b079 9:e9eaada136c6 92 }
ee12b079 9:e9eaada136c6 93
shreeshas95 1:a0055b3280c8 94 int type0_no; //number of type zero frames
ee12b079 9:e9eaada136c6 95 int type1_no;
shreeshas95 1:a0055b3280c8 96 int total_frames; //number of type one packe (TMP)
shreeshas95 1:a0055b3280c8 97 int SEGMENT_NO; //number of type one packe (TMP)
ee12b079 9:e9eaada136c6 98 int TOTAL_SEGMENT_NO;
ee12b079 9:e9eaada136c6 99 int LAST_SEGMENT_SIZE;
shreeshas95 1:a0055b3280c8 100 void inline data_number(){
shreeshas95 1:a0055b3280c8 101 int type1_frame_no;
shreeshas95 1:a0055b3280c8 102 Base_tm*head = head_ptr;
shreeshas95 1:a0055b3280c8 103 type0_no = 0;
shreeshas95 1:a0055b3280c8 104 type1_no = 0;
aniruddhv 52:0bd68655c651 105 while(head != NULL){
shreeshas95 102:80c911a6e736 106 switch( GETshort_or_long_tm(head) ){
shreeshas95 1:a0055b3280c8 107 case 0:
shreeshas95 1:a0055b3280c8 108 type0_no++;
shreeshas95 1:a0055b3280c8 109 break;
shreeshas95 1:a0055b3280c8 110 case 1:
shreeshas95 1:a0055b3280c8 111 type1_no++;
shreeshas95 1:a0055b3280c8 112 break;
shreeshas95 1:a0055b3280c8 113 }
ee12b079 9:e9eaada136c6 114
shreeshas95 1:a0055b3280c8 115 head=head->next_TM;
shreeshas95 1:a0055b3280c8 116 }
shreeshas95 1:a0055b3280c8 117 type1_frame_no = ( type1_no % 10 == 0 )? (type1_no / 10) : ( (type1_no / 10) + 1);
shreeshas95 1:a0055b3280c8 118 total_frames = type0_no + type1_frame_no ;
ee12b079 9:e9eaada136c6 119 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 120 SEGMENT_NO = TOTAL_SEGMENT_NO;
ee12b079 9:e9eaada136c6 121 if(SEGMENT_NO > MAX_SEGMENT)
ee12b079 9:e9eaada136c6 122 {
ee12b079 9:e9eaada136c6 123 SEGMENT_NO = MAX_SEGMENT;
ee12b079 9:e9eaada136c6 124 }
aniruddhv 52:0bd68655c651 125 if(SEGMENT_NO == 1) segment_r = 0; else segment_r = 1;
ee12b079 9:e9eaada136c6 126 TOTAL_SEGMENT_NO -= SEGMENT_NO;
aniruddhv 52:0bd68655c651 127 LAST_SEGMENT_SIZE = total_frames*2%ISR?total_frames*2%ISR:ISR;
shreeshas95 1:a0055b3280c8 128 }
ee12b079 9:e9eaada136c6 129
shreeshas95 1:a0055b3280c8 130 #define next_type_structure(ptr){\
shreeshas95 102:80c911a6e736 131 unsigned char temp = GETshort_or_long_tm(ptr);\
shreeshas95 1:a0055b3280c8 132 if((temp == 0) && (ptr->next_TM != NULL) ){\
shreeshas95 1:a0055b3280c8 133 do{\
shreeshas95 1:a0055b3280c8 134 ptr = ptr->next_TM;\
shreeshas95 102:80c911a6e736 135 temp = GETshort_or_long_tm(ptr);\
shreeshas95 1:a0055b3280c8 136 }\
shreeshas95 1:a0055b3280c8 137 while(temp == 1 && ptr->next_TM != NULL);\
shreeshas95 1:a0055b3280c8 138 if(temp == 1){\
shreeshas95 1:a0055b3280c8 139 ptr = NULL;\
shreeshas95 1:a0055b3280c8 140 }\
shreeshas95 1:a0055b3280c8 141 }\
shreeshas95 1:a0055b3280c8 142 else if((temp == 1) && (ptr->next_TM != NULL)){\
shreeshas95 1:a0055b3280c8 143 do{\
shreeshas95 1:a0055b3280c8 144 ptr = ptr->next_TM;\
shreeshas95 102:80c911a6e736 145 temp = GETshort_or_long_tm(ptr);\
shreeshas95 1:a0055b3280c8 146 }\
shreeshas95 1:a0055b3280c8 147 while(temp == 0 && ptr->next_TM != NULL);\
shreeshas95 1:a0055b3280c8 148 if(temp == 0){\
ee12b079 9:e9eaada136c6 149 ptr = NULL;\
shreeshas95 1:a0055b3280c8 150 }\
shreeshas95 1:a0055b3280c8 151 }\
shreeshas95 1:a0055b3280c8 152 else{\
ee12b079 9:e9eaada136c6 153 ptr = NULL;\
shreeshas95 1:a0055b3280c8 154 }\
shreeshas95 1:a0055b3280c8 155 }
ee12b079 9:e9eaada136c6 156
shreeshas95 1:a0055b3280c8 157 /*
shreeshas95 1:a0055b3280c8 158 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 159 parameter: type 0 or 1
ee12b079 9:e9eaada136c6 160 return: pointer of the first node having same type
shreeshas95 1:a0055b3280c8 161 */
aniruddhv 52:0bd68655c651 162 #define exor(ptr) { for(int i=0 ; i<134; i++ ) ptr[i]=ptr[i]^EXOR_SEQ[i];}
ee12b079 9:e9eaada136c6 163
ee12b079 9:e9eaada136c6 164
shreeshas95 1:a0055b3280c8 165 #define first_type_structure( type,return_ptr) {\
shreeshas95 1:a0055b3280c8 166 Base_tm* temp_ptr = head_ptr;\
shreeshas95 1:a0055b3280c8 167 if(type == 0){\
shreeshas95 102:80c911a6e736 168 while(GETshort_or_long_tm(temp_ptr) == 1){\
shreeshas95 1:a0055b3280c8 169 temp_ptr = temp_ptr->next_TM;\
shreeshas95 1:a0055b3280c8 170 if(temp_ptr == NULL){\
shreeshas95 1:a0055b3280c8 171 return_ptr = NULL ;\
shreeshas95 1:a0055b3280c8 172 }\
shreeshas95 1:a0055b3280c8 173 }\
shreeshas95 1:a0055b3280c8 174 }\
shreeshas95 1:a0055b3280c8 175 else if(type == 1){\
shreeshas95 102:80c911a6e736 176 while(GETshort_or_long_tm(temp_ptr) == 0){\
shreeshas95 1:a0055b3280c8 177 temp_ptr = temp_ptr->next_TM;\
shreeshas95 1:a0055b3280c8 178 if(temp_ptr == NULL){\
shreeshas95 1:a0055b3280c8 179 return_ptr = NULL;\
shreeshas95 1:a0055b3280c8 180 }\
shreeshas95 1:a0055b3280c8 181 }\
shreeshas95 1:a0055b3280c8 182 }\
shreeshas95 1:a0055b3280c8 183 return_ptr = temp_ptr;\
shreeshas95 1:a0055b3280c8 184 }
ee12b079 9:e9eaada136c6 185
ee12b079 9:e9eaada136c6 186
ee12b079 9:e9eaada136c6 187
shreeshas95 1:a0055b3280c8 188 Base_tm *T1F_pointer ;
shreeshas95 1:a0055b3280c8 189 int T1F_counter;
shreeshas95 1:a0055b3280c8 190 unsigned char TMframe_type1[TM_FRAME_SIZE];
shreeshas95 1:a0055b3280c8 191 bool type1_frame_flag; //should be true for every new list
ee12b079 9:e9eaada136c6 192
shreeshas95 1:a0055b3280c8 193 #define type1_frame(ptr){\
shreeshas95 1:a0055b3280c8 194 int i=4;\
shreeshas95 1:a0055b3280c8 195 if(type1_frame_flag){\
shreeshas95 1:a0055b3280c8 196 first_type_structure(1,T1F_pointer);\
shreeshas95 1:a0055b3280c8 197 T1F_counter = 0;\
shreeshas95 1:a0055b3280c8 198 type1_frame_flag = false;\
shreeshas95 1:a0055b3280c8 199 }\
shreeshas95 1:a0055b3280c8 200 for(i = 4 ; (i < 134) && (T1F_pointer != NULL) ; i++){\
shreeshas95 1:a0055b3280c8 201 TMframe_type1[i] = T1F_pointer->TM_string[T1F_counter];\
shreeshas95 1:a0055b3280c8 202 if(T1F_counter++ == 12){\
shreeshas95 1:a0055b3280c8 203 T1F_counter = 0;\
shreeshas95 1:a0055b3280c8 204 next_type_structure(T1F_pointer);\
shreeshas95 1:a0055b3280c8 205 }\
shreeshas95 1:a0055b3280c8 206 }\
aniruddhv 52:0bd68655c651 207 TMframe_type1[0] = (1<<7) + (( (i-4)/13 )<<3);\
aniruddhv 69:20f09a0c3fd2 208 TMframe_type1[3] = crc8_gen(TMframe_type1,3);\
shreeshas95 1:a0055b3280c8 209 if(T1F_pointer == NULL && i>12){\
shreeshas95 1:a0055b3280c8 210 for( ; i < 134 ; i++){\
shreeshas95 1:a0055b3280c8 211 TMframe_type1[i] = TMframe_type1[i-13];\
shreeshas95 1:a0055b3280c8 212 }\
shreeshas95 1:a0055b3280c8 213 }\
ee12b079 9:e9eaada136c6 214 ptr=TMframe_type1;\
shreeshas95 1:a0055b3280c8 215 }
ee12b079 9:e9eaada136c6 216
ee12b079 9:e9eaada136c6 217
shreeshas95 1:a0055b3280c8 218 bool type0_frame_flag;
ee12b079 9:e9eaada136c6 219
ee12b079 9:e9eaada136c6 220
shreeshas95 1:a0055b3280c8 221 #define type0_frame(ptr){\
shreeshas95 1:a0055b3280c8 222 if(type0_frame_flag){\
shreeshas95 1:a0055b3280c8 223 first_type_structure(0,T0F_pointer);\
shreeshas95 1:a0055b3280c8 224 type0_frame_flag = false;\
shreeshas95 1:a0055b3280c8 225 }\
shreeshas95 1:a0055b3280c8 226 else {\
shreeshas95 1:a0055b3280c8 227 next_type_structure(T0F_pointer);\
shreeshas95 1:a0055b3280c8 228 }\
shreeshas95 1:a0055b3280c8 229 ptr = T0F_pointer->TM_string;\
shreeshas95 1:a0055b3280c8 230 }
ee12b079 53:18db568f1098 231
ee12b079 9:e9eaada136c6 232 unsigned char convoluted_frame[270];
shreeshas95 1:a0055b3280c8 233 Convolution ConvObj2;
shreeshas95 1:a0055b3280c8 234 void convolution (unsigned char * ptr){
shreeshas95 1:a0055b3280c8 235 ConvObj2.convolutionEncode(ptr, convoluted_frame);
shreeshas95 1:a0055b3280c8 236 ConvObj2.convolutionEncode(ptr + 67, convoluted_frame + 135);
shreeshas95 1:a0055b3280c8 237 }
ee12b079 9:e9eaada136c6 238
ee12b079 9:e9eaada136c6 239
ee12b079 9:e9eaada136c6 240 unsigned char interleave_data[2][144];
shreeshas95 1:a0055b3280c8 241 unsigned char DS_index;
shreeshas95 1:a0055b3280c8 242 bool DS_state;
shreeshas95 1:a0055b3280c8 243 int DS_counter;
shreeshas95 1:a0055b3280c8 244 bool DS_f;
shreeshas95 1:a0055b3280c8 245 bool make_DataStream_f;
ee12b079 9:e9eaada136c6 246
ee12b079 9:e9eaada136c6 247 #define make_DataStream {\
ee12b079 9:e9eaada136c6 248 unsigned char* ptr;\
ee12b079 9:e9eaada136c6 249 if(make_DataStream_f == true){\
ee12b079 9:e9eaada136c6 250 DS_state = true;\
ee12b079 9:e9eaada136c6 251 DS_counter = 0;\
ee12b079 9:e9eaada136c6 252 DS_f = false;\
ee12b079 9:e9eaada136c6 253 make_DataStream_f = false;\
ee12b079 9:e9eaada136c6 254 }\
ee12b079 9:e9eaada136c6 255 if(DS_state){\
ee12b079 9:e9eaada136c6 256 if(DS_counter < total_frames-type0_no){\
ee12b079 9:e9eaada136c6 257 type1_frame(ptr); \
ee12b079 9:e9eaada136c6 258 DS_f = true;\
ee12b079 9:e9eaada136c6 259 }\
ee12b079 9:e9eaada136c6 260 else if(DS_counter < total_frames ){\
ee12b079 9:e9eaada136c6 261 type0_frame(ptr);\
ee12b079 9:e9eaada136c6 262 DS_f = true;\
ee12b079 9:e9eaada136c6 263 }\
ee12b079 9:e9eaada136c6 264 DS_counter++;\
ee12b079 9:e9eaada136c6 265 }\
ee12b079 9:e9eaada136c6 266 DS_state = !DS_state;\
ee12b079 9:e9eaada136c6 267 if (DS_f){\
ee12b079 9:e9eaada136c6 268 DS_f = false;\
aniruddhv 69:20f09a0c3fd2 269 if(bypass_adf == 1)\
aniruddhv 69:20f09a0c3fd2 270 print_tm(ptr);\
aniruddhv 52:0bd68655c651 271 exor(ptr);\
ee12b079 9:e9eaada136c6 272 convolution(ptr);\
ee12b079 9:e9eaada136c6 273 interleave(convoluted_frame,interleave_data[0]);\
ee12b079 9:e9eaada136c6 274 interleave(convoluted_frame+ 135,interleave_data[1]);}\
ee12b079 9:e9eaada136c6 275 DS_index = (DS_state==true)?1:0;\
ee12b079 9:e9eaada136c6 276 }
ee12b079 9:e9eaada136c6 277
ee12b079 9:e9eaada136c6 278
ee12b079 9:e9eaada136c6 279 //
shreeshas95 1:a0055b3280c8 280 public:
ee12b079 9:e9eaada136c6 281
shreeshas95 1:a0055b3280c8 282 bool reset_adf;
shreeshas95 1:a0055b3280c8 283 SND_TM(){
rohit3342 11:83acbe8e0ad1 284 MAX_SEGMENT = (MAX_ADF_LEN-EOS_SIZE)/( S_FRAME_SIZE + ISR*T_FRAME_SIZE);
ee12b079 9:e9eaada136c6 285 //(max length - eos size)/(sframe length + tFrameLength*ISR)
shreeshas95 1:a0055b3280c8 286 }
ee12b079 9:e9eaada136c6 287
shreeshas95 1:a0055b3280c8 288
ee12b079 9:e9eaada136c6 289
shreeshas95 1:a0055b3280c8 290 void head_pointer(Base_tm* ptr){
shreeshas95 1:a0055b3280c8 291 head_ptr = ptr ;
shreeshas95 1:a0055b3280c8 292 type1_frame_flag = true;
shreeshas95 1:a0055b3280c8 293 type0_frame_flag = true;
shreeshas95 1:a0055b3280c8 294 make_DataStream_f = true;
shreeshas95 1:a0055b3280c8 295 transmit_data_f = true;
ee12b079 95:42d6747900cb 296 sent_tmfrom_SDcard = false;
shreeshas95 1:a0055b3280c8 297 diff_prev = 0;
shreeshas95 1:a0055b3280c8 298 data_number();
shreeshas95 1:a0055b3280c8 299 }
ee12b079 9:e9eaada136c6 300
ee12b079 9:e9eaada136c6 301
shreeshas95 1:a0055b3280c8 302 void inline transmit_data(unsigned char * transmit , bool * last_buffer){
shreeshas95 1:a0055b3280c8 303 if(transmit_data_f){
shreeshas95 1:a0055b3280c8 304 RB_c = 0;
shreeshas95 1:a0055b3280c8 305 Sframe_c = 0;
shreeshas95 1:a0055b3280c8 306 SCH40_c = 0;
shreeshas95 1:a0055b3280c8 307 FCCH80_c = 0;
shreeshas95 1:a0055b3280c8 308 Tframe_c = 0;
shreeshas95 1:a0055b3280c8 309 EOS_c = 0;
shreeshas95 1:a0055b3280c8 310 segment_c = 0;
shreeshas95 1:a0055b3280c8 311 data_c = 0;
ee12b079 9:e9eaada136c6 312
shreeshas95 1:a0055b3280c8 313 Sframe = true;
shreeshas95 1:a0055b3280c8 314 SCH40_f = false;
shreeshas95 1:a0055b3280c8 315 data_f = false;
shreeshas95 1:a0055b3280c8 316 FCCH80_f = false;
shreeshas95 1:a0055b3280c8 317 transmit_data_f = false;
shreeshas95 1:a0055b3280c8 318 reset_adf = false;
shreeshas95 1:a0055b3280c8 319 *last_buffer = false;
shreeshas95 1:a0055b3280c8 320 }
ee12b079 9:e9eaada136c6 321
shreeshas95 1:a0055b3280c8 322 for(RB_c = 0 ; RB_c<112 ; RB_c++){
ee12b079 9:e9eaada136c6 323
ee12b079 9:e9eaada136c6 324 if(junk_f || *last_buffer){
ee12b079 9:e9eaada136c6 325 transmit[RB_c] = 0x00;
ee12b079 9:e9eaada136c6 326 continue;
shreeshas95 1:a0055b3280c8 327 }
ee12b079 9:e9eaada136c6 328
shreeshas95 1:a0055b3280c8 329 if(Sframe){
shreeshas95 1:a0055b3280c8 330 transmit[RB_c] = S_frame[Sframe_c++];
shreeshas95 1:a0055b3280c8 331 if(Sframe_c == 48){
shreeshas95 1:a0055b3280c8 332 // printf("exit s frame\n");
shreeshas95 1:a0055b3280c8 333 Sframe_c = 0;
shreeshas95 1:a0055b3280c8 334 Sframe = false;
shreeshas95 1:a0055b3280c8 335 SCH40_f =true;
shreeshas95 1:a0055b3280c8 336 }
shreeshas95 1:a0055b3280c8 337 continue;
shreeshas95 1:a0055b3280c8 338 }
ee12b079 9:e9eaada136c6 339 //
shreeshas95 1:a0055b3280c8 340 if(SCH40_f){
ee12b079 9:e9eaada136c6 341 transmit[RB_c] = SCH40[SCH40_c++];
shreeshas95 1:a0055b3280c8 342 if(SCH40_c == 5 ){
shreeshas95 1:a0055b3280c8 343 SCH40_c = 0;
ee12b079 9:e9eaada136c6 344 SCH40_f = false;
ee12b079 9:e9eaada136c6 345
ee12b079 9:e9eaada136c6 346
ee12b079 9:e9eaada136c6 347 if(Tframe_c >= LAST_SEGMENT_SIZE && segment_r == 0)
ee12b079 9:e9eaada136c6 348 {
ee12b079 9:e9eaada136c6 349 repeat_data_f = true;
ee12b079 9:e9eaada136c6 350 DS_index = !DS_index;
ee12b079 9:e9eaada136c6 351 }
ee12b079 9:e9eaada136c6 352 else
ee12b079 9:e9eaada136c6 353 {
ee12b079 9:e9eaada136c6 354 data_f = true;
ee12b079 9:e9eaada136c6 355 make_DataStream;
ee12b079 9:e9eaada136c6 356 }
shreeshas95 1:a0055b3280c8 357 // printf("exit SCH40 frame\n");
shreeshas95 1:a0055b3280c8 358 }
shreeshas95 1:a0055b3280c8 359 continue;
shreeshas95 1:a0055b3280c8 360 }
ee12b079 9:e9eaada136c6 361 //
shreeshas95 1:a0055b3280c8 362 if(data_f){
shreeshas95 1:a0055b3280c8 363 transmit[RB_c] = interleave_data[DS_index][data_c++];
shreeshas95 1:a0055b3280c8 364 if(data_c == 144){
shreeshas95 1:a0055b3280c8 365 data_c = 0;
shreeshas95 1:a0055b3280c8 366 FCCH80_f = true;
shreeshas95 1:a0055b3280c8 367 data_f = false;
shreeshas95 1:a0055b3280c8 368 // printf("exit Data\n");
shreeshas95 1:a0055b3280c8 369 }
shreeshas95 1:a0055b3280c8 370 continue;
shreeshas95 1:a0055b3280c8 371 }
ee12b079 9:e9eaada136c6 372 if(repeat_data_f){
ee12b079 9:e9eaada136c6 373 transmit[RB_c] = interleave_data[DS_index][data_c++];
ee12b079 9:e9eaada136c6 374 if(data_c == 144){
ee12b079 9:e9eaada136c6 375 data_c = 0;
ee12b079 9:e9eaada136c6 376 FCCH80_f = true;
ee12b079 9:e9eaada136c6 377 repeat_data_f = false;
ee12b079 9:e9eaada136c6 378 // printf("exit Data\n");
ee12b079 9:e9eaada136c6 379 }
ee12b079 9:e9eaada136c6 380 continue;
ee12b079 9:e9eaada136c6 381 }
ee12b079 9:e9eaada136c6 382
shreeshas95 1:a0055b3280c8 383 if(FCCH80_f){
shreeshas95 1:a0055b3280c8 384 transmit[RB_c] = FCCH80[FCCH80_c++];
shreeshas95 1:a0055b3280c8 385 if(FCCH80_c == 10){
shreeshas95 1:a0055b3280c8 386 FCCH80_c = 0;
shreeshas95 1:a0055b3280c8 387 FCCH80_f = false;
shreeshas95 1:a0055b3280c8 388 // printf("exit FCCH80\n");
shreeshas95 1:a0055b3280c8 389 if(++Tframe_c != ISR)
ee12b079 9:e9eaada136c6 390 SCH40_f = true;
shreeshas95 1:a0055b3280c8 391 else{
shreeshas95 1:a0055b3280c8 392 Tframe_c = 0;
shreeshas95 1:a0055b3280c8 393 segment_c++;
aniruddhv 52:0bd68655c651 394 if(segment_c >= SEGMENT_NO - 1 && TOTAL_SEGMENT_NO == 0) segment_r = 0; else segment_r = 1;
ee12b079 9:e9eaada136c6 395 if(segment_c == SEGMENT_NO)
shreeshas95 1:a0055b3280c8 396 {eos_f = true;}
shreeshas95 1:a0055b3280c8 397 else{
shreeshas95 1:a0055b3280c8 398 Sframe = true;
shreeshas95 1:a0055b3280c8 399 }
shreeshas95 1:a0055b3280c8 400 }
shreeshas95 1:a0055b3280c8 401 }
shreeshas95 1:a0055b3280c8 402 continue;
ee12b079 9:e9eaada136c6 403 }
ee12b079 9:e9eaada136c6 404
ee12b079 9:e9eaada136c6 405 if(eos_f){
shreeshas95 1:a0055b3280c8 406 transmit[RB_c] = EoS[EOS_c++];
shreeshas95 1:a0055b3280c8 407 if(EOS_c == EOS_SIZE){
shreeshas95 1:a0055b3280c8 408 EOS_c = 0;
shreeshas95 1:a0055b3280c8 409 eos_f = false;
ee12b079 9:e9eaada136c6 410 if(segment_c == SEGMENT_NO && segment_r == 0){
ee12b079 9:e9eaada136c6 411 *last_buffer = true;
ee12b079 9:e9eaada136c6 412 }
ee12b079 9:e9eaada136c6 413 else if(segment_c == SEGMENT_NO && segment_r != 0){
ee12b079 9:e9eaada136c6 414 segment_c = 0;
ee12b079 9:e9eaada136c6 415 SEGMENT_NO = TOTAL_SEGMENT_NO;
ee12b079 9:e9eaada136c6 416 if(SEGMENT_NO > MAX_SEGMENT)
ee12b079 9:e9eaada136c6 417 {
ee12b079 9:e9eaada136c6 418 SEGMENT_NO = MAX_SEGMENT;
ee12b079 9:e9eaada136c6 419 }
aniruddhv 52:0bd68655c651 420 if(SEGMENT_NO == 1) segment_r = 0; else segment_r = 1;
ee12b079 9:e9eaada136c6 421 TOTAL_SEGMENT_NO -= SEGMENT_NO;
ee12b079 9:e9eaada136c6 422 reset_adf = true;//what does this do??
ee12b079 9:e9eaada136c6 423 Sframe = true;
ee12b079 9:e9eaada136c6 424 }
shreeshas95 1:a0055b3280c8 425 junk_f = true;
shreeshas95 1:a0055b3280c8 426 }
shreeshas95 1:a0055b3280c8 427 continue;
ee12b079 9:e9eaada136c6 428 }
shreeshas95 1:a0055b3280c8 429 }
shreeshas95 1:a0055b3280c8 430 differential_encode(transmit,112);
shreeshas95 1:a0055b3280c8 431 if(reset_adf == true){
shreeshas95 1:a0055b3280c8 432 diff_prev = 0;
shreeshas95 1:a0055b3280c8 433 junk_f = false;
shreeshas95 1:a0055b3280c8 434 }
ee12b079 9:e9eaada136c6 435
shreeshas95 1:a0055b3280c8 436 }
ee12b079 9:e9eaada136c6 437
shreeshas95 1:a0055b3280c8 438 };
shreeshas95 1:a0055b3280c8 439 SND_TM snd_tm;