FreeCalypso > hg > freecalypso-citrine
comparison L1/cust0/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 | 12f6c51be7b3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /* | |
2 * This FreeCalypso version of l1_cust.c is based on the LoCosto version; | |
3 * see ../cust1/l1_cust.c for the original. | |
4 */ | |
5 | |
6 #include <string.h> | |
7 #include "config.h" | |
8 #include "sys_types.h" | |
9 | |
10 #include "../../riviera/rv/general.h" | |
11 #include "../../nucleus/nucleus.h" | |
12 #include "../../nucleus/tm_defs.h" | |
13 #include "../../gpf/inc/cust_os.h" | |
14 | |
15 #include "l1_confg.h" | |
16 #include "l1_const.h" | |
17 #include "../../bsp/ulpd.h" | |
18 #include "l1_types.h" | |
19 #include "l1_time.h" | |
20 #include "l1_trace.h" | |
21 #include "l1_macro.h" | |
22 #include "../../serial/serialswitch.h" | |
23 #include "../../bsp/abb+spi/abb.h" | |
24 | |
25 #if CONFIG_INCLUDE_SIM | |
26 #include "../../bsp/sim.h" | |
27 #endif | |
28 | |
29 #if TESTMODE | |
30 #include "l1tm_defty.h" | |
31 #endif | |
32 | |
33 #if (AUDIO_TASK == 1) | |
34 #include "l1audio_const.h" | |
35 #include "l1audio_cust.h" | |
36 #include "l1audio_defty.h" | |
37 #endif | |
38 | |
39 #if (L1_GTT == 1) | |
40 #include "l1gtt_const.h" | |
41 #include "l1gtt_defty.h" | |
42 #endif | |
43 | |
44 #if (L1_MP3 == 1) | |
45 #include "l1mp3_defty.h" | |
46 #endif | |
47 | |
48 #if (L1_MIDI == 1) | |
49 #include "l1midi_defty.h" | |
50 #endif | |
51 | |
52 #include "l1_defty.h" | |
53 #include "l1_msgty.h" | |
54 #include "l1_tabs.h" | |
55 #include "l1_varex.h" | |
56 #include "l1_proto.h" | |
57 #if (VCXO_ALGO == 1) | |
58 #include "l1_ctl.h" | |
59 #endif | |
60 | |
61 | |
62 #if (RF_FAM == 61) | |
63 #include "drp_drive.h" | |
64 #include "tpudrv61.h" | |
65 #include "l1_rf61.h" | |
66 //#include "l1_rf61.c" | |
67 #endif | |
68 | |
69 | |
70 #if (RF_FAM == 60 ) | |
71 #include "drp_drive.h" | |
72 #include "tpudrv60.h" | |
73 #include "l1_rf60.h" | |
74 //#include "l1_rf60.c" | |
75 //#include "rf60.h" | |
76 #endif | |
77 | |
78 #if (RF_FAM == 43) | |
79 #include "tpudrv43.h" | |
80 #include "l1_rf43.h" | |
81 //#include "l1_rf43.c" | |
82 #endif | |
83 | |
84 #if (RF_FAM == 35) | |
85 #include "tpudrv35.h" | |
86 #include "l1_rf35.h" | |
87 //#include "l1_rf35.c" | |
88 #endif | |
89 | |
90 #if (RF_FAM == 12) | |
91 #include "tpudrv12.h" | |
92 #include "l1_rf12.h" | |
93 //#include "l1_rf12.c" | |
94 #endif | |
95 | |
96 #if (RF_FAM == 10) | |
97 #include "tpudrv10.h" | |
98 #include "l1_rf10.h" | |
99 //#include "l1_rf10.c" | |
100 #endif | |
101 | |
102 #if (RF_FAM == 8) | |
103 #include "tpudrv8.h" | |
104 #include "l1_rf8.h" | |
105 //#include "l1_rf8.c" | |
106 #endif | |
107 | |
108 #if (RF_FAM == 2) | |
109 #include "l1_rf2.h" | |
110 //#include "l1_rf2.c" | |
111 #endif | |
112 | |
113 #if (DRP_FW_EXT == 1) | |
114 #include "l1_drp_inc.h" | |
115 #include "l1_ver.h" | |
116 #endif | |
117 | |
118 /* | |
119 * FreeCalypso change: l1_rf12.c is now a separate compilation unit, | |
120 * so we need to extern the data objects defined therein. | |
121 */ | |
122 extern T_RF rf; | |
123 extern T_RF_BAND rf_band[GSM_BANDS]; | |
124 extern const T_RF_BAND rf_850, rf_900, rf_1800, rf_1900; | |
125 extern UWORD16 abb[ABB_TABLE_SIZE]; | |
126 extern UWORD16 AGC_TABLE[AGC_TABLE_SIZE]; | |
127 extern T_ADC adc; | |
128 extern T_ADCCAL adc_cal; | |
129 extern T_TEMP temperature[TEMP_TABLE_SIZE]; | |
130 | |
131 /* FreeCalypso configuration */ | |
132 #define STD DUALEXT | |
133 | |
134 // Nucleus functions | |
135 extern INT TMD_Timer_State; | |
136 extern UWORD32 TMD_Timer; // for big sleep | |
137 extern UWORD32 TCD_Priority_Groups; | |
138 extern VOID *TCD_Current_Thread; | |
139 extern TC_HCB *TCD_Active_HISR_Heads[TC_HISR_PRIORITIES]; | |
140 extern TC_HCB *TCD_Active_HISR_Tails[TC_HISR_PRIORITIES]; | |
141 extern TC_PROTECT TCD_System_Protect; | |
142 | |
143 #define FFS_WORKAROUND 0 | |
144 | |
145 #if 1 // (FFS_WORKAROUND == 1) | |
146 #include "../../services/ffs/ffs.h" | |
147 #else | |
148 /* typedef signed int int32; | |
149 typedef signed char effs_t;*/ | |
150 typedef signed int filesize_t; | |
151 effs_t ffs_fwrite(const char *name, void *addr, filesize_t size); | |
152 #if (DRP_FW_EXT == 0) | |
153 effs_t ffs_fread(const char *name, void *addr, filesize_t size); | |
154 #endif | |
155 #endif | |
156 | |
157 // Import band configuration from Flash module (need to replace by an access function) | |
158 //extern UWORD8 std; | |
159 extern T_L1_CONFIG l1_config; | |
160 extern T_L1S_GLOBAL l1s; | |
161 | |
162 #if 0 //(OP_L1_STANDALONE == 0) | |
163 extern SYS_BOOL cama_sleep_status(void); | |
164 #endif | |
165 | |
166 #if (CODE_VERSION != SIMULATION) | |
167 // Import serial switch configuration | |
168 #if (CHIPSET == 12) | |
169 extern char ser_cfg_info[3]; | |
170 #else | |
171 extern char ser_cfg_info[2]; | |
172 #endif | |
173 #endif | |
174 | |
175 #if(REL99 && FF_PRF) | |
176 T_TX_LEVEL *Cust_get_uplink_apc_power_reduction(UWORD8 band, | |
177 UWORD8 number_uplink_timeslot, | |
178 T_TX_LEVEL *p_tx_level); | |
179 #endif | |
180 | |
181 | |
182 void get_cal_from_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id); | |
183 UWORD8 save_cal_in_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id); | |
184 void config_rf_rw_band(char type, UWORD8 read); | |
185 void config_rf_read(char type); | |
186 void config_rf_write(char type); | |
187 | |
188 #if (RF_FAM == 61) | |
189 #include "drp_api.h" | |
190 | |
191 extern T_DRP_SW_DATA drp_sw_data_init; | |
192 extern T_DRP_SW_DATA drp_sw_data_calib; | |
193 extern T_DRP_SW_DATA drp_sw_data_calib_saved; | |
194 #endif | |
195 | |
196 enum { | |
197 RF_ID = 0, | |
198 ADC_ID = 1 | |
199 }; | |
200 | |
201 #if (L1_FF_MULTIBAND == 0) && !defined(RUN_INT_RAM) | |
202 /*-------------------------------------------------------*/ | |
203 /* Parameters: none */ | |
204 /* Return: none */ | |
205 /* Functionality: Defines the location of rf-struct */ | |
206 /* for each std. */ | |
207 /*-------------------------------------------------------*/ | |
208 //omaps00090550 #83 warinng removal | |
209 const T_BAND_CONFIG band_config[] = | |
210 { /*ffs name, default addr, max carrier, min tx pwr */ | |
211 {"",(T_RF_BAND *) 0,0,0},//undefined | |
212 {"900", (T_RF_BAND *)&rf_900, 174, 19 },//EGSM | |
213 {"1800",(T_RF_BAND *)&rf_1800, 374, 15 },//DCS | |
214 {"1900",(T_RF_BAND *)&rf_1900, 299, 15 },//PCS | |
215 {"850", (T_RF_BAND *)&rf_850, 124, 19 },//GSM850 | |
216 #if (RF_FAM == 10) | |
217 {"1900_us",(T_RF_BAND *)&rf_1900, 299, 15 },//usdual 1900 rf tables are the same as 3band 1900 rf tables at the moment | |
218 #endif | |
219 {"900", (T_RF_BAND *)&rf_900, 124, 19 } //GSM, this should be last entry | |
220 }; | |
221 | |
222 /*-------------------------------------------------------*/ | |
223 /* Parameters: none */ | |
224 /* Return: none */ | |
225 /* Functionality: Defines the indices into band_config */ | |
226 /* for each std. */ | |
227 /*-------------------------------------------------------*/ | |
228 const T_STD_CONFIG std_config[] = | |
229 { | |
230 /* band1 index, band2 index, txpwr turning point, first arfcn*/ | |
231 { 0, 0, 0, 0 }, // std = 0 not used | |
232 { BAND_GSM900, BAND_NONE, 0, 1 }, // std = 1 GSM | |
233 { BAND_EGSM900, BAND_NONE, 0, 1 }, // std = 2 EGSM | |
234 { BAND_PCS1900, BAND_NONE, 21, 512 }, // std = 3 PCS | |
235 { BAND_DCS1800, BAND_NONE, 28, 512 }, // std = 4 DCS | |
236 { BAND_GSM900, BAND_DCS1800, 28, 1 }, // std = 5 DUAL | |
237 { BAND_EGSM900, BAND_DCS1800, 28, 1 }, // std = 6 DUALEXT | |
238 { BAND_GSM850, BAND_NONE, 0, 128 }, // std = 7 850 | |
239 #if (RF_FAM == 10) | |
240 { BAND_GSM850, BAND_PCS1900_US, 21, 1 } // std = 8 850/1900 | |
241 #else | |
242 { BAND_GSM850, BAND_PCS1900, 21, 1 } // std = 8 850/1900 | |
243 #endif | |
244 }; | |
245 #endif //if (L1_FF_MULTIBAND == 0) | |
246 | |
247 #if (L1_FF_MULTIBAND == 0) && defined(RUN_INT_RAM) | |
248 extern const T_BAND_CONFIG band_config[]; | |
249 extern const T_STD_CONFIG std_config[]; | |
250 #endif | |
251 | |
252 /*-------------------------------------------------------*/ | |
253 /* Prototypes of external functions used in this file. */ | |
254 /*-------------------------------------------------------*/ | |
255 void l1_initialize(T_MMI_L1_CONFIG *mmi_l1_config); | |
256 #if (L1_FF_MULTIBAND == 0) | |
257 WORD16 Convert_l1_radio_freq (UWORD16 radio_freq); | |
258 #endif | |
259 | |
260 #ifndef RUN_FLASH | |
261 /*-------------------------------------------------------*/ | |
262 /* Cust_recover_Os() */ | |
263 /*-------------------------------------------------------*/ | |
264 /* */ | |
265 /* Description: adjust OS from sleep duration */ | |
266 /* ------------ */ | |
267 /* This function fix the : */ | |
268 /* - system clock */ | |
269 /* - Nucleus timers */ | |
270 /* - xxxxxx (customer dependant) */ | |
271 /*-------------------------------------------------------*/ | |
272 | |
273 UWORD8 Cust_recover_Os(void) | |
274 { | |
275 #if (CODE_VERSION != SIMULATION) | |
276 if (l1_config.pwr_mngt == PWR_MNGT) | |
277 { | |
278 UWORD32 current_system_clock; | |
279 | |
280 /***************************************************/ | |
281 // Fix System clock and Nucleus Timers if any.... */ | |
282 /***************************************************/ | |
283 // Fix System clock .... | |
284 current_system_clock = NU_Retrieve_Clock(); | |
285 current_system_clock += l1s.pw_mgr.sleep_duration; | |
286 NU_Set_Clock(current_system_clock); | |
287 | |
288 // Fix Nucleus timer (if needed) .... | |
289 if (TMD_Timer_State == TM_ACTIVE) | |
290 { | |
291 TMD_Timer -= l1s.pw_mgr.sleep_duration; | |
292 if (!TMD_Timer) TMD_Timer_State = TM_EXPIRED; | |
293 } | |
294 | |
295 /***************************************************/ | |
296 // Cust dependant part ... */ | |
297 /***************************************************/ | |
298 //............. | |
299 //............. | |
300 //.............. | |
301 return(TRUE); | |
302 | |
303 } | |
304 #endif | |
305 return(TRUE); //omaps00090550 | |
306 } | |
307 | |
308 | |
309 | |
310 /*-------------------------------------------------------*/ | |
311 /* Cust_check_system() */ | |
312 /*-------------------------------------------------------*/ | |
313 /* */ | |
314 /* Description: */ | |
315 /* ------------ */ | |
316 /* GSM 1.5 : */ | |
317 /* - authorize UWIRE clock to be stopped */ | |
318 /* and write value in l1s.pw_mgr.modules_status. */ | |
319 /* - authorize ARMIO clock to be stopped if the light is */ | |
320 /* off and write value in l1s.pw_mgr.modules_status. */ | |
321 /* - check if SIM clock have been stopped */ | |
322 /* before allowing DEEP SLEEP. */ | |
323 /* - check if UARTs are ready to enter deep sleep */ | |
324 /* - choose the sleep mode */ | |
325 /* */ | |
326 /* Return: */ | |
327 /* ------- */ | |
328 /* DO_NOT_SLEEP, FRAME_STOP or CLOCK_STOP */ | |
329 /*-------------------------------------------------------*/ | |
330 UWORD8 Cust_check_system(void) | |
331 { | |
332 | |
333 #if (CODE_VERSION != SIMULATION) | |
334 if (l1_config.pwr_mngt == PWR_MNGT) | |
335 { | |
336 | |
337 #if (L2_L3_SIMUL == 0) | |
338 // Forbid deep sleep if the light is on | |
339 /* FreeCalypso change: this LT_Status() function is defunct */ | |
340 #if 0 | |
341 if(LT_Status()) | |
342 { | |
343 //cut ARMIO and UWIRE clocks in big sleep | |
344 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ; | |
345 l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_LIGHT_ON; | |
346 return(FRAME_STOP); // BIG sleep | |
347 } | |
348 #endif | |
349 | |
350 #if (OP_L1_STANDALONE == 0) | |
351 // Forbid deep sleep if the camera is working | |
352 /* FreeCalypso change: no camera */ | |
353 #if 0 | |
354 if(!cama_sleep_status()) | |
355 { | |
356 l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_CAMERA; | |
357 return(FRAME_STOP); // BIG sleep | |
358 } | |
359 #endif | |
360 | |
361 // Forbid deep sleep if the SIM and UARTs not ready | |
362 // FC note: this call to SIM_SleepStatus() *is* present in the Leonardo object | |
363 #if CONFIG_INCLUDE_SIM //(REQUIRED_FOR_ESAMPLE_LOCOSTO) | |
364 // Forbid deep sleep if the SIM and UARTs not ready | |
365 if(SIM_SleepStatus()) | |
366 #endif | |
367 { | |
368 #endif | |
369 #endif | |
370 if(SER_UartSleepStatus()) | |
371 { | |
372 return(CLOCK_STOP); // DEEP sleep | |
373 } | |
374 else l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_UART; | |
375 #if (L2_L3_SIMUL == 0) | |
376 #if (OP_L1_STANDALONE == 0) | |
377 } | |
378 // Forbid deep sleep if the SIM and UARTs not ready | |
379 #if CONFIG_INCLUDE_SIM //(REQUIRED_FOR_ESAMPLE_LOCOSTO) | |
380 else l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_SIM; | |
381 #endif | |
382 #endif | |
383 #endif | |
384 // cut ARMIO and UWIRE clocks in big sleep | |
385 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ; | |
386 return(FRAME_STOP); // BIG sleep | |
387 } | |
388 #else // Simulation part | |
389 return(CLOCK_STOP); // DEEP sleep | |
390 #endif | |
391 return(CLOCK_STOP); // omaps00090550 | |
392 } | |
393 #endif /* !RUN_FLASH */ | |
394 | |
395 #ifndef RUN_INT_RAM | |
396 /*-------------------------------------------------------*/ | |
397 /* Parameters: none */ | |
398 /* Return: none */ | |
399 /* Functionality: Read the RF configuration, tables etc. */ | |
400 /* from FFS files. */ | |
401 /*-------------------------------------------------------*/ | |
402 //omaps00090550 #83-d warnimg removal | |
403 static const T_CONFIG_FILE config_files_common[] = | |
404 { | |
405 #if (CODE_VERSION != SIMULATION) | |
406 | |
407 // The first char is NOT part of the filename. It is used for | |
408 // categorizing the ffs file contents: | |
409 // f=rf-cal, F=rf-config, | |
410 // t=tx-cal, T=tx-config, | |
411 // r=rx-cal, R=rx-config, | |
412 // s=sys-cal, S=sys-config, | |
413 "f/gsm/rf/afcdac", &rf.afc.eeprom_afc, sizeof(rf.afc.eeprom_afc), | |
414 "F/gsm/rf/stdmap", &rf.radio_band_support, sizeof(rf.radio_band_support), | |
415 #if (VCXO_ALGO == 1) | |
416 "F/gsm/rf/afcparams", &rf.afc.psi_sta_inv, 4 * sizeof(UWORD32) + 4 * sizeof(WORD16), | |
417 #else | |
418 "F/gsm/rf/afcparams", &rf.afc.psi_sta_inv, 4 * sizeof(UWORD32), | |
419 #endif | |
420 | |
421 "R/gsm/rf/rx/agcglobals", &rf.rx.agc, 4 * sizeof(UWORD16), | |
422 "R/gsm/rf/rx/il2agc", &rf.rx.agc.il2agc_pwr[0], 3 * sizeof(rf.rx.agc.il2agc_pwr), | |
423 "R/gsm/rf/rx/agcwords", &AGC_TABLE, sizeof(AGC_TABLE), | |
424 | |
425 "s/sys/adccal", &adc_cal, sizeof(adc_cal), | |
426 | |
427 "S/sys/abb", &abb, sizeof(abb), | |
428 "S/sys/uartswitch", &ser_cfg_info, sizeof(ser_cfg_info), | |
429 | |
430 #if (RF_FAM ==61) | |
431 "S/sys/drp_wrapper", & drp_wrapper, sizeof(drp_wrapper), | |
432 #if (DRP_FW_EXT == 0) | |
433 "S/sys/drp_calibration", & drp_sw_data_calib, sizeof(drp_sw_data_calib), | |
434 #endif | |
435 #endif | |
436 | |
437 #endif | |
438 NULL, 0, 0 // terminator | |
439 }; | |
440 | |
441 /*-------------------------------------------------------*/ | |
442 /* Parameters: none */ | |
443 /* Return: none */ | |
444 /* Functionality: Read the RF configurations for */ | |
445 /* each band from FFS files. These files */ | |
446 /* are defined for one band, and and used */ | |
447 /* for all bands. */ | |
448 /*-------------------------------------------------------*/ | |
449 //omaps00090550 #83 warning removal | |
450 static const T_CONFIG_FILE config_files_band[] = | |
451 { | |
452 // The first char is NOT part of the filename. It is used for | |
453 // categorizing the ffs file contents: | |
454 // f=rf-cal, F=rf-config, | |
455 // t=tx-cal, T=tx-config, | |
456 // r=rx-cal, R=rx-config, | |
457 // s=sys-cal, S=sys-config, | |
458 | |
459 // generic for all bands | |
460 // band[0] is used as template for all bands. | |
461 "t/gsm/rf/tx/ramps", &rf_band[0].tx.ramp_tables, sizeof(rf_band[0].tx.ramp_tables), | |
462 "t/gsm/rf/tx/levels", &rf_band[0].tx.levels, sizeof(rf_band[0].tx.levels), | |
463 "t/gsm/rf/tx/calchan", &rf_band[0].tx.chan_cal_table, sizeof(rf_band[0].tx.chan_cal_table), | |
464 "T/gsm/rf/tx/caltemp", &rf_band[0].tx.temp, sizeof(rf_band[0].tx.temp), | |
465 | |
466 "r/gsm/rf/rx/calchan", &rf_band[0].rx.agc_bands, sizeof(rf_band[0].rx.agc_bands), | |
467 "R/gsm/rf/rx/caltemp", &rf_band[0].rx.temp, sizeof(rf_band[0].rx.temp), | |
468 "r/gsm/rf/rx/agcparams", &rf_band[0].rx.rx_cal_params, sizeof(rf_band[0].rx.rx_cal_params), | |
469 NULL, 0, 0 // terminator | |
470 }; | |
471 | |
472 #if CONFIG_TARGET_PIRELLI | |
473 extern int pirelli_cal_fread(const char *name, void *userbuf, T_FFS_SIZE size); | |
474 #define cal_fread pirelli_cal_fread | |
475 #else | |
476 #define cal_fread ffs_file_read | |
477 #endif | |
478 | |
479 void config_ffs_read(char type) | |
480 { | |
481 config_rf_read(type); | |
482 config_rf_rw_band(type, 1); | |
483 } | |
484 | |
485 void config_ffs_write(char type) | |
486 { | |
487 config_rf_write(type); | |
488 config_rf_rw_band(type, 0); | |
489 } | |
490 | |
491 void config_rf_read(char type) | |
492 { | |
493 const T_CONFIG_FILE *file = config_files_common; | |
494 | |
495 while (file->name != NULL) | |
496 { | |
497 if (type == '*' || type == file->name[0]) { | |
498 cal_fread(&file->name[1], file->addr, file->size); | |
499 } | |
500 file++; | |
501 } | |
502 } | |
503 | |
504 void config_rf_write(char type) | |
505 { | |
506 const T_CONFIG_FILE *file = config_files_common; | |
507 | |
508 while (file->name != NULL) | |
509 { | |
510 if (type == '*' || type == file->name[0]) { | |
511 ffs_fwrite(&file->name[1], file->addr, file->size); | |
512 } | |
513 file++; | |
514 } | |
515 } | |
516 | |
517 void config_rf_rw_band(char type, UWORD8 read) | |
518 { | |
519 const T_CONFIG_FILE *f1 = config_files_band; | |
520 UWORD8 i; | |
521 WORD32 offset; | |
522 char name[64]; | |
523 char *p; | |
524 #if (L1_FF_MULTIBAND == 0) | |
525 UWORD8 std = l1_config.std.id; | |
526 #endif | |
527 | |
528 #if FFS_WORKAROUND == 1 | |
529 struct stat_s stat; | |
530 UWORD16 time; | |
531 #endif | |
532 #if (L1_FF_MULTIBAND == 0) | |
533 for (i=0; i< GSM_BANDS; i++) | |
534 { | |
535 if(std_config[std].band[i] !=0 ) | |
536 { | |
537 #else | |
538 for (i = 0; i < RF_NB_SUPPORTED_BANDS; i++) | |
539 { | |
540 #endif /*if (L1_FF_MULTIBAND == 0) */ | |
541 f1 = &config_files_band[0]; | |
542 while (f1->name != NULL) | |
543 { | |
544 offset = (WORD32) f1->addr - (WORD32) &rf_band[0]; //offset in bytes | |
545 p = ((char *) &rf_band[i]) + offset; | |
546 if (type == '*' || type == f1->name[0]) | |
547 { | |
548 strcpy(name, &f1->name[1]); | |
549 strcat(name, "."); | |
550 #if (L1_FF_MULTIBAND == 0) | |
551 strcat(name, band_config[std_config[std].band[i]].name); | |
552 #else | |
553 strcat(name, multiband_rf[i].name); | |
554 #endif /*if (L1_FF_MULTIBAND == 0)*/ | |
555 | |
556 if (read == 1) | |
557 cal_fread(name, p, f1->size); | |
558 else //write == 0 | |
559 { | |
560 ffs_fwrite(name, p, f1->size); | |
561 | |
562 // wait until ffs write has finished | |
563 #if FFS_WORKAROUND == 1 | |
564 stat.inode = 0; | |
565 time = 0; | |
566 | |
567 do { | |
568 rvf_delay(10); // in milliseconds | |
569 time += 10; | |
570 ffs_stat(name, &stat); | |
571 } while (stat.inode == 0 && time < 500); | |
572 #endif | |
573 } | |
574 } | |
575 f1++; | |
576 } | |
577 } | |
578 #if (L1_FF_MULTIBAND == 0) | |
579 } | |
580 #endif | |
581 } | |
582 | |
583 | |
584 /*-------------------------------------------------------*/ | |
585 /* Cust_init_std() */ | |
586 /*-------------------------------------------------------*/ | |
587 /* Parameters : */ | |
588 /* Return : */ | |
589 /* Functionality : Init Standard variable configuration */ | |
590 /*-------------------------------------------------------*/ | |
591 void Cust_init_std(void) | |
592 #if (L1_FF_MULTIBAND == 0) | |
593 { | |
594 UWORD8 std = l1_config.std.id; | |
595 UWORD8 band1, band2; | |
596 T_RF_BAND *pt1, *pt2; | |
597 | |
598 band1 = std_config[std].band[0]; | |
599 band2 = std_config[std].band[1]; | |
600 | |
601 //get these from std | |
602 pt1 = band_config[band1].addr; | |
603 pt2 = band_config[band2].addr; | |
604 | |
605 // copy rf-struct from default flash to ram | |
606 memcpy(&rf_band[0], pt1, sizeof(T_RF_BAND)); | |
607 | |
608 if(std_config[std].band[1] != BAND_NONE ) | |
609 memcpy(&rf_band[1], pt2, sizeof(T_RF_BAND)); | |
610 | |
611 // Read all RF and system configuration from FFS *before* we copy any of | |
612 // the rf structure variables to other places, like L1. | |
613 | |
614 config_ffs_read('*'); | |
615 | |
616 l1_config.std.first_radio_freq = std_config[std].first_arfcn; | |
617 | |
618 if(band2!=0) | |
619 l1_config.std.first_radio_freq_band2 = band_config[band1].max_carrier + 1; | |
620 else | |
621 l1_config.std.first_radio_freq_band2 = 0; //band1 carrier + 1 else 0 | |
622 | |
623 // if band2 is not used it is initialised with zeros | |
624 l1_config.std.nbmax_carrier = band_config[band1].max_carrier; | |
625 if(band2!=0) | |
626 l1_config.std.nbmax_carrier += band_config[band2].max_carrier; | |
627 | |
628 l1_config.std.max_txpwr_band1 = band_config[band1].max_txpwr; | |
629 l1_config.std.max_txpwr_band2 = band_config[band2].max_txpwr; | |
630 l1_config.std.txpwr_turning_point = std_config[std].txpwr_tp; | |
631 l1_config.std.cal_freq1_band1 = 0; | |
632 l1_config.std.cal_freq1_band2 = 0; | |
633 | |
634 l1_config.std.g_magic_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.g_magic; | |
635 l1_config.std.lna_att_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.lna_att; | |
636 l1_config.std.lna_switch_thr_low_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.lna_switch_thr_low; | |
637 l1_config.std.lna_switch_thr_high_band1 = rf_band[MULTI_BAND1].rx.rx_cal_params.lna_switch_thr_high; | |
638 l1_config.std.swap_iq_band1 = rf_band[MULTI_BAND1].swap_iq; | |
639 | |
640 l1_config.std.g_magic_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.g_magic; | |
641 l1_config.std.lna_att_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.lna_att; | |
642 l1_config.std.lna_switch_thr_low_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.lna_switch_thr_low; | |
643 l1_config.std.lna_switch_thr_high_band2 = rf_band[MULTI_BAND2].rx.rx_cal_params.lna_switch_thr_high; | |
644 l1_config.std.swap_iq_band2 = rf_band[MULTI_BAND2].swap_iq; | |
645 | |
646 l1_config.std.radio_freq_index_offset = l1_config.std.first_radio_freq-1; | |
647 | |
648 // init variable indicating which radio bands are supported by the chosen RF | |
649 l1_config.std.radio_band_support = rf.radio_band_support; | |
650 | |
651 //TBD: DRP Calib: Currently the Calib Data are only used for the routines, TBD add to l1_config. from saved Calibration | |
652 // on a need basis ? | |
653 } | |
654 #else | |
655 { | |
656 UWORD8 i; | |
657 | |
658 for (i = 0; i < RF_NB_SUPPORTED_BANDS; i++) | |
659 { | |
660 switch(multiband_rf[i].gsm_band_identifier) | |
661 { | |
662 case RF_GSM900: | |
663 rf_band[i]=rf_900; | |
664 break; | |
665 case RF_GSM850: | |
666 rf_band[i]=rf_850; | |
667 break; | |
668 case RF_DCS1800: | |
669 rf_band[i]=rf_1800; | |
670 break; | |
671 case RF_PCS1900: | |
672 rf_band[i]=rf_1900; | |
673 break; | |
674 default: | |
675 break; | |
676 } | |
677 } | |
678 config_ffs_read('*'); | |
679 } | |
680 #endif // if (L1_FF_MULTIBAND == 0) | |
681 | |
682 | |
683 /*-------------------------------------------------------*/ | |
684 /* Cust_init_params() */ | |
685 /*-------------------------------------------------------*/ | |
686 /* Parameters : */ | |
687 /* Return : */ | |
688 /* Functionality : Init RF dependent paramters (AGC, TX) */ | |
689 /*-------------------------------------------------------*/ | |
690 void Cust_init_params(void) | |
691 { | |
692 | |
693 #if (CODE_VERSION==SIMULATION) | |
694 extern UWORD16 simu_RX_SYNTH_SETUP_TIME; // set in xxx.txt l3 scenario file | |
695 extern UWORD16 simu_TX_SYNTH_SETUP_TIME; // set in xxx.txt l3 scenario file | |
696 | |
697 l1_config.params.rx_synth_setup_time = simu_RX_SYNTH_SETUP_TIME; | |
698 l1_config.params.tx_synth_setup_time = simu_TX_SYNTH_SETUP_TIME; | |
699 #else | |
700 l1_config.params.rx_synth_setup_time = RX_SYNTH_SETUP_TIME; | |
701 l1_config.params.tx_synth_setup_time = TX_SYNTH_SETUP_TIME; | |
702 #endif | |
703 | |
704 | |
705 // Convert SYNTH_SETUP_TIME into SPLIT. | |
706 // We have kept a margin of 20qbit (EPSILON_MEAS) to cover offset change and Scenario closing time + margin. | |
707 l1_config.params.rx_synth_load_split = 1L + (l1_config.params.rx_synth_setup_time + EPSILON_MEAS) / (BP_DURATION/BP_SPLIT); | |
708 l1_config.params.tx_synth_load_split = 1L + (l1_config.params.tx_synth_setup_time + EPSILON_MEAS) / (BP_DURATION/BP_SPLIT); | |
709 | |
710 l1_config.params.rx_synth_start_time = TPU_CLOCK_RANGE + PROVISION_TIME - l1_config.params.rx_synth_setup_time; | |
711 l1_config.params.tx_synth_start_time = TPU_CLOCK_RANGE - l1_config.params.tx_synth_setup_time; | |
712 | |
713 l1_config.params.rx_change_synchro_time = l1_config.params.rx_synth_start_time - EPSILON_SYNC; | |
714 l1_config.params.rx_change_offset_time = l1_config.params.rx_synth_start_time - EPSILON_OFFS; | |
715 | |
716 l1_config.params.tx_change_offset_time = TIME_OFFSET_TX - | |
717 TA_MAX - | |
718 l1_config.params.tx_synth_setup_time - | |
719 EPSILON_OFFS; | |
720 | |
721 // TX duration = ramp up time + burst duration (data + tail bits) | |
722 l1_config.params.tx_nb_duration = UL_ABB_DELAY + rf.tx.guard_bits*4 + NB_BURST_DURATION_UL; | |
723 l1_config.params.tx_ra_duration = UL_ABB_DELAY + rf.tx.guard_bits*4 + RA_BURST_DURATION; | |
724 | |
725 l1_config.params.tx_nb_load_split = 1L + (l1_config.params.tx_nb_duration - rf.tx.prg_tx - NB_MARGIN) / (BP_DURATION/BP_SPLIT); | |
726 l1_config.params.tx_ra_load_split = 1L + (l1_config.params.tx_ra_duration - rf.tx.prg_tx - NB_MARGIN) / (BP_DURATION/BP_SPLIT); | |
727 | |
728 // time for the end of RX and TX TPU scenarios | |
729 l1_config.params.rx_tpu_scenario_ending = RX_TPU_SCENARIO_ENDING; | |
730 l1_config.params.tx_tpu_scenario_ending = TX_TPU_SCENARIO_ENDING; | |
731 | |
732 // FB26 anchoring time is computed backward to leave only 6 qbit margin between | |
733 // FB26 window and next activity (RX time tracking). | |
734 // This margin is used as follow: | |
735 // Serving offset restore: 1 qbit (SERV_OFFS_REST_LOAD) | |
736 // Tpu Sleep: 2 qbit (TPU_SLEEP_LOAD) | |
737 // --------- | |
738 // Total: 3 qbit | |
739 | |
740 l1_config.params.fb26_anchoring_time = (l1_config.params.rx_synth_start_time - | |
741 #if (CODE_VERSION == SIMULATION) | |
742 // simulator: end of scenario not included in window (no serialization) | |
743 1 - | |
744 #else | |
745 // RF dependent end of RX TPU scenario | |
746 l1_config.params.rx_tpu_scenario_ending - | |
747 #endif | |
748 EPSILON_SYNC - | |
749 TPU_SLEEP_LOAD - | |
750 SERV_OFFS_REST_LOAD - | |
751 FB26_ACQUIS_DURATION - | |
752 PROVISION_TIME + | |
753 TPU_CLOCK_RANGE) % TPU_CLOCK_RANGE; | |
754 | |
755 l1_config.params.fb26_change_offset_time = l1_config.params.fb26_anchoring_time + | |
756 PROVISION_TIME - | |
757 l1_config.params.rx_synth_setup_time - | |
758 EPSILON_OFFS; | |
759 | |
760 l1_config.params.guard_bits = rf.tx.guard_bits; | |
761 | |
762 l1_config.params.prg_tx_gsm = rf.tx.prg_tx; | |
763 l1_config.params.prg_tx_dcs = rf.tx.prg_tx; //delay for dual band not implemented yet | |
764 | |
765 l1_config.params.low_agc_noise_thr = rf.rx.agc.low_agc_noise_thr; | |
766 l1_config.params.high_agc_sat_thr = rf.rx.agc.high_agc_sat_thr; | |
767 l1_config.params.low_agc = rf.rx.agc.low_agc; | |
768 l1_config.params.high_agc = rf.rx.agc.high_agc; | |
769 l1_config.params.il_min = IL_MIN; | |
770 | |
771 l1_config.params.fixed_txpwr = FIXED_TXPWR; | |
772 l1_config.params.eeprom_afc = rf.afc.eeprom_afc; | |
773 l1_config.params.setup_afc_and_rf = SETUP_AFC_AND_RF; | |
774 l1_config.params.rf_wakeup_tpu_scenario_duration = l1_config.params.setup_afc_and_rf + 1; //directly dependent of l1dmacro_RF_wakeup implementation | |
775 | |
776 l1_config.params.psi_sta_inv = rf.afc.psi_sta_inv; | |
777 l1_config.params.psi_st = rf.afc.psi_st; | |
778 l1_config.params.psi_st_32 = rf.afc.psi_st_32; | |
779 l1_config.params.psi_st_inv = rf.afc.psi_st_inv; | |
780 | |
781 #if (CODE_VERSION == SIMULATION) | |
782 #if (VCXO_ALGO == 1) | |
783 l1_config.params.afc_algo = ALGO_AFC_LQG_PREDICTOR; // VCXO|VCTCXO - Choosing AFC algorithm | |
784 #endif | |
785 #else | |
786 #if (VCXO_ALGO == 1) | |
787 l1_config.params.afc_dac_center = rf.afc.dac_center; // VCXO - assuming DAC linearity | |
788 l1_config.params.afc_dac_min = rf.afc.dac_min; // VCXO - assuming DAC linearity | |
789 l1_config.params.afc_dac_max = rf.afc.dac_max; // VCXO - assuming DAC linearity | |
790 #if (NEW_SNR_THRESHOLD == 0) | |
791 l1_config.params.afc_snr_thr = rf.afc.snr_thr; // VCXO - SNR threshold | |
792 #else | |
793 l1_config.params.afc_snr_thr = L1_TOA_SNR_THRESHOLD; | |
794 #endif /* NEW_SNR_THRESHOLD */ | |
795 l1_config.params.afc_algo = ALGO_AFC_LQG_PREDICTOR; // VCXO|VCTCXO - Choosing AFC algorithm | |
796 l1_config.params.afc_win_avg_size_M = C_WIN_AVG_SIZE_M; // VCXO - Average psi values with this value | |
797 l1_config.params.rgap_algo = ALGO_AFC_RXGAP; // VCXO - Choosing Reception Gap algorithm | |
798 l1_config.params.rgap_bad_snr_count_B = C_RGAP_BAD_SNR_COUNT_B; // VCXO - Prediction SNR count | |
799 #endif | |
800 #endif | |
801 | |
802 #if DCO_ALGO | |
803 #if (RF_FAM == 10) | |
804 // Enable DCO algorithm for direct conversion RFs | |
805 l1_config.params.dco_enabled = TRUE; | |
806 #else | |
807 l1_config.params.dco_enabled = FALSE; | |
808 #endif | |
809 #endif | |
810 | |
811 #if (ANALOG == 1) | |
812 l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG | |
813 l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset | |
814 l1_config.params.vbuctrl = abb[ABB_VBUCTRL]; // Uplink gain amp 0dB, Sidetone gain to mute | |
815 l1_config.params.vbdctrl = abb[ABB_VBDCTRL]; // Downlink gain amp 0dB, Volume control 0 dB | |
816 l1_config.params.bbctrl = abb[ABB_BBCTRL]; // value at reset | |
817 l1_config.params.apcoff = abb[ABB_APCOFF]; // value at reset | |
818 l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset | |
819 l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset | |
820 l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset | |
821 l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset | |
822 l1_config.params.vbctrl = abb[ABB_VBCTRL]; // VULSWITCH=0, VDLAUX=1, VDLEAR=1 | |
823 l1_config.params.apcdel1 = abb[ABB_APCDEL1]; // value at reset | |
824 #endif | |
825 #if (ANALOG == 2) | |
826 l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG | |
827 l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset | |
828 l1_config.params.vbuctrl = abb[ABB_VBUCTRL]; // Uplink gain amp 0dB, Sidetone gain to mute | |
829 l1_config.params.vbdctrl = abb[ABB_VBDCTRL]; // Downlink gain amp 0dB, Volume control 0 dB | |
830 l1_config.params.bbctrl = abb[ABB_BBCTRL]; // value at reset | |
831 l1_config.params.bulgcal = abb[ABB_BULGCAL]; // value at reset | |
832 l1_config.params.apcoff = abb[ABB_APCOFF]; // value at reset | |
833 l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset | |
834 l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset | |
835 l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset | |
836 l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset | |
837 l1_config.params.vbctrl1 = abb[ABB_VBCTRL1]; // VULSWITCH=0, VDLAUX=1, VDLEAR=1 | |
838 l1_config.params.vbctrl2 = abb[ABB_VBCTRL2]; // MICBIASEL=0, VDLHSO=0, MICAUX=0 | |
839 l1_config.params.apcdel1 = abb[ABB_APCDEL1]; // value at reset | |
840 l1_config.params.apcdel2 = abb[ABB_APCDEL2]; // value at reset | |
841 #endif | |
842 #if (ANALOG == 3) | |
843 l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG | |
844 l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset | |
845 l1_config.params.vbuctrl = abb[ABB_VBUCTRL]; // Uplink gain amp 0dB, Sidetone gain to mute | |
846 l1_config.params.vbdctrl = abb[ABB_VBDCTRL]; // Downlink gain amp 0dB, Volume control 0 dB | |
847 l1_config.params.bbctrl = abb[ABB_BBCTRL]; // value at reset | |
848 l1_config.params.bulgcal = abb[ABB_BULGCAL]; // value at reset | |
849 l1_config.params.apcoff = abb[ABB_APCOFF]; // X2 Slope 128 and APCSWP disabled | |
850 l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset | |
851 l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset | |
852 l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset | |
853 l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset | |
854 l1_config.params.vbctrl1 = abb[ABB_VBCTRL1]; // VULSWITCH=0 | |
855 l1_config.params.vbctrl2 = abb[ABB_VBCTRL2]; // MICBIASEL=0, VDLHSO=0, MICAUX=0 | |
856 l1_config.params.apcdel1 = abb[ABB_APCDEL1]; // value at reset | |
857 l1_config.params.apcdel2 = abb[ABB_APCDEL2]; // value at reset | |
858 l1_config.params.vbpop = abb[ABB_VBPOP]; // HSOAUTO enabled | |
859 l1_config.params.vau_delay_init = abb[ABB_VAUDINITD]; // 2 TDMA Frames between VDL "ON" and VDLHSO "ON" | |
860 l1_config.params.vaud_cfg = abb[ABB_VAUDCTRL]; // value at reset | |
861 l1_config.params.vauo_onoff = abb[ABB_VAUOCTRL]; // speech on AUX and EAR | |
862 l1_config.params.vaus_vol = abb[ABB_VAUSCTRL]; // value at reset | |
863 l1_config.params.vaud_pll = abb[ABB_VAUDPLL]; // value at reset | |
864 #endif | |
865 | |
866 #if (RF_FAM == 61) | |
867 l1_config.params.apcctrl2 = drp_wrapper[DRP_WRAPPER_APCCTRL2]; | |
868 l1_config.params.apcdel1 = drp_wrapper[DRP_WRAPPER_APCDEL1]; | |
869 l1_config.params.apcdel2 = drp_wrapper[DRP_WRAPPER_APCDEL2]; | |
870 #endif | |
871 #if (ANALOG == 11) | |
872 l1_config.params.vulgain = abb[ABB_VULGAIN]; | |
873 l1_config.params.vdlgain = abb[ABB_VDLGAIN]; | |
874 l1_config.params.sidetone = abb[ABB_SIDETONE]; | |
875 l1_config.params.ctrl1 = abb[ABB_CTRL1]; | |
876 l1_config.params.ctrl2 = abb[ABB_CTRL2]; | |
877 l1_config.params.ctrl3 = abb[ABB_CTRL3]; | |
878 l1_config.params.ctrl4 = abb[ABB_CTRL4]; | |
879 l1_config.params.ctrl5 = abb[ABB_CTRL5]; | |
880 l1_config.params.ctrl6 = abb[ABB_CTRL6]; | |
881 l1_config.params.popauto = abb[ABB_POPAUTO]; | |
882 l1_config.params.outen1 = abb[ABB_OUTEN1]; | |
883 l1_config.params.outen2 = abb[ABB_OUTEN2]; | |
884 l1_config.params.outen3 = abb[ABB_OUTEN3]; | |
885 l1_config.params.aulga = abb[ABB_AULGA]; | |
886 l1_config.params.aurga = abb[ABB_AURGA]; | |
887 #endif | |
888 } | |
889 #endif /* !RUN_INT_RAM */ | |
890 | |
891 #ifndef RUN_FLASH | |
892 /************************************/ | |
893 /* Automatic Gain Control */ | |
894 /************************************/ | |
895 | |
896 /*-------------------------------------------------------*/ | |
897 /* Cust_get_agc_from_IL() */ | |
898 /*-------------------------------------------------------*/ | |
899 /* Parameters : */ | |
900 /* Return : */ | |
901 /* Functionality : returns agc value */ | |
902 /*-------------------------------------------------------*/ | |
903 WORD8 Cust_get_agc_from_IL(UWORD16 radio_freq, UWORD16 agc_index, UWORD8 table_id,UWORD8 lna_off_val) | |
904 { | |
905 | |
906 UWORD16 agc_index_temp; | |
907 | |
908 // radio_freq currently not used | |
909 // this parameter is passed in order to allow band dependent tables for specific RFs | |
910 // (e.g. dual band RF with separate AGC H/W blocks for GSM and DCS) | |
911 | |
912 agc_index_temp = (agc_index<<1) + (lna_off_val * l1ctl_get_lna_att(radio_freq)); | |
913 agc_index= agc_index_temp>>1; | |
914 if (agc_index > 120) | |
915 agc_index = 120; // Clip agc_index | |
916 | |
917 switch (table_id) | |
918 { | |
919 case MAX_ID: return(rf.rx.agc.il2agc_max[agc_index]); | |
920 case AV_ID: return(rf.rx.agc.il2agc_av[agc_index]); | |
921 case PWR_ID: return(rf.rx.agc.il2agc_pwr[agc_index]); | |
922 } | |
923 return (0);//omaps00090550 | |
924 } | |
925 | |
926 /*-------------------------------------------------------*/ | |
927 /* Cust_get_agc_band */ | |
928 /*-------------------------------------------------------*/ | |
929 /* Parameters : radio_freq */ | |
930 /* Return : band number */ | |
931 /* Functionality : Computes the band for RF calibration */ | |
932 /*-------------------------------------------------------*/ | |
933 /*---------------------------------------------*/ | |
934 | |
935 #if (CODE_VERSION == SIMULATION) | |
936 UWORD16 Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band) | |
937 #else | |
938 UWORD16 inline Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band) | |
939 #endif | |
940 { | |
941 // WORD32 i =0 ; //omaps00090550 | |
942 UWORD8 band_number; | |
943 | |
944 for (band_number=0;band_number<RF_RX_CAL_CHAN_SIZE;band_number++) | |
945 { | |
946 if (arfcn <= rf_band[gsm_band].rx.agc_bands[band_number].upper_bound) | |
947 return(band_number); | |
948 } | |
949 // Should never happen! | |
950 return(0); | |
951 } | |
952 | |
953 #if (L1_FF_MULTIBAND == 0) | |
954 /*-------------------------------------------------------*/ | |
955 /* Cust_is_band_high */ | |
956 /*-------------------------------------------------------*/ | |
957 /* Parameters : arfcn */ | |
958 /* Return : 0 if low band */ | |
959 /* 1 if high band */ | |
960 /* Functionality : Generic function which return 1 if */ | |
961 /* arfcn is in the high band */ | |
962 /*-------------------------------------------------------*/ | |
963 | |
964 UWORD8 Cust_is_band_high(UWORD16 radio_freq) | |
965 { | |
966 UWORD16 max_carrier; | |
967 UWORD8 std = l1_config.std.id; | |
968 | |
969 max_carrier = band_config[std_config[std].band[0]].max_carrier; | |
970 | |
971 return(((radio_freq >= l1_config.std.first_radio_freq) && | |
972 (radio_freq < (l1_config.std.first_radio_freq + max_carrier))) ? MULTI_BAND1 : MULTI_BAND2); | |
973 } | |
974 #endif | |
975 | |
976 /*-------------------------------------------------------*/ | |
977 /* l1ctl_encode_delta2() */ | |
978 /*-------------------------------------------------------*/ | |
979 /* Parameters : */ | |
980 /* Return : */ | |
981 /* Functionality : */ | |
982 /*-------------------------------------------------------*/ | |
983 WORD8 l1ctl_encode_delta2(UWORD16 radio_freq) | |
984 { | |
985 WORD8 delta2_freq; | |
986 UWORD16 i; | |
987 UWORD16 arfcn; | |
988 #if (L1_FF_MULTIBAND == 0) | |
989 UWORD8 band; | |
990 | |
991 band = Cust_is_band_high(radio_freq); | |
992 arfcn = Convert_l1_radio_freq(radio_freq); | |
993 #else | |
994 WORD8 band; | |
995 // Corrected for input being rf_freq and not l1_freq | |
996 arfcn = rf_convert_l1freq_to_arfcn_rfband(rf_convert_rffreq_to_l1freq(radio_freq), &band); | |
997 #endif | |
998 | |
999 i = Cust_get_agc_band(arfcn,band); // | |
1000 delta2_freq = rf_band[band].rx.agc_bands[i].agc_calib; | |
1001 | |
1002 //temperature compensation | |
1003 for (i=0;i<RF_RX_CAL_TEMP_SIZE;i++) | |
1004 { | |
1005 if ((WORD16)adc.converted[ADC_RFTEMP] <= rf_band[band].rx.temp[i].temperature) | |
1006 { | |
1007 delta2_freq += rf_band[band].rx.temp[i].agc_calib; | |
1008 break; | |
1009 } | |
1010 } | |
1011 | |
1012 return(delta2_freq); | |
1013 } | |
1014 | |
1015 #if (L1_FF_MULTIBAND == 0) | |
1016 #else | |
1017 /*-------------------------------------------------------*/ | |
1018 /* l1ctl_get_g_magic() */ | |
1019 /*-------------------------------------------------------*/ | |
1020 /* Parameters : */ | |
1021 /* Return : */ | |
1022 /* Functionality : */ | |
1023 /*-------------------------------------------------------*/ | |
1024 UWORD16 l1ctl_get_g_magic(UWORD16 radio_freq) | |
1025 { | |
1026 // Corrected for input being rf_freq and not l1_freq | |
1027 return (rf_band[rf_subband2band[rf_convert_rffreq_to_l1subband(radio_freq)]].rx.rx_cal_params.g_magic); | |
1028 } | |
1029 | |
1030 | |
1031 /*-------------------------------------------------------*/ | |
1032 /* l1ctl_get_lna_att() */ | |
1033 /*-------------------------------------------------------*/ | |
1034 /* Parameters : */ | |
1035 /* Return : */ | |
1036 /* Functionality : */ | |
1037 /*-------------------------------------------------------*/ | |
1038 UWORD16 l1ctl_get_lna_att(UWORD16 radio_freq) | |
1039 { | |
1040 // The function is provided with rf_freq as input so | |
1041 // convert rf_freq to l1_subband then convert l1_subband to rf_band and index into rf_band | |
1042 return( rf_band[rf_subband2band[rf_convert_rffreq_to_l1subband(radio_freq)]].rx.rx_cal_params.lna_att); | |
1043 // return (rf_band[rf_convert_l1freq_to_rf_band_idx(radio_freq)].rx.rx_cal_params.lna_att); | |
1044 } | |
1045 /*-------------------------------------------------------*/ | |
1046 /* l1ctl_encode_delta1() */ | |
1047 /*-------------------------------------------------------*/ | |
1048 /* Parameters : */ | |
1049 /* Return : */ | |
1050 /* Functionality : */ | |
1051 /*-------------------------------------------------------*/ | |
1052 WORD8 l1ctl_encode_delta1(UWORD16 radio_freq) | |
1053 { | |
1054 return 0; | |
1055 } | |
1056 /*-------------------------------------------------------*/ | |
1057 /* l1ctl_encode_lna() */ | |
1058 /*-------------------------------------------------------*/ | |
1059 /* Parameters : */ | |
1060 /* Return : */ | |
1061 /* Functionality : */ | |
1062 /*-------------------------------------------------------*/ | |
1063 void l1ctl_encode_lna( UWORD8 input_level, | |
1064 UWORD8 *lna_state, | |
1065 UWORD16 radio_freq) | |
1066 { | |
1067 | |
1068 /*** LNA Hysteresis is implemented as following : | |
1069 | |
1070 | | |
1071 On|---<>----+-------+ | |
1072 | | | | |
1073 LNA | | | | |
1074 | ^ v | |
1075 | | | | |
1076 | | | | |
1077 Off| +-------+----<>----- | |
1078 +-------------------------------- | |
1079 50 40 30 20 input_level /-dBm | |
1080 THR_HIGH THR_LOW ***/ | |
1081 WORD8 band; | |
1082 // Corrected for input to be rf_freq and not l1_freq | |
1083 band = rf_subband2band[rf_convert_rffreq_to_l1subband(radio_freq)]; | |
1084 if ( input_level > rf_band[band].rx.rx_cal_params.lna_switch_thr_high) // < -44dBm ? | |
1085 { | |
1086 *lna_state = LNA_ON; // lna_off = FALSE | |
1087 } | |
1088 else if ( input_level < rf_band[band].rx.rx_cal_params.lna_switch_thr_low) // > -40dBm ? | |
1089 { | |
1090 *lna_state = LNA_OFF; // lna off = TRUE | |
1091 } | |
1092 } | |
1093 | |
1094 UWORD8 l1ctl_get_iqswap(UWORD16 rf_freq) | |
1095 { | |
1096 return(rf_band[rf_subband2band[rf_convert_rffreq_to_l1subband(rf_freq)]].swap_iq); | |
1097 } | |
1098 | |
1099 #endif //if L1_FF_MULTIBAND == 0) | |
1100 | |
1101 /************************************/ | |
1102 /* TX Management */ | |
1103 /************************************/ | |
1104 /*-------------------------------------------------------*/ | |
1105 /* Cust_get_ramp_tab */ | |
1106 /*-------------------------------------------------------*/ | |
1107 /* Parameters : */ | |
1108 /* Return : */ | |
1109 /* Functionality : | |
1110 Notes: | |
1111 Cal+ | |
1112 APCRAM : Dwn(15:11)Up(10:6)Forced(0) | |
1113 Locosto: | |
1114 APCRAM: Dwn(15:8)Up(7:0) | |
1115 | |
1116 */ | |
1117 /*-------------------------------------------------------*/ | |
1118 | |
1119 void Cust_get_ramp_tab(API *a_ramp, UWORD8 txpwr_ramp_up, UWORD8 txpwr_ramp_down, UWORD16 radio_freq) | |
1120 { | |
1121 UWORD16 index_up, index_down,j, arfcn; | |
1122 #if (L1_FF_MULTIBAND == 0) | |
1123 UWORD8 band; | |
1124 | |
1125 band = Cust_is_band_high(radio_freq); | |
1126 arfcn = Convert_l1_radio_freq(radio_freq); | |
1127 #else | |
1128 WORD8 band; | |
1129 // Corrected for input being rf_freq and not l1_freq | |
1130 arfcn = rf_convert_l1freq_to_arfcn_rfband(rf_convert_rffreq_to_l1freq(radio_freq), &band); | |
1131 #endif //if( L1_FF_MULTIBAND == 0) | |
1132 | |
1133 index_up = rf_band[band].tx.levels[txpwr_ramp_up].ramp_index; | |
1134 index_down = rf_band[band].tx.levels[txpwr_ramp_down].ramp_index; | |
1135 | |
1136 #if ((ANALOG == 1) || (ANALOG == 2) || (ANALOG == 3)) | |
1137 for (j=0; j<16; j++) | |
1138 { | |
1139 a_ramp[j]=((rf_band[band].tx.ramp_tables[index_down].ramp_down[j])<<11) | | |
1140 ((rf_band[band].tx.ramp_tables[index_up].ramp_up[j]) << 6) | | |
1141 0x14; | |
1142 } | |
1143 #endif | |
1144 | |
1145 #if (RF_FAM == 61) | |
1146 // 20 Coeff each 8 (RampDown) + 8 (RampUp) | |
1147 for (j=0; j<20; j++) | |
1148 { | |
1149 a_ramp[j]=( (255 - (rf_band[band].tx.ramp_tables[index_down].ramp_down[j]) ) <<8) | | |
1150 ((rf_band[band].tx.ramp_tables[index_up].ramp_up[j])) ; | |
1151 } | |
1152 #endif | |
1153 } | |
1154 | |
1155 /*-------------------------------------------------------*/ | |
1156 /* get_pwr_data */ | |
1157 /*-------------------------------------------------------*/ | |
1158 /* Parameters : */ | |
1159 /* Return : */ | |
1160 /* Functionality : */ | |
1161 /*-------------------------------------------------------*/ | |
1162 | |
1163 #if ((ANALOG == 1) || (ANALOG == 2) || (ANALOG == 3) || (RF_FAM == 61)) | |
1164 UWORD16 Cust_get_pwr_data(UWORD8 txpwr, UWORD16 radio_freq | |
1165 #if (REL99 && FF_PRF) | |
1166 , UWORD8 number_uplink_timeslot | |
1167 #endif | |
1168 ) | |
1169 { | |
1170 | |
1171 UWORD16 i,j; | |
1172 UWORD16 arfcn; | |
1173 | |
1174 T_TX_LEVEL *a_tx_levels; | |
1175 | |
1176 #if (APC_VBAT_COMP == 1) | |
1177 static UWORD16 apc_max_value = APC_MAX_VALUE; | |
1178 #endif | |
1179 | |
1180 #if(ORDER2_TX_TEMP_CAL==1) | |
1181 WORD16 pwr_data; | |
1182 #else | |
1183 UWORD16 pwr_data; | |
1184 #endif | |
1185 | |
1186 #if (L1_FF_MULTIBAND == 0) | |
1187 UWORD8 band; | |
1188 band = Cust_is_band_high(radio_freq); | |
1189 arfcn = Convert_l1_radio_freq(radio_freq); | |
1190 #else | |
1191 WORD8 band; | |
1192 // Corrected for input being rf_freq and not l1_freq | |
1193 arfcn = rf_convert_l1freq_to_arfcn_rfband(rf_convert_rffreq_to_l1freq(radio_freq), &band); | |
1194 #endif //if( L1_FF_MULTIBAND == 0) | |
1195 | |
1196 // band = Cust_is_band_high(radio_freq); | |
1197 // arfcn = Convert_l1_radio_freq(radio_freq); | |
1198 | |
1199 a_tx_levels = &(rf_band[band].tx.levels[txpwr]); // get pointer to rf tx structure | |
1200 | |
1201 #if REL99 | |
1202 #if FF_PRF | |
1203 // uplink power reduction feature which decrease power level in case of uplink multislot | |
1204 a_tx_levels = Cust_get_uplink_apc_power_reduction(band, number_uplink_timeslot, a_tx_levels); | |
1205 #endif | |
1206 #endif | |
1207 | |
1208 // get uncalibrated apc | |
1209 pwr_data = a_tx_levels->apc; | |
1210 | |
1211 i = a_tx_levels->chan_cal_index; // get index for channel compensation | |
1212 j=0; | |
1213 | |
1214 while (arfcn > rf_band[band].tx.chan_cal_table[i][j].arfcn_limit) | |
1215 j++; | |
1216 | |
1217 // channel calibrate apc | |
1218 pwr_data = ((UWORD32) (pwr_data * rf_band[band].tx.chan_cal_table[i][j].chan_cal))/128; | |
1219 | |
1220 // temperature compensate apc | |
1221 { | |
1222 T_TX_TEMP_CAL *pt; | |
1223 | |
1224 pt = rf_band[band].tx.temp; | |
1225 while (((WORD16)adc.converted[ADC_RFTEMP] > pt->temperature) && ((pt-rf_band[band].tx.temp) < (RF_TX_CAL_TEMP_SIZE-1))) | |
1226 pt++; | |
1227 #if(ORDER2_TX_TEMP_CAL==1) | |
1228 pwr_data += (txpwr*(pt->a*txpwr + pt->b) + pt->c) / 64; //delta apc = ax^2+bx+c | |
1229 if(pwr_data < 0) pwr_data = 0; | |
1230 #else | |
1231 pwr_data += pt->apc_calib; | |
1232 #endif | |
1233 } | |
1234 | |
1235 // Vbat compensate apc | |
1236 #if (APC_VBAT_COMP == 1) | |
1237 | |
1238 if (adc.converted[ADC_VBAT] < VBAT_LOW_THRESHOLD) | |
1239 apc_max_value = APC_MAX_VALUE_LOW_BAT; | |
1240 | |
1241 else if (adc.converted[ADC_VBAT] > VBAT_HIGH_THRESHOLD) | |
1242 apc_max_value = APC_MAX_VALUE; | |
1243 | |
1244 // else do nothing as Vbat is staying between VBAT_LOW_THRESHOLD and | |
1245 // VBAT_HIGH_THRESHOLD -> max APC value is still the same than previous one | |
1246 | |
1247 if (pwr_data > apc_max_value) | |
1248 pwr_data = apc_max_value; | |
1249 #endif // APC_VBAT_COMP == 1 | |
1250 | |
1251 return(pwr_data); | |
1252 } | |
1253 #endif | |
1254 | |
1255 | |
1256 #if(REL99 && FF_PRF) | |
1257 | |
1258 /*-------------------------------------------------------*/ | |
1259 /* Cust_get_uplink_apc_power_reduction */ | |
1260 /*-------------------------------------------------------*/ | |
1261 /* Parameters : */ | |
1262 /* - frenquency band */ | |
1263 /* - modulation type */ | |
1264 /* - number of uplink timeslot */ | |
1265 /* - pointer to radio power control structure */ | |
1266 /* Return : */ | |
1267 /* - pointer to radio power control structure */ | |
1268 /* */ | |
1269 /* Functionality : This function returns a pointer to */ | |
1270 /* the radio power control structure after power */ | |
1271 /* reduction processing. */ | |
1272 /* Depending of the number of uplink timeslot, the */ | |
1273 /* analogue power control (apc) value can be reduced */ | |
1274 /* in order to limit effect of terminal heat */ | |
1275 /* dissipation due to power amplifier. */ | |
1276 /*-------------------------------------------------------*/ | |
1277 | |
1278 T_TX_LEVEL *Cust_get_uplink_apc_power_reduction(UWORD8 band, | |
1279 UWORD8 number_uplink_timeslot, | |
1280 T_TX_LEVEL *p_tx_level) | |
1281 { | |
1282 T_TX_LEVEL *p_power_reduction_tx_level; | |
1283 | |
1284 #if TESTMODE | |
1285 if ((l1_config.TestMode == TRUE) && (l1_config.tmode.tx_params.power_reduction_enable == FALSE)) | |
1286 return p_tx_level ; // return without any power reduction | |
1287 #endif | |
1288 | |
1289 if ((number_uplink_timeslot >= 1) && (number_uplink_timeslot <= MAX_UPLINK_TIME_SLOT)) | |
1290 { | |
1291 number_uplink_timeslot--; // index start from 0 | |
1292 } | |
1293 else | |
1294 { | |
1295 return p_tx_level; // abnormal case we do not apply any power reduction | |
1296 } | |
1297 | |
1298 p_power_reduction_tx_level = &(rf_band[band].tx.levels_power_reduction[number_uplink_timeslot]); | |
1299 | |
1300 // We select the lowest power level in order to apply power reduction | |
1301 #if (CODE_VERSION != SIMULATION) | |
1302 if (p_tx_level->apc > p_power_reduction_tx_level->apc) // higher apc value means higher transmit power | |
1303 #else | |
1304 if (p_tx_level->apc < p_power_reduction_tx_level->apc) // ! for simulation rf apc tables are inverted so comparaison is the reverse | |
1305 #endif | |
1306 return p_power_reduction_tx_level; | |
1307 else | |
1308 return p_tx_level; | |
1309 } | |
1310 | |
1311 #endif | |
1312 #endif /* !RUN_FLASH */ | |
1313 | |
1314 #ifndef RUN_INT_RAM | |
1315 /*-------------------------------------------------------*/ | |
1316 /* Cust_Init_Layer1 */ | |
1317 /*-------------------------------------------------------*/ | |
1318 /* Parameters : */ | |
1319 /* Return : */ | |
1320 /* Functionality : Load and boot the DSP */ | |
1321 /* Initialize shared memory and L1 data structures */ | |
1322 /*-------------------------------------------------------*/ | |
1323 | |
1324 void Cust_Init_Layer1(void) | |
1325 { | |
1326 T_MMI_L1_CONFIG cfg; | |
1327 | |
1328 // Get the current band configuration from the flash | |
1329 #if (OP_WCP==1) && (OP_L1_STANDALONE!=1) | |
1330 extern unsigned char ffs_GetBand(); | |
1331 cfg.std = ffs_GetBand(); | |
1332 #else // NO OP_WCP | |
1333 // cfg.std = std; | |
1334 cfg.std = STD; | |
1335 #endif // OP_WCP | |
1336 | |
1337 cfg.tx_pwr_code = 1; | |
1338 | |
1339 // sleep management configuration | |
1340 | |
1341 #if(L1_POWER_MGT == 0) | |
1342 cfg.pwr_mngt = 0; | |
1343 cfg.pwr_mngt_mode_authorized = NO_SLEEP; //Sleep mode | |
1344 cfg.pwr_mngt_clocks = 0x5ff; // list of clocks cut in Big Sleep | |
1345 #endif | |
1346 #if(L1_POWER_MGT == 1) | |
1347 cfg.pwr_mngt = 1; | |
1348 cfg.pwr_mngt_mode_authorized = ALL_SLEEP; //Sleep mode | |
1349 cfg.pwr_mngt_clocks = 0x5ff; // list of clocks cut in Big Sleep | |
1350 #endif | |
1351 | |
1352 #if (CODE_VERSION != SIMULATION) | |
1353 cfg.dwnld = DWNLD; //external define from makefile | |
1354 #endif | |
1355 | |
1356 l1_initialize(&cfg); | |
1357 | |
1358 /* | |
1359 * The following conditioned-out line appears in the LoCosto version, | |
1360 * but not in the Leonardo binary object. Investigation has revealed | |
1361 * that the change is malicious: it disables ALL useful L1 traces. | |
1362 */ | |
1363 #if 0 | |
1364 //add below line for CSR 174476 | |
1365 trace_info.current_config->l1_dyn_trace = 0; //disable L1 trace after L1 init | |
1366 #endif | |
1367 | |
1368 get_cal_from_nvmem((UWORD8 *)&rf, sizeof(rf), RF_ID); | |
1369 get_cal_from_nvmem((UWORD8 *)&adc_cal, sizeof(adc_cal), ADC_ID); | |
1370 | |
1371 } | |
1372 #endif /* !RUN_INT_RAM */ | |
1373 | |
1374 /*****************************************************************************************/ | |
1375 /*************************** TESTMODE functions **********************************/ | |
1376 /*****************************************************************************************/ | |
1377 | |
1378 | |
1379 #ifndef RUN_FLASH | |
1380 /*------------------------------------------------------*/ | |
1381 /* madc_hex_2_physical */ | |
1382 /*------------------------------------------------------*/ | |
1383 /* Parameters : */ | |
1384 /* Return : */ | |
1385 /* Functionality : Function to convert MAD hexadecimal */ | |
1386 /* values into physical values */ | |
1387 /*------------------------------------------------------*/ | |
1388 | |
1389 void madc_hex_2_physical (UWORD16 *adc_hex, T_ADC *adc_phy) | |
1390 { | |
1391 WORD16 i; | |
1392 UWORD16 y; | |
1393 WORD16 Smin = 0, Smax = TEMP_TABLE_SIZE-1; | |
1394 WORD16 index = (TEMP_TABLE_SIZE-1)/2; /* y is the adc code after compensation of ADC slope error introduced by VREF error */ | |
1395 | |
1396 //store raw ADC values | |
1397 memcpy(&adc.raw[0], adc_hex, sizeof(adc.raw)); | |
1398 | |
1399 // Convert Vbat [mV] : direct equation with slope and offset compensation | |
1400 for (i = ADC_VBAT; i<ADC_RFTEMP; i++) | |
1401 adc.converted[i] = (((UWORD32)(adc_cal.a[i] * adc.raw[i])) >>10) + adc_cal.b[i]; | |
1402 | |
1403 /*Convert RF Temperature [Celsius]: binsearch into a table*/ | |
1404 y = ((UWORD32)(adc_cal.a[ADC_RFTEMP] * adc.raw[ADC_RFTEMP]))>>8; /* rf.tempcal is the calibration of VREF*/ | |
1405 while((Smax-Smin) > 1 ) | |
1406 { | |
1407 if(y < temperature[index].adc) | |
1408 Smax=index; | |
1409 else | |
1410 Smin=index; | |
1411 | |
1412 index = (Smax+Smin)/2; | |
1413 } | |
1414 adc.converted[ADC_RFTEMP] = temperature[index].temp; | |
1415 | |
1416 for (i = ADC_RFTEMP+1; i<ADC_INDEX_END; i++) | |
1417 adc.converted[i] = (((UWORD32)(adc_cal.a[i] * adc.raw[i])) >>10) + adc_cal.b[i]; | |
1418 | |
1419 //store converted ADC values | |
1420 memcpy(adc_phy, &adc.converted[0], sizeof(adc.raw)); | |
1421 } | |
1422 #endif /* !RUN_FLASH */ | |
1423 | |
1424 #ifndef RUN_INT_RAM | |
1425 /*------------------------------------------------------*/ | |
1426 /* get_cal_from_nvmem */ | |
1427 /*------------------------------------------------------*/ | |
1428 /* Parameters : */ | |
1429 /* Return : */ | |
1430 /* Functionality : Copy calibrated parameter to */ | |
1431 /* calibration structure in RAM */ | |
1432 /*------------------------------------------------------*/ | |
1433 | |
1434 void get_cal_from_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id) | |
1435 { | |
1436 | |
1437 } | |
1438 | |
1439 /*------------------------------------------------------*/ | |
1440 /* save_cal_from_nvmem */ | |
1441 /*------------------------------------------------------*/ | |
1442 /* Parameters : */ | |
1443 /* Return : */ | |
1444 /* Functionality : Copy calibrated structure from RAM */ | |
1445 /* into NV memory */ | |
1446 /*------------------------------------------------------*/ | |
1447 | |
1448 UWORD8 save_cal_in_nvmem (UWORD8 *ptr, UWORD16 len, UWORD8 id) | |
1449 { | |
1450 return (0); | |
1451 } | |
1452 #endif /* !RUN_INT_RAM */ | |
1453 | |
1454 #if (TRACE_TYPE == 4) && !defined(RUN_FLASH) | |
1455 | |
1456 /*------------------------------------------------------*/ | |
1457 /* l1_cst_l1_parameters */ | |
1458 /*------------------------------------------------------*/ | |
1459 /* Parameters : s: pointer on configuration string */ | |
1460 /* Return : nothing: global var are set */ | |
1461 /* Functionality : Set global L1 vars for dynamic trace */ | |
1462 /* and configuration */ | |
1463 /* */ | |
1464 /* This function is called when a CST message is sent */ | |
1465 /* from the Condat Panel. */ | |
1466 /*------------------------------------------------------*/ | |
1467 void l1_cst_l1_parameters(char *s) | |
1468 { | |
1469 /* | |
1470 a sample command string can be: | |
1471 L1_PARAMS=<1,2,3,4,5> or | |
1472 L1_PARAMS=<1,23,3E32,4,5> | |
1473 with n parameters (here: 5 params); n>=1 | |
1474 parameters are decoded as hexadecimal unsigned integers (UWORD16) | |
1475 */ | |
1476 | |
1477 UWORD8 uNParams = 0; /* Number of parameters */ | |
1478 UWORD32 aParam[10]; /* Parameters array */ | |
1479 UWORD8 uIndex = 0; | |
1480 | |
1481 /* *** retrieve all parameters *** */ | |
1482 while (s[uIndex] != '<') uIndex++; | |
1483 uIndex++; | |
1484 aParam[0] = 0; | |
1485 | |
1486 /* uIndex points on 1st parameter */ | |
1487 | |
1488 while (s[uIndex] != '>') | |
1489 { | |
1490 if (s[uIndex] == ',') | |
1491 { | |
1492 uNParams++; | |
1493 aParam[uNParams] = 0; | |
1494 } | |
1495 else | |
1496 { | |
1497 /* uIndex points on a parameter char */ | |
1498 UWORD8 uChar = s[uIndex]; | |
1499 aParam[uNParams] = aParam[uNParams] << 4; /* shift 4 bits left */ | |
1500 if ((uChar>='0') && (uChar<='9')) | |
1501 aParam[uNParams] += (uChar - '0'); /* retrieve value */ | |
1502 else if ((uChar>='A') && (uChar<='F')) | |
1503 aParam[uNParams] += (10 + uChar - 'A'); /* retrieve value */ | |
1504 else if ((uChar>='a') && (uChar<='f')) | |
1505 aParam[uNParams] += (10 + uChar - 'a'); /* retrieve value */ | |
1506 } | |
1507 | |
1508 uIndex++; /* go to next char */ | |
1509 } | |
1510 | |
1511 /* increment number of params */ | |
1512 uNParams++; | |
1513 | |
1514 /* *** handle parameters *** */ | |
1515 /* | |
1516 1st param: command type | |
1517 2nd param: argument for command type | |
1518 */ | |
1519 switch (aParam[0]) | |
1520 { | |
1521 case 0: /* Trace setting */ | |
1522 /* The 2nd parameter contains the trace bitmap*/ | |
1523 if (uNParams >=2) | |
1524 trace_info.current_config->l1_dyn_trace = aParam[1]; | |
1525 else | |
1526 trace_info.current_config->l1_dyn_trace = 0; /* error case: disable all trace */ | |
1527 Trace_dyn_trace_change(); | |
1528 break; | |
1529 default: /* ignore it */ | |
1530 break; | |
1531 } // switch | |
1532 } | |
1533 | |
1534 #endif | |
1535 | |
1536 #if ((CHIPSET == 2) || (CHIPSET == 3) || (CHIPSET == 4) || \ | |
1537 (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || \ | |
1538 (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || \ | |
1539 (CHIPSET == 11) || (CHIPSET == 12)) | |
1540 #ifndef RUN_FLASH | |
1541 /*-------------------------------------------------------*/ | |
1542 /* power_down_config() : temporary implementation !!! */ | |
1543 /*-------------------------------------------------------*/ | |
1544 /* Parameters : sleep_mode (NO, SMALL, BIG, DEEP or ALL) */ | |
1545 /* clocks to be cut in BIG sleep */ | |
1546 /* Return : */ | |
1547 /* Functionality : set the l1s variables */ | |
1548 /* l1s.pw_mgr.mode_authorized and l1s.pw_mgr.clocks */ | |
1549 /* according to the desired mode. */ | |
1550 /*-------------------------------------------------------*/ | |
1551 void power_down_config(UWORD8 sleep_mode, UWORD16 clocks) | |
1552 { | |
1553 #if (OP_L1_STANDALONE == 1) | |
1554 if(sleep_mode != NO_SLEEP) | |
1555 #endif | |
1556 { | |
1557 l1_config.pwr_mngt = PWR_MNGT; | |
1558 l1s.pw_mgr.mode_authorized = sleep_mode; | |
1559 l1s.pw_mgr.clocks = clocks; | |
1560 } | |
1561 | |
1562 #if (OP_L1_STANDALONE == 0) | |
1563 l1s.pw_mgr.enough_gaug = FALSE; | |
1564 #endif | |
1565 } | |
1566 #endif | |
1567 #endif |