FreeCalypso > hg > fc-magnetite
comparison src/cs/layer1/cust0/l1_cust.c @ 69:50a15a54801e
src/cs/layer1: import from tcs211-l1-reconst project
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 01 Oct 2016 23:45:38 +0000 |
parents | |
children | daddb933047d |
comparison
equal
deleted
inserted
replaced
68:838717193e09 | 69:50a15a54801e |
---|---|
1 /************* Revision Controle System Header ************* | |
2 * GSM Layer 1 software | |
3 * L1_CUST.C | |
4 * | |
5 * Filename l1_cust.c | |
6 * Version 3.66 | |
7 * Date 03/21/03 | |
8 * | |
9 ************* Revision Controle System Header *************/ | |
10 | |
11 //#define GLOBAL | |
12 | |
13 | |
14 #include "string.h" | |
15 | |
16 #include "l1_confg.h" | |
17 #include "l1_const.h" | |
18 #include "ulpd.h" | |
19 #include "tm_defs.h" | |
20 #include "l1_types.h" | |
21 #include "l1_time.h" | |
22 #include "l1_trace.h" | |
23 #include "sys_types.h" | |
24 #include "sim.h" | |
25 #include "buzzer.h" | |
26 #include "serialswitch.h" | |
27 | |
28 #include "abb.h" | |
29 | |
30 #if TESTMODE | |
31 #include "l1tm_defty.h" | |
32 #endif | |
33 | |
34 #if (AUDIO_TASK == 1) | |
35 #include "l1audio_const.h" | |
36 #include "l1audio_cust.h" | |
37 #include "l1audio_defty.h" | |
38 #endif | |
39 | |
40 #if (L1_GTT == 1) | |
41 #include "l1gtt_const.h" | |
42 #include "l1gtt_defty.h" | |
43 #endif | |
44 #include "l1_defty.h" | |
45 #include "l1_msgty.h" | |
46 #include "l1_tabs.h" | |
47 #include "l1_varex.h" | |
48 | |
49 #if (VCXO_ALGO == 1) | |
50 #include "l1_ctl.h" | |
51 #endif | |
52 | |
53 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2) || (ANLG_FAM == 3)) | |
54 #include "spi_drv.h" | |
55 #endif | |
56 | |
57 #if (RF==35) | |
58 #include "tpudrv35.h" | |
59 #include "l1_rf35.h" | |
60 #include "l1_rf35.c" | |
61 #endif | |
62 | |
63 #if (RF==12) | |
64 #include "tpudrv12.h" | |
65 #include "l1_rf12.h" | |
66 #include "l1_rf12.c" | |
67 #endif | |
68 | |
69 #if (RF==10) | |
70 #include "tpudrv10.h" | |
71 #include "l1_rf10.h" | |
72 #include "l1_rf10.c" | |
73 #endif | |
74 | |
75 #if (RF==8) | |
76 #include "tpudrv8.h" | |
77 #include "l1_rf8.h" | |
78 #include "l1_rf8.c" | |
79 #endif | |
80 | |
81 #if (RF==2) | |
82 #include "l1_rf2.h" | |
83 #include "l1_rf2.c" | |
84 #endif | |
85 | |
86 // Nucleus functions | |
87 extern INT TMD_Timer_State; | |
88 extern UWORD32 TMD_Timer; // for big sleep | |
89 extern UWORD32 TCD_Priority_Groups; | |
90 extern VOID *TCD_Current_Thread; | |
91 extern TC_HCB *TCD_Active_HISR_Heads[TC_HISR_PRIORITIES]; | |
92 extern TC_HCB *TCD_Active_HISR_Tails[TC_HISR_PRIORITIES]; | |
93 extern TC_PROTECT TCD_System_Protect; | |
94 | |
95 #if (L2_L3_SIMUL == 0) | |
96 #define FFS_WORKAROUND 1 | |
97 #else | |
98 #define FFS_WORKAROUND 0 | |
99 #endif | |
100 #if (FFS_WORKAROUND == 1) | |
101 #include "ffs.h" | |
102 #else | |
103 typedef signed int int32; | |
104 typedef signed char effs_t; | |
105 typedef int32 filesize_t; | |
106 effs_t ffs_fwrite(const char *name, void *addr, filesize_t size); | |
107 effs_t ffs_fread(const char *name, void *addr, filesize_t size); | |
108 #endif | |
109 | |
110 // Import band configuration from Flash module (need to replace by an access function) | |
111 //extern UWORD8 std; | |
112 extern T_L1_CONFIG l1_config; | |
113 extern T_L1S_GLOBAL l1s; | |
114 | |
115 #if (CODE_VERSION != SIMULATION) | |
116 // Import serial switch configuration | |
117 extern char ser_cfg_info[2]; | |
118 #endif | |
119 | |
120 void get_cal_from_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id); | |
121 UWORD8 save_cal_in_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id); | |
122 void config_rf_rw_band(char type, UWORD8 read); | |
123 void config_rf_read(char type); | |
124 void config_rf_write(char type); | |
125 | |
126 enum { | |
127 RF_ID = 0, | |
128 ADC_ID = 1 | |
129 }; | |
130 | |
131 /*-------------------------------------------------------*/ | |
132 /* Parameters: none */ | |
133 /* Return: none */ | |
134 /* Functionality: Defines the location of rf-struct */ | |
135 /* for each std. */ | |
136 /*-------------------------------------------------------*/ | |
137 | |
138 const static T_BAND_CONFIG band_config[] = | |
139 { /*ffs name, default addr, max carrier, min tx pwr */ | |
140 {"",(T_RF_BAND *) 0,0,0},//undefined | |
141 {"900", (T_RF_BAND *)&rf_900, 174, 19 },//EGSM | |
142 {"1800",(T_RF_BAND *)&rf_1800, 374, 15 },//DCS | |
143 {"1900",(T_RF_BAND *)&rf_1900, 299, 15 },//PCS | |
144 {"850", (T_RF_BAND *)&rf_850, 124, 19 },//GSM850 | |
145 #if (RF == 10) | |
146 {"1900_us",(T_RF_BAND *)&rf_1900, 299, 15 },//usdual 1900 rf tables are the same as 3band 1900 rf tables at the moment | |
147 #endif | |
148 {"900", (T_RF_BAND *)&rf_900, 124, 19 } //GSM, this should be last entry | |
149 }; | |
150 | |
151 /*-------------------------------------------------------*/ | |
152 /* Parameters: none */ | |
153 /* Return: none */ | |
154 /* Functionality: Defines the indices into band_config */ | |
155 /* for each std. */ | |
156 /*-------------------------------------------------------*/ | |
157 const T_STD_CONFIG std_config[] = | |
158 { | |
159 /* band1 index, band2 index, txpwr turning point, first arfcn*/ | |
160 { 0, 0, 0, 0 }, // std = 0 not used | |
161 { BAND_GSM900, BAND_NONE, 0, 1 }, // std = 1 GSM | |
162 { BAND_EGSM900, BAND_NONE, 0, 1 }, // std = 2 EGSM | |
163 { BAND_PCS1900, BAND_NONE, 21, 512 }, // std = 3 PCS | |
164 { BAND_DCS1800, BAND_NONE, 28, 512 }, // std = 4 DCS | |
165 { BAND_GSM900, BAND_DCS1800, 28, 1 }, // std = 5 DUAL | |
166 { BAND_EGSM900, BAND_DCS1800, 28, 1 }, // std = 6 DUALEXT | |
167 { BAND_GSM850, BAND_NONE, 0, 128 }, // std = 7 850 | |
168 #if (RF == 10) | |
169 { BAND_GSM850, BAND_PCS1900_US, 21, 1 } // std = 8 850/1900 | |
170 #else | |
171 { BAND_GSM850, BAND_PCS1900, 21, 1 } // std = 8 850/1900 | |
172 #endif | |
173 }; | |
174 | |
175 /*-------------------------------------------------------*/ | |
176 /* Prototypes of external functions used in this file. */ | |
177 /*-------------------------------------------------------*/ | |
178 void l1_initialize(T_MMI_L1_CONFIG *mmi_l1_config); | |
179 WORD16 Convert_l1_radio_freq (UWORD16 radio_freq); | |
180 | |
181 /*-------------------------------------------------------*/ | |
182 /* Cust_recover_Os() */ | |
183 /*-------------------------------------------------------*/ | |
184 /* */ | |
185 /* Description: adjust OS from sleep duration */ | |
186 /* ------------ */ | |
187 /* This function fix the : */ | |
188 /* - system clock */ | |
189 /* - Nucleus timers */ | |
190 /* - xxxxxx (customer dependant) */ | |
191 /*-------------------------------------------------------*/ | |
192 | |
193 UWORD8 Cust_recover_Os(void) | |
194 { | |
195 #if (CODE_VERSION != SIMULATION) | |
196 UWORD32 current_system_clock; | |
197 | |
198 /***************************************************/ | |
199 // Fix System clock and Nucleus Timers if any.... */ | |
200 /***************************************************/ | |
201 // Fix System clock .... | |
202 current_system_clock = NU_Retrieve_Clock(); | |
203 current_system_clock += l1s.pw_mgr.sleep_duration; | |
204 NU_Set_Clock(current_system_clock); | |
205 | |
206 // Fix Nucleus timer (if needed) .... | |
207 if (TMD_Timer_State == TM_ACTIVE) | |
208 { | |
209 TMD_Timer -= l1s.pw_mgr.sleep_duration; | |
210 if (!TMD_Timer) TMD_Timer_State = TM_EXPIRED; | |
211 } | |
212 | |
213 /***************************************************/ | |
214 // Cust dependant part ... */ | |
215 /***************************************************/ | |
216 //............. | |
217 //............. | |
218 //.............. | |
219 return(TRUE); | |
220 | |
221 #endif | |
222 } | |
223 | |
224 | |
225 | |
226 /*-------------------------------------------------------*/ | |
227 /* Cust_check_system() */ | |
228 /*-------------------------------------------------------*/ | |
229 /* */ | |
230 /* Description: */ | |
231 /* ------------ */ | |
232 /* GSM 1.5 : */ | |
233 /* - authorize UWIRE clock to be stopped */ | |
234 /* and write value in l1s.pw_mgr.modules_status. */ | |
235 /* - authorize ARMIO clock to be stopped if the light is */ | |
236 /* off and write value in l1s.pw_mgr.modules_status. */ | |
237 /* - check if SIM clock have been stopped */ | |
238 /* before allowing DEEP SLEEP. */ | |
239 /* - check if UARTs are ready to enter deep sleep */ | |
240 /* - choose the sleep mode */ | |
241 /* */ | |
242 /* Return: */ | |
243 /* ------- */ | |
244 /* DO_NOT_SLEEP, FRAME_STOP or CLOCK_STOP */ | |
245 /*-------------------------------------------------------*/ | |
246 UWORD8 Cust_check_system(void) | |
247 { | |
248 extern UWORD8 why_big_sleep; | |
249 #if (CODE_VERSION != SIMULATION) | |
250 #if (L2_L3_SIMUL == 0) | |
251 // Forbid deep sleep if the light is on | |
252 if(LT_Status()) | |
253 { | |
254 //cut ARMIO and UWIRE clocks in big sleep | |
255 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ; | |
256 why_big_sleep = BIG_SLEEP_DUE_TO_LIGHT_ON; | |
257 return(FRAME_STOP); // BIG sleep | |
258 } | |
259 | |
260 // Forbid deep sleep if the SIM and UARTs not ready | |
261 if(SIM_SleepStatus()) | |
262 { | |
263 #endif | |
264 if(SER_UartSleepStatus()) | |
265 { | |
266 return(CLOCK_STOP); // DEEP sleep | |
267 } | |
268 else why_big_sleep = BIG_SLEEP_DUE_TO_UART; | |
269 #if (L2_L3_SIMUL == 0) | |
270 } | |
271 else why_big_sleep = BIG_SLEEP_DUE_TO_SIM; | |
272 #endif | |
273 // cut ARMIO and UWIRE clocks in big sleep | |
274 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ; | |
275 return(FRAME_STOP); // BIG sleep | |
276 #else // Simulation part | |
277 return(CLOCK_STOP); // DEEP sleep | |
278 #endif | |
279 } | |
280 | |
281 | |
282 /*-------------------------------------------------------*/ | |
283 /* Parameters: none */ | |
284 /* Return: none */ | |
285 /* Functionality: Read the RF configuration, tables etc. */ | |
286 /* from FFS files. */ | |
287 /*-------------------------------------------------------*/ | |
288 const static T_CONFIG_FILE config_files_common[] = | |
289 { | |
290 #if (CODE_VERSION != SIMULATION) | |
291 | |
292 // The first char is NOT part of the filename. It is used for | |
293 // categorizing the ffs file contents: | |
294 // f=rf-cal, F=rf-config, | |
295 // t=tx-cal, T=tx-config, | |
296 // r=rx-cal, R=rx-config, | |
297 // s=sys-cal, S=sys-config, | |
298 "f/gsm/rf/afcdac", &rf.afc.eeprom_afc, sizeof(rf.afc.eeprom_afc), | |
299 "F/gsm/rf/stdmap", &rf.radio_band_support, sizeof(rf.radio_band_support), | |
300 #if (VCXO_ALGO == 1) | |
301 "F/gsm/rf/afcparams", &rf.afc.psi_sta_inv, 4 * sizeof(UWORD32) + 4 * sizeof(WORD16), | |
302 #else | |
303 "F/gsm/rf/afcparams", &rf.afc.psi_sta_inv, 4 * sizeof(UWORD32), | |
304 #endif | |
305 | |
306 "R/gsm/rf/rx/agcglobals", &rf.rx.agc, 4 * sizeof(UWORD16), | |
307 "R/gsm/rf/rx/il2agc", &rf.rx.agc.il2agc_pwr[0], 3 * sizeof(rf.rx.agc.il2agc_pwr), | |
308 "R/gsm/rf/rx/agcwords", &AGC_TABLE, sizeof(AGC_TABLE), | |
309 | |
310 "s/sys/adccal", &adc_cal, sizeof(adc_cal), | |
311 | |
312 "S/sys/abb", &abb, sizeof(abb), | |
313 "S/sys/uartswitch", &ser_cfg_info, sizeof(ser_cfg_info), | |
314 | |
315 #endif | |
316 NULL, 0, 0 // terminator | |
317 }; | |
318 | |
319 /*-------------------------------------------------------*/ | |
320 /* Parameters: none */ | |
321 /* Return: none */ | |
322 /* Functionality: Read the RF configurations for */ | |
323 /* each band from FFS files. These files */ | |
324 /* are defined for one band, and and used */ | |
325 /* for all bands. */ | |
326 /*-------------------------------------------------------*/ | |
327 const static T_CONFIG_FILE config_files_band[] = | |
328 { | |
329 // The first char is NOT part of the filename. It is used for | |
330 // categorizing the ffs file contents: | |
331 // f=rf-cal, F=rf-config, | |
332 // t=tx-cal, T=tx-config, | |
333 // r=rx-cal, R=rx-config, | |
334 // s=sys-cal, S=sys-config, | |
335 | |
336 // generic for all bands | |
337 // band[0] is used as template for all bands. | |
338 "t/gsm/rf/tx/ramps", &rf_band[0].tx.ramp_tables, sizeof(rf_band[0].tx.ramp_tables), | |
339 "t/gsm/rf/tx/levels", &rf_band[0].tx.levels, sizeof(rf_band[0].tx.levels), | |
340 "t/gsm/rf/tx/calchan", &rf_band[0].tx.chan_cal_table, sizeof(rf_band[0].tx.chan_cal_table), | |
341 "T/gsm/rf/tx/caltemp", &rf_band[0].tx.temp, sizeof(rf_band[0].tx.temp), | |
342 | |
343 "r/gsm/rf/rx/calchan", &rf_band[0].rx.agc_bands, sizeof(rf_band[0].rx.agc_bands), | |
344 "R/gsm/rf/rx/caltemp", &rf_band[0].rx.temp, sizeof(rf_band[0].rx.temp), | |
345 "r/gsm/rf/rx/agcparams", &rf_band[0].rx.rx_cal_params, sizeof(rf_band[0].rx.rx_cal_params), | |
346 NULL, 0, 0 // terminator | |
347 }; | |
348 | |
349 void config_ffs_read(char type) | |
350 { | |
351 config_rf_read(type); | |
352 config_rf_rw_band(type, 1); | |
353 } | |
354 | |
355 void config_ffs_write(char type) | |
356 { | |
357 config_rf_write(type); | |
358 config_rf_rw_band(type, 0); | |
359 } | |
360 | |
361 void config_rf_read(char type) | |
362 { | |
363 const T_CONFIG_FILE *file = config_files_common; | |
364 | |
365 while (file->name != NULL) | |
366 { | |
367 if (type == '*' || type == file->name[0]) { | |
368 ffs_fread(&file->name[1], file->addr, file->size); | |
369 } | |
370 file++; | |
371 } | |
372 } | |
373 | |
374 void config_rf_write(char type) | |
375 { | |
376 const T_CONFIG_FILE *file = config_files_common; | |
377 | |
378 while (file->name != NULL) | |
379 { | |
380 if (type == '*' || type == file->name[0]) { | |
381 ffs_fwrite(&file->name[1], file->addr, file->size); | |
382 } | |
383 file++; | |
384 } | |
385 } | |
386 | |
387 void config_rf_rw_band(char type, UWORD8 read) | |
388 { | |
389 const T_CONFIG_FILE *f1 = config_files_band; | |
390 UWORD8 i; | |
391 WORD32 offset; | |
392 char name[64]; | |
393 char *p; | |
394 UWORD8 std = l1_config.std.id; | |
395 | |
396 #if FFS_WORKAROUND == 1 | |
397 struct stat_s stat; | |
398 UWORD16 time; | |
399 #endif | |
400 for (i=0; i< GSM_BANDS; i++) | |
401 { | |
402 if(std_config[std].band[i] !=0 ) | |
403 { | |
404 f1 = &config_files_band[0]; | |
405 while (f1->name != NULL) | |
406 { | |
407 offset = (WORD32) f1->addr - (WORD32) &rf_band[0]; //offset in bytes | |
408 p = ((char *) &rf_band[i]) + offset; | |
409 if (type == '*' || type == f1->name[0]) | |
410 { | |
411 strcpy(name, &f1->name[1]); | |
412 strcat(name, "."); | |
413 strcat(name, band_config[std_config[std].band[i]].name); | |
414 | |
415 if (read == 1) | |
416 ffs_fread(name, p, f1->size); | |
417 else //write == 0 | |
418 { | |
419 ffs_fwrite(name, p, f1->size); | |
420 | |
421 // wait until ffs write has finished | |
422 #if FFS_WORKAROUND == 1 | |
423 stat.inode = 0; | |
424 time = 0; | |
425 | |
426 do { | |
427 rvf_delay(10); // in milliseconds | |
428 time += 10; | |
429 ffs_stat(name, &stat); | |
430 } while (stat.inode == 0 && time < 500); | |
431 #endif | |
432 } | |
433 } | |
434 f1++; | |
435 } | |
436 } | |
437 } | |
438 } | |
439 | |
440 /*-------------------------------------------------------*/ | |
441 /* Cust_init_std() */ | |
442 /*-------------------------------------------------------*/ | |
443 /* Parameters : */ | |
444 /* Return : */ | |
445 /* Functionality : Init Standard variable configuration */ | |
446 /*-------------------------------------------------------*/ | |
447 void Cust_init_std(void) | |
448 { | |
449 UWORD8 std = l1_config.std.id; | |
450 UWORD8 band1, band2; | |
451 T_RF_BAND *pt1, *pt2; | |
452 | |
453 band1 = std_config[std].band[0]; | |
454 band2 = std_config[std].band[1]; | |
455 | |
456 //get these from std | |
457 pt1 = band_config[band1].addr; | |
458 pt2 = band_config[band2].addr; | |
459 | |
460 // copy rf-struct from default flash to ram | |
461 memcpy(&rf_band[0], pt1, sizeof(T_RF_BAND)); | |
462 | |
463 if(std_config[std].band[1] != BAND_NONE ) | |
464 memcpy(&rf_band[1], pt2, sizeof(T_RF_BAND)); | |
465 | |
466 // Read all RF and system configuration from FFS *before* we copy any of | |
467 // the rf structure variables to other places, like L1. | |
468 | |
469 config_ffs_read('*'); | |
470 | |
471 l1_config.std.first_radio_freq = std_config[std].first_arfcn; | |
472 | |
473 if(band2!=0) | |
474 l1_config.std.first_radio_freq_band2 = band_config[band1].max_carrier + 1; | |
475 else | |
476 l1_config.std.first_radio_freq_band2 = 0; //band1 carrier + 1 else 0 | |
477 | |
478 // if band2 is not used it is initialised with zeros | |
479 l1_config.std.nbmax_carrier = band_config[band1].max_carrier; | |
480 if(band2!=0) | |
481 l1_config.std.nbmax_carrier += band_config[band2].max_carrier; | |
482 | |
483 l1_config.std.max_txpwr_band1 = band_config[band1].max_txpwr; | |
484 l1_config.std.max_txpwr_band2 = band_config[band2].max_txpwr; | |
485 l1_config.std.txpwr_turning_point = std_config[std].txpwr_tp; | |
486 l1_config.std.cal_freq1_band1 = 0; | |
487 l1_config.std.cal_freq1_band2 = 0; | |
488 | |
489 l1_config.std.g_magic_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.g_magic; | |
490 l1_config.std.lna_att_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.lna_att; | |
491 l1_config.std.lna_switch_thr_low_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.lna_switch_thr_low; | |
492 l1_config.std.lna_switch_thr_high_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.lna_switch_thr_high; | |
493 l1_config.std.swap_iq_band1 = rf_band[MULTI_BAND1].swap_iq; | |
494 | |
495 l1_config.std.g_magic_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.g_magic; | |
496 l1_config.std.lna_att_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.lna_att; | |
497 l1_config.std.lna_switch_thr_low_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.lna_switch_thr_low; | |
498 l1_config.std.lna_switch_thr_high_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.lna_switch_thr_high; | |
499 l1_config.std.swap_iq_band2 = rf_band[MULTI_BAND2].swap_iq; | |
500 | |
501 l1_config.std.radio_freq_index_offset = l1_config.std.first_radio_freq-1; | |
502 | |
503 // init variable indicating which radio bands are supported by the chosen RF | |
504 l1_config.std.radio_band_support = rf.radio_band_support; | |
505 } | |
506 | |
507 | |
508 /*-------------------------------------------------------*/ | |
509 /* Cust_init_params() */ | |
510 /*-------------------------------------------------------*/ | |
511 /* Parameters : */ | |
512 /* Return : */ | |
513 /* Functionality : Init RF dependent paramters (AGC, TX) */ | |
514 /*-------------------------------------------------------*/ | |
515 void Cust_init_params(void) | |
516 { | |
517 | |
518 #if (CODE_VERSION==SIMULATION) | |
519 extern UWORD16 simu_RX_SYNTH_SETUP_TIME; // set in xxx.txt l3 scenario file | |
520 extern UWORD16 simu_TX_SYNTH_SETUP_TIME; // set in xxx.txt l3 scenario file | |
521 | |
522 l1_config.params.rx_synth_setup_time = simu_RX_SYNTH_SETUP_TIME; | |
523 l1_config.params.tx_synth_setup_time = simu_TX_SYNTH_SETUP_TIME; | |
524 #else | |
525 l1_config.params.rx_synth_setup_time = RX_SYNTH_SETUP_TIME; | |
526 l1_config.params.tx_synth_setup_time = TX_SYNTH_SETUP_TIME; | |
527 #endif | |
528 | |
529 | |
530 // Convert SYNTH_SETUP_TIME into SPLIT. | |
531 // We have kept a margin of 20qbit (EPSILON_MEAS) to cover offset change and Scenario closing time + margin. | |
532 l1_config.params.rx_synth_load_split = 1L + (l1_config.params.rx_synth_setup_time + EPSILON_MEAS) / (BP_DURATION/BP_SPLIT); | |
533 l1_config.params.tx_synth_load_split = 1L + (l1_config.params.tx_synth_setup_time + EPSILON_MEAS) / (BP_DURATION/BP_SPLIT); | |
534 | |
535 l1_config.params.rx_synth_start_time = TPU_CLOCK_RANGE + PROVISION_TIME - l1_config.params.rx_synth_setup_time; | |
536 l1_config.params.tx_synth_start_time = TPU_CLOCK_RANGE - l1_config.params.tx_synth_setup_time; | |
537 | |
538 l1_config.params.rx_change_synchro_time = l1_config.params.rx_synth_start_time - EPSILON_SYNC; | |
539 l1_config.params.rx_change_offset_time = l1_config.params.rx_synth_start_time - EPSILON_OFFS; | |
540 | |
541 l1_config.params.tx_change_offset_time = TIME_OFFSET_TX - | |
542 TA_MAX - | |
543 l1_config.params.tx_synth_setup_time - | |
544 EPSILON_OFFS; | |
545 | |
546 // TX duration = ramp up time + burst duration (data + tail bits) | |
547 l1_config.params.tx_nb_duration = UL_ABB_DELAY + rf.tx.guard_bits*4 + NB_BURST_DURATION_UL; | |
548 l1_config.params.tx_ra_duration = UL_ABB_DELAY + rf.tx.guard_bits*4 + RA_BURST_DURATION; | |
549 | |
550 l1_config.params.tx_nb_load_split = 1L + (l1_config.params.tx_nb_duration - rf.tx.prg_tx - NB_MARGIN) / (BP_DURATION/BP_SPLIT); | |
551 l1_config.params.tx_ra_load_split = 1L + (l1_config.params.tx_ra_duration - rf.tx.prg_tx - NB_MARGIN) / (BP_DURATION/BP_SPLIT); | |
552 | |
553 // time for the end of RX and TX TPU scenarios | |
554 l1_config.params.rx_tpu_scenario_ending = RX_TPU_SCENARIO_ENDING; | |
555 l1_config.params.tx_tpu_scenario_ending = TX_TPU_SCENARIO_ENDING; | |
556 | |
557 // FB26 anchoring time is computed backward to leave only 6 qbit margin between | |
558 // FB26 window and next activity (RX time tracking). | |
559 // This margin is used as follow: | |
560 // Serving offset restore: 1 qbit (SERV_OFFS_REST_LOAD) | |
561 // Tpu Sleep: 2 qbit (TPU_SLEEP_LOAD) | |
562 // --------- | |
563 // Total: 3 qbit | |
564 | |
565 l1_config.params.fb26_anchoring_time = (l1_config.params.rx_synth_start_time - | |
566 #if (CODE_VERSION == SIMULATION) | |
567 // simulator: end of scenario not included in window (no serialization) | |
568 1 - | |
569 #else | |
570 // RF dependent end of RX TPU scenario | |
571 l1_config.params.rx_tpu_scenario_ending - | |
572 #endif | |
573 EPSILON_SYNC - | |
574 TPU_SLEEP_LOAD - | |
575 SERV_OFFS_REST_LOAD - | |
576 FB26_ACQUIS_DURATION - | |
577 PROVISION_TIME + | |
578 TPU_CLOCK_RANGE) % TPU_CLOCK_RANGE; | |
579 | |
580 l1_config.params.fb26_change_offset_time = l1_config.params.fb26_anchoring_time + | |
581 PROVISION_TIME - | |
582 l1_config.params.rx_synth_setup_time - | |
583 EPSILON_OFFS; | |
584 | |
585 l1_config.params.guard_bits = rf.tx.guard_bits; | |
586 | |
587 l1_config.params.prg_tx_gsm = rf.tx.prg_tx; | |
588 l1_config.params.prg_tx_dcs = rf.tx.prg_tx; //delay for dual band not implemented yet | |
589 | |
590 l1_config.params.low_agc_noise_thr = rf.rx.agc.low_agc_noise_thr; | |
591 l1_config.params.high_agc_sat_thr = rf.rx.agc.high_agc_sat_thr; | |
592 l1_config.params.low_agc = rf.rx.agc.low_agc; | |
593 l1_config.params.high_agc = rf.rx.agc.high_agc; | |
594 l1_config.params.il_min = IL_MIN; | |
595 | |
596 l1_config.params.fixed_txpwr = FIXED_TXPWR; | |
597 l1_config.params.eeprom_afc = rf.afc.eeprom_afc; | |
598 l1_config.params.setup_afc_and_rf = SETUP_AFC_AND_RF; | |
599 | |
600 l1_config.params.psi_sta_inv = rf.afc.psi_sta_inv; | |
601 l1_config.params.psi_st = rf.afc.psi_st; | |
602 l1_config.params.psi_st_32 = rf.afc.psi_st_32; | |
603 l1_config.params.psi_st_inv = rf.afc.psi_st_inv; | |
604 | |
605 #if (CODE_VERSION == SIMULATION) | |
606 #if (VCXO_ALGO == 1) | |
607 l1_config.params.afc_algo = ALGO_AFC_LQG_PREDICTOR; // VCXO|VCTCXO - Choosing AFC algorithm | |
608 #endif | |
609 #else | |
610 #if (VCXO_ALGO == 1) | |
611 l1_config.params.afc_dac_center = rf.afc.dac_center; // VCXO - assuming DAC linearity | |
612 l1_config.params.afc_dac_min = rf.afc.dac_min; // VCXO - assuming DAC linearity | |
613 l1_config.params.afc_dac_max = rf.afc.dac_max; // VCXO - assuming DAC linearity | |
614 l1_config.params.afc_snr_thr = rf.afc.snr_thr; // VCXO - SNR threshold | |
615 l1_config.params.afc_algo = ALGO_AFC_LQG_PREDICTOR; // VCXO|VCTCXO - Choosing AFC algorithm | |
616 l1_config.params.afc_win_avg_size_M = C_WIN_AVG_SIZE_M; // VCXO - Average psi values with this value | |
617 l1_config.params.rgap_algo = ALGO_AFC_RXGAP; // VCXO - Choosing Reception Gap algorithm | |
618 l1_config.params.rgap_bad_snr_count_B = C_RGAP_BAD_SNR_COUNT_B; // VCXO - Prediction SNR count | |
619 #endif | |
620 #endif | |
621 | |
622 #if DCO_ALGO | |
623 #if (RF == 10) | |
624 // Enable DCO algorithm for direct conversion RFs | |
625 l1_config.params.dco_enabled = TRUE; | |
626 #else | |
627 l1_config.params.dco_enabled = FALSE; | |
628 #endif | |
629 #endif | |
630 | |
631 #if (ANLG_FAM == 1) | |
632 l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG | |
633 l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset | |
634 l1_config.params.vbuctrl = abb[ABB_VBUCTRL]; // Uplink gain amp 0dB, Sidetone gain to mute | |
635 l1_config.params.vbdctrl = abb[ABB_VBDCTRL]; // Downlink gain amp 0dB, Volume control 0 dB | |
636 l1_config.params.bbctrl = abb[ABB_BBCTRL]; // value at reset | |
637 l1_config.params.apcoff = abb[ABB_APCOFF]; // value at reset | |
638 l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset | |
639 l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset | |
640 l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset | |
641 l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset | |
642 l1_config.params.vbctrl = abb[ABB_VBCTRL]; // VULSWITCH=0, VDLAUX=1, VDLEAR=1 | |
643 l1_config.params.apcdel1 = abb[ABB_APCDEL1]; // value at reset | |
644 #endif | |
645 #if (ANLG_FAM == 2) | |
646 l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG | |
647 l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset | |
648 l1_config.params.vbuctrl = abb[ABB_VBUCTRL]; // Uplink gain amp 0dB, Sidetone gain to mute | |
649 l1_config.params.vbdctrl = abb[ABB_VBDCTRL]; // Downlink gain amp 0dB, Volume control 0 dB | |
650 l1_config.params.bbctrl = abb[ABB_BBCTRL]; // value at reset | |
651 l1_config.params.bulgcal = abb[ABB_BULGCAL]; // value at reset | |
652 l1_config.params.apcoff = abb[ABB_APCOFF]; // value at reset | |
653 l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset | |
654 l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset | |
655 l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset | |
656 l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset | |
657 l1_config.params.vbctrl1 = abb[ABB_VBCTRL1]; // VULSWITCH=0, VDLAUX=1, VDLEAR=1 | |
658 l1_config.params.vbctrl2 = abb[ABB_VBCTRL2]; // MICBIASEL=0, VDLHSO=0, MICAUX=0 | |
659 l1_config.params.apcdel1 = abb[ABB_APCDEL1]; // value at reset | |
660 l1_config.params.apcdel2 = abb[ABB_APCDEL2]; // value at reset | |
661 #endif | |
662 #if (ANLG_FAM == 3) | |
663 l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG | |
664 l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset | |
665 l1_config.params.vbuctrl = abb[ABB_VBUCTRL]; // Uplink gain amp 0dB, Sidetone gain to mute | |
666 l1_config.params.vbdctrl = abb[ABB_VBDCTRL]; // Downlink gain amp 0dB, Volume control 0 dB | |
667 l1_config.params.bbctrl = abb[ABB_BBCTRL]; // value at reset | |
668 l1_config.params.bulgcal = abb[ABB_BULGCAL]; // value at reset | |
669 l1_config.params.apcoff = abb[ABB_APCOFF]; // X2 Slope 128 and APCSWP disabled | |
670 l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset | |
671 l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset | |
672 l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset | |
673 l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset | |
674 l1_config.params.vbctrl1 = abb[ABB_VBCTRL1]; // VULSWITCH=0 | |
675 l1_config.params.vbctrl2 = abb[ABB_VBCTRL2]; // MICBIASEL=0, VDLHSO=0, MICAUX=0 | |
676 l1_config.params.apcdel1 = abb[ABB_APCDEL1]; // value at reset | |
677 l1_config.params.apcdel2 = abb[ABB_APCDEL2]; // value at reset | |
678 l1_config.params.vbpop = abb[ABB_VBPOP]; // HSOAUTO enabled | |
679 l1_config.params.vau_delay_init = abb[ABB_VAUDINITD]; // 2 TDMA Frames between VDL "ON" and VDLHSO "ON" | |
680 l1_config.params.vaud_cfg = abb[ABB_VAUDCTRL]; // value at reset | |
681 l1_config.params.vauo_onoff = abb[ABB_VAUOCTRL]; // speech on AUX and EAR | |
682 l1_config.params.vaus_vol = abb[ABB_VAUSCTRL]; // value at reset | |
683 l1_config.params.vaud_pll = abb[ABB_VAUDPLL]; // value at reset | |
684 #endif | |
685 | |
686 #if 0 /* present in MV100 version, but not in TCS211 */ | |
687 // global variable for access to deep sleep time | |
688 l1_config.params.sleep_time = 0; | |
689 #endif | |
690 } | |
691 | |
692 | |
693 /************************************/ | |
694 /* Automatic Gain Control */ | |
695 /************************************/ | |
696 | |
697 /*-------------------------------------------------------*/ | |
698 /* Cust_get_agc_from_IL() */ | |
699 /*-------------------------------------------------------*/ | |
700 /* Parameters : */ | |
701 /* Return : */ | |
702 /* Functionality : returns agc value */ | |
703 /*-------------------------------------------------------*/ | |
704 WORD8 Cust_get_agc_from_IL(UWORD16 radio_freq, UWORD16 agc_index, UWORD8 table_id) | |
705 { | |
706 WORD8 agc_value; | |
707 | |
708 // radio_freq currently not used | |
709 // this parameter is passed in order to allow band dependent tables for specific RFs | |
710 // (e.g. dual band RF with separate AGC H/W blocks for GSM and DCS) | |
711 | |
712 if (agc_index > 120) | |
713 agc_index = 120; // Clip agc_index | |
714 | |
715 switch (table_id) | |
716 { | |
717 case MAX_ID: | |
718 agc_value = rf.rx.agc.il2agc_max[agc_index]; | |
719 break; | |
720 case AV_ID: | |
721 agc_value = rf.rx.agc.il2agc_av[agc_index]; | |
722 break; | |
723 case PWR_ID: | |
724 agc_value = rf.rx.agc.il2agc_pwr[agc_index]; | |
725 break; | |
726 } | |
727 | |
728 return agc_value; | |
729 } | |
730 | |
731 /*-------------------------------------------------------*/ | |
732 /* Cust_get_agc_band */ | |
733 /*-------------------------------------------------------*/ | |
734 /* Parameters : radio_freq */ | |
735 /* Return : band number */ | |
736 /* Functionality : Computes the band for RF calibration */ | |
737 /*-------------------------------------------------------*/ | |
738 /*---------------------------------------------*/ | |
739 | |
740 | |
741 #if (CODE_VERSION == SIMULATION) | |
742 UWORD16 Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band) | |
743 #else | |
744 UWORD16 inline Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band) | |
745 #endif | |
746 { | |
747 WORD32 i ; | |
748 | |
749 for (i=0;i<RF_RX_CAL_CHAN_SIZE;i++) | |
750 { | |
751 if (arfcn <= rf_band[gsm_band].rx.agc_bands[i].upper_bound) | |
752 return(i); | |
753 } | |
754 // Should never happen! | |
755 return(0); | |
756 } | |
757 | |
758 /*-------------------------------------------------------*/ | |
759 /* Cust_is_band_high */ | |
760 /*-------------------------------------------------------*/ | |
761 /* Parameters : arfcn */ | |
762 /* Return : 0 if low band */ | |
763 /* 1 if high band */ | |
764 /* Functionality : Generic function which return 1 if */ | |
765 /* arfcn is in the high band */ | |
766 /*-------------------------------------------------------*/ | |
767 | |
768 UWORD8 Cust_is_band_high(UWORD16 radio_freq) | |
769 { | |
770 UWORD16 max_carrier; | |
771 UWORD8 std = l1_config.std.id; | |
772 | |
773 max_carrier = band_config[std_config[std].band[0]].max_carrier; | |
774 | |
775 return(((radio_freq >= l1_config.std.first_radio_freq) && | |
776 (radio_freq < (l1_config.std.first_radio_freq + max_carrier))) ? MULTI_BAND1 : MULTI_BAND2); | |
777 } | |
778 | |
779 /*-------------------------------------------------------*/ | |
780 /* l1ctl_encode_delta2() */ | |
781 /*-------------------------------------------------------*/ | |
782 /* Parameters : */ | |
783 /* Return : */ | |
784 /* Functionality : */ | |
785 /*-------------------------------------------------------*/ | |
786 WORD8 l1ctl_encode_delta2(UWORD16 radio_freq) | |
787 { | |
788 WORD8 delta2_freq; | |
789 UWORD16 i; | |
790 UWORD16 arfcn; | |
791 UWORD8 band; | |
792 | |
793 band = Cust_is_band_high(radio_freq); | |
794 arfcn = Convert_l1_radio_freq(radio_freq); | |
795 | |
796 i = Cust_get_agc_band(arfcn,band); // | |
797 delta2_freq = rf_band[band].rx.agc_bands[i].agc_calib; | |
798 | |
799 //temperature compensation | |
800 for (i=0;i<RF_RX_CAL_TEMP_SIZE;i++) | |
801 { | |
802 if ((WORD16)adc.converted[ADC_RFTEMP] <= rf_band[band].rx.temp[i].temperature) | |
803 { | |
804 delta2_freq += rf_band[band].rx.temp[i].agc_calib; | |
805 break; | |
806 } | |
807 } | |
808 | |
809 return(delta2_freq); | |
810 } | |
811 | |
812 /************************************/ | |
813 /* TX Management */ | |
814 /************************************/ | |
815 /*-------------------------------------------------------*/ | |
816 /* Cust_get_ramp_tab */ | |
817 /*-------------------------------------------------------*/ | |
818 /* Parameters : */ | |
819 /* Return : */ | |
820 /* Functionality : */ | |
821 /*-------------------------------------------------------*/ | |
822 | |
823 void Cust_get_ramp_tab(API *a_ramp, UWORD8 txpwr_ramp_up, UWORD8 txpwr_ramp_down, UWORD16 radio_freq) | |
824 { | |
825 UWORD16 index_up, index_down, j; | |
826 UWORD8 band; | |
827 | |
828 band = Cust_is_band_high(radio_freq); | |
829 | |
830 index_up = rf_band[band].tx.levels[txpwr_ramp_up].ramp_index; | |
831 index_down = rf_band[band].tx.levels[txpwr_ramp_down].ramp_index; | |
832 | |
833 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2) || (ANLG_FAM == 3)) | |
834 for (j=0; j<16; j++) | |
835 { | |
836 a_ramp[j]=((rf_band[band].tx.ramp_tables[index_down].ramp_down[j])<<11) | | |
837 ((rf_band[band].tx.ramp_tables[index_up].ramp_up[j]) << 6) | | |
838 0x14; | |
839 } | |
840 #endif | |
841 } | |
842 | |
843 /*-------------------------------------------------------*/ | |
844 /* get_pwr_data */ | |
845 /*-------------------------------------------------------*/ | |
846 /* Parameters : */ | |
847 /* Return : */ | |
848 /* Functionality : */ | |
849 /*-------------------------------------------------------*/ | |
850 | |
851 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2) || (ANLG_FAM == 3)) | |
852 UWORD16 Cust_get_pwr_data(UWORD8 txpwr, UWORD16 radio_freq) | |
853 { | |
854 | |
855 UWORD16 i,j; | |
856 UWORD16 arfcn; | |
857 UWORD8 band; | |
858 | |
859 #if(ORDER2_TX_TEMP_CAL==1) | |
860 WORD16 pwr_data; | |
861 #else | |
862 UWORD16 pwr_data; | |
863 #endif | |
864 | |
865 band = Cust_is_band_high(radio_freq); | |
866 arfcn = Convert_l1_radio_freq(radio_freq); | |
867 | |
868 i = rf_band[band].tx.levels[txpwr].chan_cal_index; | |
869 j=0; | |
870 // get uncalibrated apc | |
871 pwr_data = rf_band[band].tx.levels[txpwr].apc; | |
872 | |
873 while (arfcn > rf_band[band].tx.chan_cal_table[i][j].arfcn_limit) | |
874 j++; | |
875 | |
876 // channel calibrate apc | |
877 pwr_data = ((UWORD32) (pwr_data * rf_band[band].tx.chan_cal_table[i][j].chan_cal))/128; | |
878 | |
879 // temperature compensate apc | |
880 { | |
881 T_TX_TEMP_CAL *pt; | |
882 | |
883 pt = rf_band[band].tx.temp; | |
884 while (((WORD16)adc.converted[ADC_RFTEMP] > pt->temperature) && ((pt-rf_band[band].tx.temp) < (RF_TX_CAL_TEMP_SIZE-1))) | |
885 pt++; | |
886 #if(ORDER2_TX_TEMP_CAL==1) | |
887 pwr_data += (txpwr*(pt->a*txpwr + pt->b) + pt->c) / 64; //delta apc = ax^2+bx+c | |
888 if(pwr_data < 0) pwr_data = 0; | |
889 #else | |
890 pwr_data += pt->apc_calib; | |
891 #endif | |
892 } | |
893 return(pwr_data); | |
894 } | |
895 #endif | |
896 /*-------------------------------------------------------*/ | |
897 /* Cust_Init_Layer1 */ | |
898 /*-------------------------------------------------------*/ | |
899 /* Parameters : */ | |
900 /* Return : */ | |
901 /* Functionality : Load and boot the DSP */ | |
902 /* Initialize shared memory and L1 data structures */ | |
903 /*-------------------------------------------------------*/ | |
904 | |
905 void Cust_Init_Layer1(void) | |
906 { | |
907 T_MMI_L1_CONFIG cfg; | |
908 | |
909 // Get the current band configuration from the flash | |
910 #if (OP_WCP==1) | |
911 extern unsigned char ffs_GetBand(); | |
912 cfg.std = ffs_GetBand(); | |
913 #else // NO OP_WCP | |
914 // cfg.std = std; | |
915 cfg.std = STD; | |
916 #endif // OP_WCP | |
917 | |
918 cfg.tx_pwr_code = 1; | |
919 | |
920 // sleep management configuration | |
921 cfg.pwr_mngt = 0; | |
922 cfg.pwr_mngt_mode_authorized = NO_SLEEP; //Sleep mode | |
923 cfg.pwr_mngt_clocks = 0x5ff; // list of clocks cut in Big Sleep | |
924 | |
925 | |
926 | |
927 #if (CODE_VERSION != SIMULATION) | |
928 cfg.dwnld = DWNLD; //external define from makefile | |
929 #endif | |
930 | |
931 l1_initialize(&cfg); | |
932 | |
933 get_cal_from_nvmem((UWORD8 *)&rf, sizeof(rf), RF_ID); | |
934 get_cal_from_nvmem((UWORD8 *)&adc_cal, sizeof(adc_cal), ADC_ID); | |
935 | |
936 } | |
937 | |
938 | |
939 /*****************************************************************************************/ | |
940 /*************************** TESTMODE functions **********************************/ | |
941 /*****************************************************************************************/ | |
942 | |
943 | |
944 | |
945 /*------------------------------------------------------*/ | |
946 /* madc_hex_2_physical */ | |
947 /*------------------------------------------------------*/ | |
948 /* Parameters : */ | |
949 /* Return : */ | |
950 /* Functionality : Function to convert MAD hexadecimal */ | |
951 /* values into physical values */ | |
952 /*------------------------------------------------------*/ | |
953 | |
954 void madc_hex_2_physical (UWORD16 *adc_hex, T_ADC *adc_phy) | |
955 { | |
956 WORD16 i; | |
957 UWORD16 y; | |
958 WORD16 Smin = 0, Smax = TEMP_TABLE_SIZE-1; | |
959 WORD16 index = (TEMP_TABLE_SIZE-1)/2; /* y is the adc code after compensation of ADC slope error introduced by VREF error */ | |
960 | |
961 //store raw ADC values | |
962 memcpy(&adc.raw[0], adc_hex, sizeof(adc.raw)); | |
963 | |
964 // Convert Vbat [mV] : direct equation with slope and offset compensation | |
965 for (i = ADC_VBAT; i<ADC_RFTEMP; i++) | |
966 adc.converted[i] = (((UWORD32)(adc_cal.a[i] * adc.raw[i])) >>10) + adc_cal.b[i]; | |
967 | |
968 /*Convert RF Temperature [Celsius]: binsearch into a table*/ | |
969 y = ((UWORD32)(adc_cal.a[ADC_RFTEMP] * adc.raw[ADC_RFTEMP]))>>8; /* rf.tempcal is the calibration of VREF*/ | |
970 while((Smax-Smin) > 1 ) | |
971 { | |
972 if(y < temperature[index].adc) | |
973 Smax=index; | |
974 else | |
975 Smin=index; | |
976 | |
977 index = (Smax+Smin)/2; | |
978 } | |
979 adc.converted[ADC_RFTEMP] = temperature[index].temp; | |
980 | |
981 for (i = ADC_RFTEMP+1; i<ADC_INDEX_END; i++) | |
982 adc.converted[i] = (((UWORD32)(adc_cal.a[i] * adc.raw[i])) >>10) + adc_cal.b[i]; | |
983 | |
984 //store converted ADC values | |
985 memcpy(adc_phy, &adc.converted[0], sizeof(adc.raw)); | |
986 } | |
987 | |
988 | |
989 /*------------------------------------------------------*/ | |
990 /* get_cal_from_nvmem */ | |
991 /*------------------------------------------------------*/ | |
992 /* Parameters : */ | |
993 /* Return : */ | |
994 /* Functionality : Copy calibrated parameter to */ | |
995 /* calibration structure in RAM */ | |
996 /*------------------------------------------------------*/ | |
997 | |
998 void get_cal_from_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id) | |
999 { | |
1000 | |
1001 } | |
1002 | |
1003 /*------------------------------------------------------*/ | |
1004 /* save_cal_from_nvmem */ | |
1005 /*------------------------------------------------------*/ | |
1006 /* Parameters : */ | |
1007 /* Return : */ | |
1008 /* Functionality : Copy calibrated structure from RAM */ | |
1009 /* into NV memory */ | |
1010 /*------------------------------------------------------*/ | |
1011 | |
1012 UWORD8 save_cal_in_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id) | |
1013 { | |
1014 #if (OP_WCP == 1) | |
1015 // FFS backup implementation an Avenger 2 | |
1016 // Request MPU-S to backup the FFS | |
1017 // after full calibration of device | |
1018 extern void ffs_backup(void); | |
1019 ffs_backup(); | |
1020 #endif | |
1021 return (0); | |
1022 } | |
1023 | |
1024 #if (TRACE_TYPE == 4) | |
1025 | |
1026 /*------------------------------------------------------*/ | |
1027 /* l1_cst_l1_parameters */ | |
1028 /*------------------------------------------------------*/ | |
1029 /* Parameters : s: pointer on configuration string */ | |
1030 /* Return : nothing: global var are set */ | |
1031 /* Functionality : Set global L1 vars for dynamic trace */ | |
1032 /* and configuration */ | |
1033 /* */ | |
1034 /* This function is called when a CST message is sent */ | |
1035 /* from the Condat Panel. */ | |
1036 /*------------------------------------------------------*/ | |
1037 void l1_cst_l1_parameters(char *s) | |
1038 { | |
1039 /* | |
1040 a sample command string can be: | |
1041 L1_PARAMS=<1,2,3,4,5> or | |
1042 L1_PARAMS=<1,23,3E32,4,5> | |
1043 with n parameters (here: 5 params); n>=1 | |
1044 parameters are decoded as hexadecimal unsigned integers (UWORD16) | |
1045 */ | |
1046 | |
1047 UWORD8 uNParams = 0; /* Number of parameters */ | |
1048 UWORD32 aParam[10]; /* Parameters array */ | |
1049 UWORD8 uIndex = 0; | |
1050 | |
1051 /* *** retrieve all parameters *** */ | |
1052 while (s[uIndex] != '<') uIndex++; | |
1053 uIndex++; | |
1054 aParam[0] = 0; | |
1055 | |
1056 /* uIndex points on 1st parameter */ | |
1057 | |
1058 while (s[uIndex] != '>') | |
1059 { | |
1060 if (s[uIndex] == ',') | |
1061 { | |
1062 uNParams++; | |
1063 aParam[uNParams] = 0; | |
1064 } | |
1065 else | |
1066 { | |
1067 /* uIndex points on a parameter char */ | |
1068 UWORD8 uChar = s[uIndex]; | |
1069 aParam[uNParams] = aParam[uNParams] << 4; /* shift 4 bits left */ | |
1070 if ((uChar>='0') && (uChar<='9')) | |
1071 aParam[uNParams] += (uChar - '0'); /* retrieve value */ | |
1072 else if ((uChar>='A') && (uChar<='F')) | |
1073 aParam[uNParams] += (10 + uChar - 'A'); /* retrieve value */ | |
1074 else if ((uChar>='a') && (uChar<='f')) | |
1075 aParam[uNParams] += (10 + uChar - 'a'); /* retrieve value */ | |
1076 } | |
1077 | |
1078 uIndex++; /* go to next char */ | |
1079 } | |
1080 | |
1081 /* increment number of params */ | |
1082 uNParams++; | |
1083 | |
1084 /* *** handle parameters *** */ | |
1085 /* | |
1086 1st param: command type | |
1087 2nd param: argument for command type | |
1088 */ | |
1089 switch (aParam[0]) | |
1090 { | |
1091 case 0: /* Trace setting */ | |
1092 /* The 2nd parameter contains the trace bitmap*/ | |
1093 if (uNParams >=2) | |
1094 trace_info.current_config->l1_dyn_trace = aParam[1]; | |
1095 else | |
1096 trace_info.current_config->l1_dyn_trace = 0; /* error case: disable all trace */ | |
1097 Trace_dyn_trace_change(); | |
1098 break; | |
1099 default: /* ignore it */ | |
1100 break; | |
1101 } // switch | |
1102 } | |
1103 | |
1104 #endif | |
1105 | |
1106 #if ((CHIPSET == 2) || (CHIPSET == 3) || (CHIPSET == 4) || \ | |
1107 (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || \ | |
1108 (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || \ | |
1109 (CHIPSET == 11) || (CHIPSET == 12)) | |
1110 /*-------------------------------------------------------*/ | |
1111 /* power_down_config() : temporary implementation !!! */ | |
1112 /*-------------------------------------------------------*/ | |
1113 /* Parameters : sleep_mode (NO, SMALL, BIG, DEEP or ALL) */ | |
1114 /* clocks to be cut in BIG sleep */ | |
1115 /* Return : */ | |
1116 /* Functionality : set the l1s variables */ | |
1117 /* l1s.pw_mgr.mode_authorized and l1s.pw_mgr.clocks */ | |
1118 /* according to the desired mode. */ | |
1119 /*-------------------------------------------------------*/ | |
1120 void power_down_config(UWORD8 sleep_mode, UWORD16 clocks) | |
1121 { | |
1122 #if (OP_L1_STANDALONE == 1) | |
1123 if(sleep_mode != NO_SLEEP) | |
1124 #endif | |
1125 { | |
1126 l1_config.pwr_mngt = PWR_MNGT; | |
1127 l1s.pw_mgr.mode_authorized = sleep_mode; | |
1128 l1s.pw_mgr.clocks = clocks; | |
1129 } | |
1130 | |
1131 #if (OP_L1_STANDALONE == 0) | |
1132 l1s.pw_mgr.enough_gaug = FALSE; | |
1133 #endif | |
1134 } | |
1135 #endif |