comparison gsm-fw/L1/tpudrv/tpudrv12.c @ 579:df71726fa4e1

L1: checkpointing work in progress on tpudrv12.c
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 14 Aug 2014 21:00:17 +0000
parents
children df12004ac8ee
comparison
equal deleted inserted replaced
578:e9a87d682b97 579:df71726fa4e1
1 /*
2 * tpudrv12.c (TPU driver for RF type 12) is a required part of the L1
3 * code for TI GSM chipset solutions consisting of Calypso or other
4 * classic (non-LoCosto) DBB, one of the classic ABB chips such as Iota
5 * or Syren, and Rita RF transceiver; the number 12 refers to the latter.
6 *
7 * We, the FreeCalypso team, have not been able to find an original
8 * source for this C module: the LoCosto source has tpudrv61.c instead,
9 * supporting LoCosto RF instead of Rita, whereas the TSM30 source
10 * only supports non-TI RF transceivers. Our only available reference
11 * for what this tpudrv12.c module is supposed to contain is the
12 * tpudrv12.obj COFF object from the Leonardo semi-src deliverable.
13 *
14 * The present reconstruction has been made by copying tpudrv61.c and
15 * tweaking it to match the disassembly of the reference binary object
16 * named above.
17 */
18
19 #define TPUDRV12_C
20
21 #include "config.h"
22 #include "l1_confg.h"
23
24 #include "l1_macro.h"
25 #include "l1_const.h"
26 #include "l1_types.h"
27 #if TESTMODE
28 #include "l1tm_defty.h"
29 #endif
30 #if (AUDIO_TASK == 1)
31 #include "l1audio_const.h"
32 #include "l1audio_cust.h"
33 #include "l1audio_defty.h"
34 #endif
35 #if (L1_GTT == 1)
36 #include "l1gtt_const.h"
37 #include "l1gtt_defty.h"
38 #endif
39 #if (L1_MP3 == 1)
40 #include "l1mp3_defty.h"
41 #endif
42 #if (L1_MIDI == 1)
43 #include "l1midi_defty.h"
44 #endif
45
46 #if (L1_AAC == 1)
47 #include "l1aac_defty.h"
48 #endif
49
50 #include "l1_defty.h"
51 #include "l1_time.h"
52 #include "l1_ctl.h"
53 #include "tpudrv.h"
54 #include "tpudrv12.h"
55 #include "l1_rf12.h"
56
57 #include "sys_types.h"
58
59 #include "../../bsp/mem.h"
60 #include "../../bsp/armio.h"
61 #include "../../bsp/clkm.h"
62
63 // Global variables
64 extern T_L1_CONFIG l1_config;
65 extern UWORD16 AGC_TABLE[];
66 extern UWORD16 *TP_Ptr;
67 #if (L1_FF_MULTIBAND == 1)
68 extern const WORD8 rf_subband2band[RF_NB_SUBBANDS];
69 #endif
70
71 static WORD8 rf_index; // index into rf_path[]
72 static UWORD16 rf_chip_band; /* from tpudrv12.obj, not in tpudrv61.c */
73 static UWORD8 rfband; /* ditto */
74
75 // Internal function prototypes
76 void l1dmacro_rx_down (WORD32 t);
77
78 #if (L1_FF_MULTIBAND == 0)
79 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq);
80 WORD32 rf_init(WORD32 t);
81
82 // External function prototypes
83 UWORD8 Cust_is_band_high(UWORD16 radio_freq);
84 #endif
85
86
87 extern T_RF_BAND rf_band[];
88 extern T_RF rf;
89
90 /**************************************************************************/
91 /**************************************************************************/
92 /* DEFINITION OF MACROS FOR CHIPS SERIAL PROGRAMMATION */
93 /**************************************************************************/
94 /**************************************************************************/
95
96 /*------------------------------------------*/
97 /* Is arfcn in the DCS band (512-885) ? */
98 /*------------------------------------------*/
99 #define IS_HIGH_BAND(arfcn) (((arfcn >= 512) && (arfcn <= 885)) ? 1 : 0)
100
101 /*------------------------------------------*/
102 /* Send a value to Rita RF */
103 /*------------------------------------------*/
104 #define TSP_TO_RF(rf_data)\
105 {\
106 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, ((rf_data) >> 8) & 0xFF); \
107 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_2, (rf_data) & 0xFF); \
108 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x4F); \
109 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, 0x02); \
110 }
111
112 /*------------------------------------------*/
113 /* Send a TSP command to ABB */
114 /*------------------------------------------*/
115 #define TSP_TO_ABB(data)\
116 {\
117 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, (data) & 0xFF); \
118 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x06); \
119 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, 0x02); \
120 }
121
122 /*------------------------------------------*/
123 /* Trace arfcn for conversion debug */
124 /*------------------------------------------*/
125 #ifdef ARFCN_DEBUG
126 // ----Debug information : record all arfcn programmed into synthesizer!
127 #define MAX_ARFCN_TRACE 4096 // enough for 5 sessions of 124+374
128 SYS_UWORD16 arfcn_trace[MAX_ARFCN_TRACE];
129 static UWORD32 arfcn_trace_index = 0;
130
131 void trace_arfcn(SYS_UWORD16 arfcn)
132 {
133 arfcn_trace[arfcn_trace_index++] = arfcn;
134
135 // Wrap to beginning
136 if (arfcn_trace_index == MAX_ARFCN_TRACE)
137 arfcn_trace_index = 0;
138 }
139 #endif
140
141
142 /**************************************************************************/
143 /**************************************************************************/
144 /* DEFINITION OF HARWARE DEPENDANT CONSTANTS */
145 /**************************************************************************/
146 /**************************************************************************/
147
148 /**************************************************************************/
149 /**************************************************************************/
150 /* INTERNAL FUNCTIONS OF TPUDRV14.C */
151 /* EFFECTIVE DOWNLOADING THROUGH TSP */
152 /**************************************************************************/
153 /**************************************************************************/
154 // rx & tx
155 typedef struct tx_rx_s
156 {
157 UWORD16 farfcn0;
158 WORD8 ou;
159 }
160 T_TX_RX;
161
162 struct synth_s {
163 // common
164 UWORD16 arfcn0;
165 UWORD16 limit;
166 UWORD16 rf_chip_band; /* from tpudrv12.obj, not in tpudrv61.c */
167 T_TX_RX tx_rx[2];
168 };
169
170 struct rf_path_s {
171 UWORD8 rx_up;
172 UWORD8 rx_down;
173 UWORD8 tx_up;
174 UWORD8 tx_down;
175 struct synth_s *synth;
176 };
177
178 const struct synth_s synth_900[] =
179 {
180 { 0, 124, BAND_SELECT_GSM, {{ 890, 1}, { 935, 2}}},// gsm 0 - 124
181 {974, 1023, BAND_SELECT_GSM, {{ 880, 1}, { 925, 2}}},// egsm 975 - 1023
182 };
183
184 const struct synth_s synth_1800[] =
185 {
186 {511, 885, BAND_SELECT_DCS, {{1710, 1}, {1805, 1}}}, // dcs 512 - 885
187 };
188
189 const struct synth_s synth_1900[] =
190 {
191 {511, 810, BAND_SELECT_PCS, {{1850, 1}, {1930, 1}}}, // pcs 512 - 810;
192 };
193
194 const struct synth_s synth_850[] =
195 {
196 {127, 192, BAND_SELECT_850_LO, {{ 824, 2}, { 869, 2}}}, // gsm850 low
197 {127, 251, BAND_SELECT_850_HI, {{ 824, 1}, { 869, 2}}}, // gsm850 high
198 };
199
200 struct rf_path_s rf_path[] = { //same index used as for band_config[] - 1
201 { RU_900, RD_900, TU_900, TD_900, (struct synth_s *)synth_900 }, //EGSM
202 { RU_1800, RD_1800, TU_1800, TD_1800, (struct synth_s *)synth_1800}, //DCS
203 { RU_1900, RD_1900, TU_1900, TD_1900, (struct synth_s *)synth_1900}, //PCS
204 { RU_850, RD_850, TU_850, TD_850, (struct synth_s *)synth_850 }, //GSM850
205 { RU_900, RD_900, TU_900, TD_900, (struct synth_s *)synth_900 }, //GSM
206 };
207
208 /*
209 * Leonardo tpudrv12.obj contains a function named calc_a_b(); there is
210 * no such function in the LoCosto version, but there is a similar-looking
211 * calc_rf_freq() function instead. Let's try making our calc_a_b()
212 * from LoCosto's calc_rf_freq().
213 */
214
215 UWORD32 calc_a_b(UWORD16 arfcn, UWORD8 downlink)
216 {
217 UWORD32 farfcn; /* in 200 kHz units */
218 UWORD32 n; /* B * P + A */
219 struct synth_s *s;
220
221 s = rf_path[rf_index].synth;
222 while(s->limit < arfcn)
223 s++;
224
225 rf_chip_band = s->rf_chip_band;
226
227 // Convert the ARFCN to the channel frequency (times 5 to avoid the decimal value)
228 farfcn = 5*s->tx_rx[downlink].farfcn0 + (arfcn - s->arfcn0);
229 n = farfcn * s->tx_rx[downlink].ou;
230
231 /* magic A & B encoding for Rita */
232 return((n - 4096) << 3);
233 }
234
235 /*------------------------------------------*/
236 /* Convert_l1_radio_freq */
237 /*------------------------------------------*/
238 /* conversion of l1 radio_freq to */
239 /* real channel number */
240 /*------------------------------------------*/
241 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq)
242 {
243 switch(l1_config.std.id)
244 {
245 case GSM:
246 case DCS1800:
247 case PCS1900:
248 case GSM850:
249 return (radio_freq);
250 //omaps00090550 break;
251
252 case DUAL:
253 {
254 if (radio_freq < l1_config.std.first_radio_freq_band2)
255 // GSM band...
256 return(radio_freq);
257 else
258 // DCS band...
259 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512);
260 }
261 //omaps00090550 break;
262
263 case DUALEXT:
264 {
265 if (radio_freq < l1_config.std.first_radio_freq_band2)
266 // E-GSM band...
267 {
268 if(radio_freq <= 124)
269 // GSM part...
270 return(radio_freq);
271 if(radio_freq < 174)
272 // Extended part...
273 return (radio_freq - 125 + 975);
274 else
275 // Extended part, special case of ARFCN=0
276 return(0);
277 }
278 else
279 {
280 // DCS band...
281 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512);
282 }
283 }
284 // break;
285
286 case GSM_E:
287 {
288 if(radio_freq <= 124)
289 // GSM part...
290 return(radio_freq);
291 else
292 if(radio_freq < 174)
293 // Extended part...
294 return (radio_freq - 125 + 975);
295 else
296 // Extended part, special case of ARFCN=0
297 return(0);
298 }
299 //omaps00090550 break;
300
301 case DUAL_US:
302 {
303 if (radio_freq < l1_config.std.first_radio_freq_band2)
304 {
305 return(radio_freq - l1_config.std.first_radio_freq + 128);
306 }
307 else
308 {
309 // PCS band...
310 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512);
311 }
312 }
313 // break;
314
315 default: // should never occur.
316 return(radio_freq);
317 } // end of switch
318 }
319
320 /*------------------------------------------*/
321 /* rf_init */
322 /*------------------------------------------*/
323 /* Initialization routine for PLL */
324 /* Effective downloading through TSP */
325 /*------------------------------------------*/
326 /* Rita and LoCosto versions look totally */
327 /* different, reconstructing from disasm. */
328 /*------------------------------------------*/
329 WORD32 rf_init(WORD32 t)
330 {
331 *TP_Ptr++ = TPU_AT(t);
332 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x47);
333 t += 5;
334 *TP_Ptr++ = TPU_AT(t);
335 *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x00);
336 t += 8;
337 *TP_Ptr++ = TPU_AT(t);
338 *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x01);
339 t += 5;
340 *TP_Ptr++ = TPU_AT(t);
341 TSP_TO_RF(0x0012);
342 t += 7;
343 *TP_Ptr++ = TPU_AT(t);
344 *TP_Ptr++ = TPU_AT(t);
345 *TP_Ptr++ = TPU_AT(t);
346 *TP_Ptr++ = TPU_AT(t);
347 *TP_Ptr++ = TPU_AT(t);
348 *TP_Ptr++ = TPU_AT(t);
349 TSP_TO_RF(0x003A);
350 t += 117;
351 *TP_Ptr++ = TPU_AT(t);
352 TSP_TO_RF(0xC003);
353 t += 7;
354 *TP_Ptr++ = TPU_AT(t);
355 TSP_TO_RF(0x02FE);
356 t += 7;
357 *TP_Ptr++ = TPU_AT(t);
358 TSP_TO_RF(0x401F);
359 t += 7;
360 *TP_Ptr++ = TPU_AT(t);
361 TSP_TO_RF(0x043D);
362 t += 7;
363 return(t);
364 }
365
366 /*------------------------------------------*/
367 /* rf_init_light */
368 /*------------------------------------------*/
369 /* Initialization routine for PLL */
370 /* Effective downloading through TSP */
371 /*------------------------------------------*/
372 WORD32 rf_init_light(WORD32 t)
373 {
374 // initialization for change of multi-band configuration dependent on STD
375 return(t);
376 }
377
378 UWORD8 arfcn_to_rf_index(SYS_UWORD16 arfcn)
379 {
380 UWORD8 index;
381 extern const T_STD_CONFIG std_config[];
382 index = std_config[l1_config.std.id].band[0];
383
384 if ((std_config[l1_config.std.id].band[1] != BAND_NONE) && IS_HIGH_BAND(arfcn))
385 index = std_config[l1_config.std.id].band[1];
386
387 return (index - 1);
388 }
389
390 /*------------------------------------------*/
391 /* rf_program */
392 /*------------------------------------------*/
393 /* Programs the RF synthesizer */
394 /* called each frame */
395 /* downloads NA counter value */
396 /* t = start time in the current frame */
397 /*------------------------------------------*/ //change 2 UWORD8
398 UWORD32 rf_program(UWORD32 t, SYS_UWORD16 radio_freq, UWORD32 rx)
399 {
400 UWORD32 rfdiv;
401 SYS_UWORD16 arfcn;
402
403 rfband = Cust_is_band_high(radio_freq);
404
405 arfcn = Convert_l1_radio_freq(radio_freq);
406 #ifdef ARFCN_DEBUG
407 trace_arfcn(arfcn);
408 #endif
409 rf_index = arfcn_to_rf_index(arfcn);
410
411 rfdiv = calc_a_b(arfcn, rx);
412
413 if (rx != 1) {
414 TSP_TO_RF(rfdiv | REG_PLL);
415 *TP_Ptr++ = TPU_FAT(0x1274);
416 TSP_TO_RF(0x043A | rf_chip_band);
417 } else {
418 TSP_TO_RF(rfdiv | REG_PLL);
419 *TP_Ptr++ = TPU_FAT(0x12FD);
420 TSP_TO_RF(0x023A | rf_chip_band);
421 }
422
423 return(t);
424 }
425
426 /**************************************************************************/
427 /**************************************************************************/
428 /* EXTERNAL FUNCTIONS CALLED BY LAYER1 */
429 /* COMMON TO L1 and TOOLKIT */
430 /**************************************************************************/
431 /**************************************************************************/
432
433 /*------------------------------------------*/
434 /* agc */
435 /*------------------------------------------*/
436 /* Program a gain into IF amp */
437 /* agc_value : gain in dB */
438 /* */
439 /* additional parameter for LNA setting */
440 /*------------------------------------------*/
441 /* Rita and LoCosto versions look totally */
442 /* different, reconstructing from disasm. */
443 /*------------------------------------------*/
444
445 void l1dmacro_agc(SYS_UWORD16 radio_freq, WORD8 gain, UWORD8 lna_off)
446 {
447 int agc_table_index;
448 UWORD16 rf_data;
449
450 agc_table_index = gain - 2;
451 if (agc_table_index < 0)
452 agc_table_index++;
453 agc_table_index >>= 1;
454 if (gain >= 42)
455 agc_table_index = 19;
456 if (gain < 16)
457 agc_table_index = 6;
458 *TP_Ptr++ = TPU_FAT(0x1334);
459 rf_data = REG_RX;
460 if (!lna_off)
461 rf_data |= RF_GAIN;
462 rf_data |= AGC_TABLE[agc_table_index] << 11;
463 rf_data |= RX_CAL_MODE;
464 TSP_TO_RF(rf_data);
465 }
466
467 /*------------------------------------------*/
468 /* l1dmacro_rx_synth */
469 /*------------------------------------------*/
470 /* programs RF synth for recceive */
471 /*------------------------------------------*/
472 void l1dmacro_rx_synth(SYS_UWORD16 radio_freq)
473 {
474 UWORD32 t;
475
476 // Important: always use rx_synth_start_time for first TPU_AT
477 // Never remove below 2 lines!!!
478 t = l1_config.params.rx_synth_start_time;
479 *TP_Ptr++ = TPU_FAT (t);
480
481 t = rf_program(t, radio_freq, 1); // direction is set to 1 for Rx
482 }
483
484 /*------------------------------------------*/
485 /* l1dmacro_tx_synth */
486 /*------------------------------------------*/
487 /* programs RF synth for transmit */
488 /* programs OPLL for transmit */
489 /*------------------------------------------*/
490 void l1dmacro_tx_synth(SYS_UWORD16 radio_freq)
491 {
492 UWORD32 t;
493
494 // Important: always use tx_synth_start_time for first TPU_AT
495 // Never remove below 2 lines!!!
496 t = l1_config.params.tx_synth_start_time;
497 *TP_Ptr++ = TPU_FAT (t);
498
499 t = rf_program(t, radio_freq, 0); // direction set to 0 for Tx
500 }
501
502 /*------------------------------------------*/
503 /* l1dmacro_rx_up */
504 /*------------------------------------------*/
505 /* Open window for normal burst reception */
506 /*------------------------------------------*/
507 /* Rita version differs from LoCosto, */
508 /* reconstructing from disassembly. */
509 /*------------------------------------------*/
510 void l1dmacro_rx_up (void)
511 {
512 *TP_Ptr++ = TPU_FAT(0x1377);
513 TSP_TO_RF(0x0A3A | rf_chip_band);
514 *TP_Ptr++ = TPU_FAT(0x137E);
515 TSP_TO_ABB(0x10);
516 *TP_Ptr++ = TPU_FAT(0x1383);
517 TSP_TO_ABB(0x18);
518 *TP_Ptr++ = TPU_FAT(58);
519 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_up | 0x01);
520 *TP_Ptr++ = TPU_FAT(62);
521 TSP_TO_ABB(0x14);
522 }
523
524 /*------------------------------------------*/
525 /* l1pdmacro_rx_down */
526 /*------------------------------------------*/
527 /* Close window for normal burst reception */
528 /*------------------------------------------*/
529 /* Rita version differs from LoCosto, */
530 /* reconstructing from disassembly. */
531 /*------------------------------------------*/
532 void l1dmacro_rx_down (WORD32 t)
533 {
534 *TP_Ptr++ = TPU_FAT(t - 37);
535 TSP_TO_RF(0x003A);
536 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | 0x01);
537 *TP_Ptr++ = TPU_FAT(t - 4);
538 TSP_TO_ABB(0x00);
539 }
540
541 /*------------------------------------------*/
542 /* l1dmacro_tx_up */
543 /*------------------------------------------*/
544 /* Open transmission window for normal burst*/
545 /*------------------------------------------*/
546 /* Rita version differs from LoCosto, */
547 /* reconstructing from disassembly. */
548 /*------------------------------------------*/
549 void l1dmacro_tx_up (void)
550 {
551 if (l1_config.std.id == DCS1800 ||
552 rfband == MULTI_BAND2 &&
553 (l1_config.std.id == DUAL || l1_config.std.id == DUALEXT)) {
554 *TP_Ptr++ = TPU_FAT(0x127E);
555 TSP_TO_RF(0x0007);
556 *TP_Ptr++ = TPU_FAT(0x1288);
557 TSP_TO_RF(0xC00B);
558 *TP_Ptr++ = TPU_FAT(0x1292);
559 TSP_TO_RF(0x3077);
560 } else {
561 *TP_Ptr++ = TPU_FAT(0x127E);
562 TSP_TO_RF(0xC003);
563 }
564 *TP_Ptr++ = TPU_FAT(0x12C6);
565 TSP_TO_ABB(0x80);
566 *TP_Ptr++ = TPU_FAT(0x12E3);
567 TSP_TO_RF(0x243A | rf_chip_band);
568 *TP_Ptr++ = TPU_FAT(0x1302);
569 TSP_TO_ABB(0xC0);
570 *TP_Ptr++ = TPU_FAT(0x1352);
571 TSP_TO_ABB(0x80);
572 *TP_Ptr++ = TPU_FAT(0x1384);
573 TSP_TO_ABB(0xA0);
574 *TP_Ptr++ = TPU_FAT(16);
575 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | 0x01);
576
577
578 }
579
580 /*-------------------------------------------*/
581 /* l1dmacro_tx_down */
582 /*-------------------------------------------*/
583 /* Close transmission window for normal burst*/
584 /*-------------------------------------------*/
585 #if (L1_RF_KBD_FIX == 1)
586 void l1dmacro_tx_down (WORD32 t, BOOL tx_flag, UWORD8 adc_active, UWORD8 kbd_config)
587 {
588 UWORD8 kbd_tspact_config =0;
589
590 if (kbd_config == KBD_DISABLED)
591 kbd_tspact_config = KBD_DIS_TSPACT;
592
593
594 if (adc_active == ACTIVE) {
595 // 36qbits = (10qbits for TPU programming) + (26qbits duration to convert the first ADC channel (= Battery))
596 if ((t)<(TRF_T8+2-TRF_T9)) //Done to enable RACH Burst Support
597 {
598 l1dmacro_adc_read_tx (TRF_T8+10, rf_path[rf_index].tx_up);
599 }
600 else
601 {
602 l1dmacro_adc_read_tx (t + TRF_T9, rf_path[rf_index].tx_up);
603 }
604 }
605
606
607
608 // t10: disable APC
609 *TP_Ptr++ = TPU_FAT (t + TRF_T10);
610 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_L, kbd_tspact_config | LDO_EN | APC_EN | TX_START );
611
612 // t11: disable PA
613 *TP_Ptr++ = TPU_FAT (t + TRF_T11);
614 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_U, rf_path[rf_index].tx_down);
615 // disable Tx_Start
616 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_L, kbd_tspact_config | LDO_EN | APC_EN );
617
618 // t12: power off Locosto: IDLE SCRIPT
619 *TP_Ptr++ = TPU_FAT (t + TRF_T12);
620 MOVE_REG_TSP_TO_RF(START_SCRIPT(DRP_IDLE), ((UWORD16)( ((UWORD32)(&drp_regs->SCRIPT_STARTL))&0xFFFF)));
621
622 // t13: Switch off APC
623 *TP_Ptr++ = TPU_FAT (t + TRF_T13);
624 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_L, 0);
625
626 }
627 #endif /*(L1_RF_KBD_FIX == 1)*/
628
629
630
631 #if (L1_RF_KBD_FIX == 0)
632 void l1dmacro_tx_down (WORD32 t, BOOL tx_flag, UWORD8 adc_active)
633 {
634
635 if (adc_active == ACTIVE) {
636 // 36qbits = (10qbits for TPU programming) + (26qbits duration to convert the first ADC channel (= Battery))
637 l1dmacro_adc_read_tx (t + TRF_T9, rf_path[rf_index].tx_up);
638 }
639
640 // t10: disable APC
641 *TP_Ptr++ = TPU_FAT (t + TRF_T10);
642 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_L, kbd_tspact_config | LDO_EN | APC_EN | TX_START );
643
644 // t11: disable PA
645 *TP_Ptr++ = TPU_FAT (t + TRF_T11);
646 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_U, rf_path[rf_index].tx_down);
647 // disable Tx_Start
648 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_L, kbd_tspact_config | LDO_EN | APC_EN );
649
650 // t12: power off Locosto: IDLE SCRIPT
651 *TP_Ptr++ = TPU_FAT (t + TRF_T12);
652 MOVE_REG_TSP_TO_RF(START_SCRIPT(DRP_IDLE), (UWORD16)(&drp_regs->SCRIPT_STARTL));
653
654 // t13: Switch off APC
655 *TP_Ptr++ = TPU_FAT (t + TRF_T13);
656 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_L, 0);
657
658 }
659
660
661 #endif/*(L1_RF_KBD_FIX == 0)*/
662
663 /*
664 * l1dmacro_rx_nb
665 *
666 * Receive Normal burst
667 */
668 #if (L1_RF_KBD_FIX == 1)
669 #if (L1_MADC_ON == 1)
670 void l1dmacro_rx_nb (SYS_UWORD16 radio_freq, UWORD8 adc_active, UWORD8 csf_filter_choice
671 #if(NEW_SNR_THRESHOLD==1)
672 , UWORD8 saic_flag_rx_up
673 #endif
674 )
675 {
676 l1dmacro_rx_up(adc_active, csf_filter_choice, L1_KBD_DIS_RX_NB
677 #if(NEW_SNR_THRESHOLD==1)
678 , saic_flag_rx_up
679 #endif
680 );
681 l1dmacro_rx_down (STOP_RX_SNB);
682 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_NB * (-TRF_R3_1 + STOP_RX_SNB - TRF_R7);
683 }
684 #else
685 void l1dmacro_rx_nb (SYS_UWORD16 radio_freq,UWORD8 csf_filter_choice
686 #if(NEW_SNR_THRESHOLD==1)
687 , UWORD8 saic_flag_rx_up
688 #endif
689 )
690 {
691 l1dmacro_rx_up(csf_filter_choice, L1_KBD_DIS_RX_NB
692 #if(NEW_SNR_THRESHOLD==1)
693 , saic_flag_rx_up
694 #endif
695 );
696 l1dmacro_rx_down (STOP_RX_SNB);
697 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_NB * (-TRF_R3_1 + STOP_RX_SNB - TRF_R7);
698 }
699 #endif
700 #endif /*(L1_RF_KBD_FIX == 1)*/
701
702 #if (L1_RF_KBD_FIX == 0)
703 #if (L1_MADC_ON == 1)
704 void l1dmacro_rx_nb (SYS_UWORD16 radio_freq, UWORD8 adc_active, UWORD8 csf_filter_choice
705 #if(NEW_SNR_THRESHOLD==1)
706 , UWORD8 saic_flag_rx_up
707 #endif
708 )
709 {
710 l1dmacro_rx_up(adc_active, csf_filter_choice
711 #if(NEW_SNR_THRESHOLD==1)
712 , saic_flag_rx_up
713 #endif
714 );
715 l1dmacro_rx_down (STOP_RX_SNB);
716
717 }
718 #else
719 void l1dmacro_rx_nb (SYS_UWORD16 radio_freq,UWORD8 csf_filter_choice
720 #if(NEW_SNR_THRESHOLD==1)
721 , UWORD8 saic_flag_rx_up
722 #endif
723 )
724 {
725 l1dmacro_rx_up(csf_filter_choice
726 #if(NEW_SNR_THRESHOLD==1)
727 , saic_flag_rx_up
728 #endif
729 );
730 l1dmacro_rx_down (STOP_RX_SNB);
731
732 }
733 #endif
734
735 #endif/*(L1_RF_KBD_FIX == 0)*/
736
737
738
739 /*
740 * l1dmacro_rx_sb
741 * Receive Synchro burst
742 */
743 #if (L1_RF_KBD_FIX == 1)
744 #if (L1_MADC_ON == 1)
745 void l1dmacro_rx_sb (SYS_UWORD16 radio_freq,UWORD8 adc_active)
746 {
747 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_SB
748 #if(NEW_SNR_THRESHOLD==1)
749 , SAIC_OFF
750 #endif
751 );
752
753 l1dmacro_rx_down (STOP_RX_SB);
754 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_SB * (-TRF_R3_1 + STOP_RX_SB - TRF_R7);
755 }
756
757 #else
758 void l1dmacro_rx_sb (SYS_UWORD16 radio_freq)
759 {
760 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_SB
761 #if(NEW_SNR_THRESHOLD==1)
762 , SAIC_OFF
763 #endif
764 );
765 l1dmacro_rx_down (STOP_RX_SB);
766 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_SB * (-TRF_R3_1 + STOP_RX_SB - TRF_R7);
767 }
768 #endif
769
770 #endif/*(L1_RF_KBD_FIX == 1)*/
771
772 #if(L1_RF_KBD_FIX == 0)
773 #if (L1_MADC_ON == 1)
774 void l1dmacro_rx_sb (SYS_UWORD16 radio_freq,UWORD8 adc_active)
775 {
776 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER
777 #if(NEW_SNR_THRESHOLD==1)
778 , SAIC_OFF
779 #endif
780 );
781 l1dmacro_rx_down (STOP_RX_SB);
782
783 }
784
785 #else
786 void l1dmacro_rx_sb (SYS_UWORD16 radio_freq)
787 {
788 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER
789 #if(NEW_SNR_THRESHOLD==1)
790 , SAIC_OFF
791 #endif
792 );
793 l1dmacro_rx_down (STOP_RX_SB);
794
795 }
796 #endif
797
798 #endif/*(L1_RF_KBD_FIX == 0)*/
799
800 /*
801 * l1dmacro_rx_ms
802 *
803 * Receive Power Measurement window
804 */
805 #if(L1_RF_KBD_FIX == 1)
806 #if (L1_MADC_ON == 1)
807 void l1dmacro_rx_ms (SYS_UWORD16 radio_freq,UWORD8 adc_active)
808 {
809 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_MS
810 #if(NEW_SNR_THRESHOLD==1)
811 , SAIC_OFF
812 #endif
813 );
814 l1dmacro_rx_down (STOP_RX_PW_1);
815 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_MS * (-TRF_R3_1 + STOP_RX_PW_1 - TRF_R7);
816 }
817
818 #else
819 void l1dmacro_rx_ms (SYS_UWORD16 radio_freq)
820 {
821 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_MS
822 #if(NEW_SNR_THRESHOLD==1)
823 , SAIC_OFF
824 #endif
825 );
826 l1dmacro_rx_down (STOP_RX_PW_1);
827 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_MS * (-TRF_R3_1 + STOP_RX_PW_1 - TRF_R7);
828 }
829 #endif
830 #endif/*(L1_RF_KBD_FIX == 1)*/
831
832 #if(L1_RF_KBD_FIX == 0)
833 #if (L1_MADC_ON == 1)
834 void l1dmacro_rx_ms (SYS_UWORD16 radio_freq,UWORD8 adc_active)
835 {
836 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER
837 #if(NEW_SNR_THRESHOLD==1)
838 , SAIC_OFF
839 #endif
840 );
841 l1dmacro_rx_down (STOP_RX_PW_1);
842
843 }
844
845 #else
846 void l1dmacro_rx_ms (SYS_UWORD16 radio_freq)
847 {
848 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER
849 #if(NEW_SNR_THRESHOLD==1)
850 , SAIC_OFF
851 #endif
852 );
853 l1dmacro_rx_down (STOP_RX_PW_1);
854
855 }
856 #endif
857
858 #endif/*(L1_RF_KBD_FIX == 0)*/
859
860 /*
861 * l1dmacro_rx_fb
862 *
863 * Receive Frequency burst
864 */
865 #if(L1_RF_KBD_FIX == 1)
866 #if (L1_MADC_ON == 1)
867 void l1dmacro_rx_fb (SYS_UWORD16 radio_freq,UWORD8 adc_active)
868 #else
869 void l1dmacro_rx_fb (SYS_UWORD16 radio_freq)
870 #endif
871 {
872 #if (L1_MADC_ON == 1)
873 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_FB
874 #if(NEW_SNR_THRESHOLD==1)
875 , SAIC_OFF
876 #endif
877 );
878 #else
879 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_FB
880 #if(NEW_SNR_THRESHOLD==1)
881 , SAIC_OFF
882 #endif
883 );
884 #endif
885 l1s.total_kbd_on_time = 5000;
886 *TP_Ptr++ = TPU_AT(0);
887 *TP_Ptr++ = TPU_AT(0);
888 *TP_Ptr++ = TPU_AT(0);
889 *TP_Ptr++ = TPU_AT(0);
890 *TP_Ptr++ = TPU_AT(0);
891 *TP_Ptr++ = TPU_AT(0);
892 *TP_Ptr++ = TPU_AT(0);
893 *TP_Ptr++ = TPU_AT(0);
894 *TP_Ptr++ = TPU_AT(0);
895 *TP_Ptr++ = TPU_AT(0);
896 *TP_Ptr++ = TPU_AT(0);
897
898 l1dmacro_rx_down (STOP_RX_FB);
899 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_FB * (STOP_RX_FB - TRF_R7);
900 }
901 #endif/*(L1_RF_KBD_FIX == 1)*/
902
903 #if(L1_RF_KBD_FIX == 0)
904 #if (L1_MADC_ON == 1)
905 void l1dmacro_rx_fb (SYS_UWORD16 radio_freq,UWORD8 adc_active)
906 #else
907 void l1dmacro_rx_fb (SYS_UWORD16 radio_freq)
908 #endif
909 {
910 #if (L1_MADC_ON == 1)
911 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER
912 #if(NEW_SNR_THRESHOLD==1)
913 , SAIC_OFF
914 #endif
915 );
916 #else
917 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER
918 #if(NEW_SNR_THRESHOLD==1)
919 , SAIC_OFF
920 #endif
921 );
922 #endif
923
924 *TP_Ptr++ = TPU_AT(0);
925 *TP_Ptr++ = TPU_AT(0);
926 *TP_Ptr++ = TPU_AT(0);
927 *TP_Ptr++ = TPU_AT(0);
928 *TP_Ptr++ = TPU_AT(0);
929 *TP_Ptr++ = TPU_AT(0);
930 *TP_Ptr++ = TPU_AT(0);
931 *TP_Ptr++ = TPU_AT(0);
932 *TP_Ptr++ = TPU_AT(0);
933 *TP_Ptr++ = TPU_AT(0);
934 *TP_Ptr++ = TPU_AT(0);
935
936 l1dmacro_rx_down (STOP_RX_FB);
937
938 }
939
940 #endif/*(L1_RF_KBD_FIX == 0)*/
941
942 /*
943 * l1dmacro_rx_fb26
944 *
945 * Receive Frequency burst for TCH.
946 */
947 #if(L1_RF_KBD_FIX == 1)
948 #if (L1_MADC_ON == 1)
949 void l1dmacro_rx_fb26 (SYS_UWORD16 radio_freq,UWORD8 adc_active)
950 {
951 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_FB26
952 #if(NEW_SNR_THRESHOLD==1)
953 , SAIC_OFF
954 #endif
955 );
956 l1s.total_kbd_on_time = 5000;
957 *TP_Ptr++ = TPU_AT(0);
958
959 l1dmacro_rx_down (STOP_RX_FB26);
960 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_FB26 * (STOP_RX_FB26 - TRF_R7);
961 }
962
963 #else
964 void l1dmacro_rx_fb26 (SYS_UWORD16 radio_freq)
965 {
966 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_FB26
967 #if(NEW_SNR_THRESHOLD==1)
968 , SAIC_OFF
969 #endif
970 );
971 l1s.total_kbd_on_time = 5000;
972 *TP_Ptr++ = TPU_AT(0);
973
974 l1dmacro_rx_down (STOP_RX_FB26);
975 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_RX_FB26 * (STOP_RX_FB26 - TRF_R7);
976 }
977 #endif
978 #endif/*(L1_RF_KBD_FIX == 1)*/
979
980 #if(L1_RF_KBD_FIX == 0)
981 #if (L1_MADC_ON == 1)
982 void l1dmacro_rx_fb26 (SYS_UWORD16 radio_freq,UWORD8 adc_active)
983 {
984 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER
985 #if(NEW_SNR_THRESHOLD==1)
986 , SAIC_OFF
987 #endif
988 );
989
990 *TP_Ptr++ = TPU_AT(0);
991
992 l1dmacro_rx_down (STOP_RX_FB26);
993
994 }
995
996 #else
997 void l1dmacro_rx_fb26 (SYS_UWORD16 radio_freq)
998 {
999 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER
1000 #if(NEW_SNR_THRESHOLD==1)
1001 , SAIC_OFF
1002 #endif
1003 );
1004
1005 *TP_Ptr++ = TPU_AT(0);
1006
1007 l1dmacro_rx_down (STOP_RX_FB26);
1008
1009 }
1010 #endif
1011 #endif/*(L1_RF_KBD_FIX == 0)*/
1012
1013 /*
1014 * l1dmacro_tx_nb
1015 *
1016 * Transmit Normal burst
1017 */
1018 #if(L1_RF_KBD_FIX == 1)
1019
1020 void l1dmacro_tx_nb (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active)
1021 {
1022 l1dmacro_tx_up (L1_KBD_DIS_TX_NB);
1023 l1dmacro_tx_down (l1_config.params.tx_nb_duration, FALSE, adc_active, L1_KBD_DIS_TX_NB);
1024 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_TX_NB * (-TRF_T3_1 + l1_config.params.tx_nb_duration + TRF_T12);
1025 }
1026
1027 #endif/*#if(L1_RF_KBD_FIX == 1)*/
1028
1029 #if(L1_RF_KBD_FIX == 0)
1030 void l1dmacro_tx_nb (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active)
1031 {
1032 l1dmacro_tx_up ();
1033 l1dmacro_tx_down (l1_config.params.tx_nb_duration, FALSE, adc_active);
1034
1035 }
1036
1037 #endif/*#if(L1_RF_KBD_FIX == 0)*/
1038
1039 /*
1040 * l1dmacro_tx_ra
1041 *
1042 * Transmit Random Access burst
1043 */
1044 #if(L1_RF_KBD_FIX == 1)
1045
1046 void l1dmacro_tx_ra (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active)
1047 {
1048 l1dmacro_tx_up (L1_KBD_DIS_TX_RA);
1049 l1dmacro_tx_down (l1_config.params.tx_ra_duration, FALSE, adc_active, L1_KBD_DIS_TX_RA);
1050 l1s.total_kbd_on_time = l1s.total_kbd_on_time - L1_KBD_DIS_TX_RA * (-TRF_T3_1 + l1_config.params.tx_ra_duration + TRF_T12);
1051 }
1052 #endif /*#if(L1_RF_KBD_FIX == 1)*/
1053
1054 #if(L1_RF_KBD_FIX == 0)
1055 void l1dmacro_tx_ra (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active)
1056 {
1057 l1dmacro_tx_up ();
1058 l1dmacro_tx_down (l1_config.params.tx_ra_duration, FALSE, adc_active);
1059
1060 }
1061 #endif/*#if(L1_RF_KBD_FIX == 0)*/
1062
1063 /*
1064 * l1dmacro_rx_cont
1065 *
1066 * Receive continuously
1067 */
1068 #if(L1_RF_KBD_FIX == 1)
1069 #if (L1_MADC_ON == 1)
1070 void l1dmacro_rx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr,
1071 UWORD8 adc_active, UWORD8 csf_filter_choice
1072 #if(NEW_SNR_THRESHOLD==1)
1073 , UWORD8 saic_flag_rx_up
1074 #endif
1075 )
1076 {
1077 l1dmacro_rx_up (adc_active, csf_filter_choice, KBD_DISABLED
1078 #if(NEW_SNR_THRESHOLD==1)
1079 , saic_flag_rx_up
1080 #endif
1081 );
1082 }
1083 #else
1084 void l1dmacro_rx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr,
1085 UWORD8 csf_filter_choice
1086 #if(NEW_SNR_THRESHOLD==1)
1087 , UWORD8 saic_flag_rx_up
1088 #endif
1089 )
1090 {
1091 l1dmacro_rx_up (csf_filter_choice,KBD_DISABLED
1092 #if(NEW_SNR_THRESHOLD==1)
1093 , saic_flag_rx_up
1094 #endif
1095 );
1096 }
1097 #endif
1098 #endif/*#if(L1_RF_KBD_FIX == 1)*/
1099
1100 #if(L1_RF_KBD_FIX == 0)
1101 #if (L1_MADC_ON == 1)
1102 void l1dmacro_rx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr,
1103 UWORD8 adc_active, UWORD8 csf_filter_choice
1104 #if(NEW_SNR_THRESHOLD==1)
1105 , UWORD8 saic_flag_rx_up
1106 #endif
1107 )
1108 {
1109 l1dmacro_rx_up (adc_active, csf_filter_choice
1110 #if(NEW_SNR_THRESHOLD==1)
1111 , saic_flag_rx_up
1112 #endif
1113 );
1114 }
1115 #else
1116 void l1dmacro_rx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr,
1117 UWORD8 csf_filter_choice
1118 #if(NEW_SNR_THRESHOLD==1)
1119 , UWORD8 saic_flag_rx_up
1120 #endif
1121 )
1122 {
1123 l1dmacro_rx_up (csf_filter_choice
1124 #if(NEW_SNR_THRESHOLD==1)
1125 , saic_flag_rx_up
1126 #endif
1127 );
1128 }
1129 #endif
1130
1131 #endif/*#if(L1_RF_KBD_FIX == 0)*/
1132
1133
1134 /*
1135 * l1dmacro_tx_cont
1136 *
1137 * Transmit continuously
1138 */
1139 #if(L1_RF_KBD_FIX == 1)
1140 void l1dmacro_tx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr)
1141 {
1142 l1dmacro_tx_up (KBD_DISABLED);
1143 }
1144 #endif/*#if(L1_RF_KBD_FIX == 1)*/
1145
1146 #if(L1_RF_KBD_FIX == 0)
1147 void l1dmacro_tx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr)
1148 {
1149 l1dmacro_tx_up ();
1150 }
1151 #endif/*#if(L1_RF_KBD_FIX == 0)*/
1152
1153 /*
1154 * l1d_macro_stop_cont
1155 *
1156 * Stop continuous Tx or Rx
1157 */
1158 #if(L1_RF_KBD_FIX == 1)
1159 void l1dmacro_stop_cont (void)
1160 {
1161 if (l1_config.tmode.rf_params.down_up == TMODE_DOWNLINK)
1162 l1dmacro_rx_down(STOP_RX_SNB);
1163 else
1164 l1dmacro_tx_down(l1_config.params.tx_nb_duration, FALSE, 0, KBD_DISABLED);
1165 }
1166 #endif/*#if(L1_RF_KBD_FIX == 1)*/
1167
1168 #if(L1_RF_KBD_FIX == 0)
1169 void l1dmacro_stop_cont (void)
1170 {
1171 if (l1_config.tmode.rf_params.down_up == TMODE_DOWNLINK)
1172 l1dmacro_rx_down(STOP_RX_SNB);
1173 else
1174 l1dmacro_tx_down(l1_config.params.tx_nb_duration, FALSE, 0);
1175 }
1176
1177 #endif/* */
1178
1179
1180 /*------------------------------------------*/
1181 /* l1dmacro_reset_hw */
1182 /*------------------------------------------*/
1183 /* Reset and set OFFSET register */
1184 /*------------------------------------------*/
1185
1186 void l1dmacro_reset_hw(UWORD32 servingCellOffset)
1187 {
1188 TPU_Reset(1); // reset TPU only, no TSP reset
1189 TPU_Reset(0);
1190 TP_Ptr = (UWORD16 *) TPU_RAM;
1191
1192 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_U, TXM_SLEEP);
1193 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_L, TXM_SLEEP);
1194 MOVE_REG_TSP_TO_RF(START_SCRIPT(DRP_IDLE),((UWORD16)( ((UWORD32)(&drp_regs->SCRIPT_STARTL))&0xFFFF)));
1195
1196 *TP_Ptr++ = TPU_OFFSET(servingCellOffset);
1197
1198 }
1199
1200 // l1dmacro_RF_sleep
1201 // Program RF for BIG or DEEP sleep
1202
1203
1204 void l1dmacro_RF_sleep (void)
1205 {
1206 // sending REG_OFF script
1207 MOVE_REG_TSP_TO_RF(START_SCRIPT(DRP_REG_OFF), ((UWORD16)( ((UWORD32)(&drp_regs->SCRIPT_STARTL))&0xFFFF)));
1208
1209 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_U, TXM_SLEEP); //Shutdown FEM
1210
1211 *TP_Ptr++ = TPU_SLEEP;
1212 TP_Ptr = (SYS_UWORD16 *) TPU_RAM;
1213 TP_Enable(1);
1214 TPU_wait_idle();
1215
1216 }
1217
1218
1219 // l1dmacro_RF_wakeup
1220 //* wakeup RF from BIG or DEEP sleep
1221
1222 void l1dmacro_RF_wakeup (void)
1223 {
1224 // sending REG_ON script
1225 MOVE_REG_TSP_TO_RF(START_SCRIPT(DRP_REG_ON), ((UWORD16)( ((UWORD32)(&drp_regs->SCRIPT_STARTL))&0xFFFF)));
1226
1227 *TP_Ptr++ = TPU_SLEEP;
1228 TP_Ptr = (SYS_UWORD16 *) TPU_RAM;
1229 TP_Enable(1);
1230 TPU_wait_idle();
1231
1232
1233 }
1234
1235
1236 // l1dmacro_init_hw
1237 // Reset VEGA, then remove reset
1238 // Init RF/IF synthesizers
1239
1240 void l1dmacro_init_hw(void)
1241 {
1242 WORD32 t = 100; // start time for actions
1243
1244 TP_Reset(1); // reset TPU and TSP
1245
1246 // GSM 1.5 : TPU clock enable is in TPU
1247 //---------------------------------------
1248 TPU_ClkEnable(1); // TPU CLOCK ON
1249
1250 TP_Reset(0);
1251
1252
1253 TP_Ptr = (UWORD16 *) TPU_RAM;
1254
1255 // Set FEM to inactive state before turning ON the RF Board
1256 // At this point the RF regulators are still OFF. Thus the
1257 // FEM command is not inverted yet => Must use the FEM "SLEEP programming"
1258
1259
1260 // TPU_SLEEP
1261 l1dmacro_idle();
1262
1263 *TP_Ptr++ = TPU_AT(t);
1264 *TP_Ptr++ = TPU_SYNC(0);
1265
1266 //Check Initialisation or Reset for TPU2OCP
1267
1268
1269 *TP_Ptr++ = TPU_MOVE(REG_SPI_ACT_U, TXM_SLEEP);
1270
1271 t = 1000; // arbitrary start time
1272
1273 t = rf_init(t); // Initialize RF Board
1274
1275 *TP_Ptr++ = TPU_AT(t);
1276
1277 // TPU_SLEEP
1278 l1dmacro_idle();
1279
1280 return;
1281 }
1282
1283 /*------------------------------------------*/
1284 /* l1dmacro_init_hw_light */
1285 /*------------------------------------------*/
1286 /* Reset VEGA, then remove reset */
1287 /* Init RF/IF synthesizers */
1288 /*------------------------------------------*/
1289 void l1dmacro_init_hw_light(void)
1290 {
1291 UWORD32 t = 100; // start time for actions //
1292 TP_Ptr = (SYS_UWORD16 *) TPU_RAM; //
1293 *TP_Ptr++ = TPU_AT(t); //
1294 t = 1000; // arbitrary start time //
1295
1296 t = rf_init_light(t); // Initialize RF Board //
1297
1298 *TP_Ptr++ = TPU_AT(t); //
1299 l1dmacro_idle(); //
1300
1301 return;
1302 }
1303
1304 //BHO added
1305 /*
1306 * l1dmacro_rx_fbsb
1307 *
1308 * Receive Frequency burst
1309 */
1310
1311 #if ((REL99 == 1) && (FF_BHO == 1))
1312 #if(L1_RF_KBD_FIX == 1)
1313 #if (L1_MADC_ON == 1)
1314 void l1dmacro_rx_fbsb (SYS_UWORD16 radio_freq, UWORD8 adc_active)
1315 #else
1316 void l1dmacro_rx_fbsb (SYS_UWORD16 radio_freq)
1317 #endif
1318 {
1319 #if (L1_MADC_ON == 1)
1320 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_FB
1321 #if(NEW_SNR_THRESHOLD==1)
1322 , SAIC_OFF
1323 #endif
1324 );
1325 #else
1326 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER, L1_KBD_DIS_RX_FB);
1327 #endif
1328
1329
1330 // same as rx_fb
1331 *TP_Ptr++ = TPU_AT(0); // 1
1332 *TP_Ptr++ = TPU_AT(0); // 2
1333 *TP_Ptr++ = TPU_AT(0); // 3
1334 *TP_Ptr++ = TPU_AT(0); // 4
1335 *TP_Ptr++ = TPU_AT(0); // 5
1336 *TP_Ptr++ = TPU_AT(0); // 6
1337 *TP_Ptr++ = TPU_AT(0); // 7
1338 *TP_Ptr++ = TPU_AT(0); // 8
1339 *TP_Ptr++ = TPU_AT(0); // 9
1340 *TP_Ptr++ = TPU_AT(0); // 10
1341 *TP_Ptr++ = TPU_AT(0); // 11
1342
1343 // one more for SB
1344 *TP_Ptr++ = TPU_AT(0); // 12
1345
1346 l1dmacro_rx_down (STOP_RX_FBSB);
1347 }
1348 #endif/*(L1_RF_KBD_FIX == 1)*/
1349
1350 #if(L1_RF_KBD_FIX == 0)
1351 #if (L1_MADC_ON == 1)
1352 void l1dmacro_rx_fbsb (SYS_UWORD16 radio_freq, UWORD8 adc_active)
1353 #else
1354 void l1dmacro_rx_fbsb (SYS_UWORD16 radio_freq)
1355 #endif
1356 {
1357 #if (L1_MADC_ON == 1)
1358 l1dmacro_rx_up(adc_active, L1_SAIC_HARDWARE_FILTER);
1359 #else
1360 l1dmacro_rx_up(L1_SAIC_HARDWARE_FILTER);
1361 #endif
1362
1363 // same as rx_fb
1364 *TP_Ptr++ = TPU_AT(0); // 1
1365 *TP_Ptr++ = TPU_AT(0); // 2
1366 *TP_Ptr++ = TPU_AT(0); // 3
1367 *TP_Ptr++ = TPU_AT(0); // 4
1368 *TP_Ptr++ = TPU_AT(0); // 5
1369 *TP_Ptr++ = TPU_AT(0); // 6
1370 *TP_Ptr++ = TPU_AT(0); // 7
1371 *TP_Ptr++ = TPU_AT(0); // 8
1372 *TP_Ptr++ = TPU_AT(0); // 9
1373 *TP_Ptr++ = TPU_AT(0); // 10
1374 *TP_Ptr++ = TPU_AT(0); // 11
1375
1376 // one more for SB
1377 *TP_Ptr++ = TPU_AT(0); // 12
1378
1379 l1dmacro_rx_down (STOP_RX_FBSB);
1380 }
1381 #endif/*(L1_RF_KBD_FIX == 0)*/
1382 #endif // #if ((REL99 == 1) && (FF_BHO == 1))
1383
1384 ////BHO