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:
ee12b079
Date:
Sat Mar 12 14:07:32 2016 +0000
Revision:
139:1018e1dc82e9
Parent:
118:60c5de4cb8ad
Child:
142:83f48d1a1bc5
corrected some errors in obsrs.h

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