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