comparison L1/cust0/l1_cust.c @ 19:12f6c51be7b3

l1_cust.c: TCS211 reconstruction changes applied
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 10 Jun 2016 07:53:54 +0000
parents 75a11d740a02
children
comparison
equal deleted inserted replaced
18:a872b92dcd3c 19:12f6c51be7b3
271 /*-------------------------------------------------------*/ 271 /*-------------------------------------------------------*/
272 272
273 UWORD8 Cust_recover_Os(void) 273 UWORD8 Cust_recover_Os(void)
274 { 274 {
275 #if (CODE_VERSION != SIMULATION) 275 #if (CODE_VERSION != SIMULATION)
276 if (l1_config.pwr_mngt == PWR_MNGT)
277 {
278 UWORD32 current_system_clock; 276 UWORD32 current_system_clock;
279 277
280 /***************************************************/ 278 /***************************************************/
281 // Fix System clock and Nucleus Timers if any.... */ 279 // Fix System clock and Nucleus Timers if any.... */
282 /***************************************************/ 280 /***************************************************/
298 //............. 296 //.............
299 //............. 297 //.............
300 //.............. 298 //..............
301 return(TRUE); 299 return(TRUE);
302 300
303 } 301 #endif
304 #endif
305 return(TRUE); //omaps00090550
306 } 302 }
307 303
308 304
309 305
310 /*-------------------------------------------------------*/ 306 /*-------------------------------------------------------*/
327 /* ------- */ 323 /* ------- */
328 /* DO_NOT_SLEEP, FRAME_STOP or CLOCK_STOP */ 324 /* DO_NOT_SLEEP, FRAME_STOP or CLOCK_STOP */
329 /*-------------------------------------------------------*/ 325 /*-------------------------------------------------------*/
330 UWORD8 Cust_check_system(void) 326 UWORD8 Cust_check_system(void)
331 { 327 {
328 extern UWORD8 why_big_sleep;
332 329
333 #if (CODE_VERSION != SIMULATION) 330 #if (CODE_VERSION != SIMULATION)
334 if (l1_config.pwr_mngt == PWR_MNGT) 331 /* FreeCalypso change: this LT_Status() function is defunct */
332 #if 0
333 // Forbid deep sleep if the light is on
334 if(LT_Status())
335 { 335 {
336 336 //cut ARMIO and UWIRE clocks in big sleep
337 #if (L2_L3_SIMUL == 0) 337 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ;
338 // Forbid deep sleep if the light is on 338 why_big_sleep = BIG_SLEEP_DUE_TO_LIGHT_ON;
339 /* FreeCalypso change: this LT_Status() function is defunct */ 339 return(FRAME_STOP); // BIG sleep
340 #if 0 340 }
341 if(LT_Status()) 341 #endif
342
343 // Forbid deep sleep if the SIM and UARTs not ready
344 #if CONFIG_INCLUDE_SIM
345 if(SIM_SleepStatus())
346 #endif
347 {
348 if(SER_UartSleepStatus())
342 { 349 {
343 //cut ARMIO and UWIRE clocks in big sleep 350 return(CLOCK_STOP); // DEEP 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 } 351 }
348 #endif 352 else why_big_sleep = BIG_SLEEP_DUE_TO_UART;
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 } 353 }
354 #if CONFIG_INCLUDE_SIM
355 else why_big_sleep = BIG_SLEEP_DUE_TO_SIM;
356 #endif
357
358 // cut ARMIO and UWIRE clocks in big sleep
359 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ;
360 return(FRAME_STOP); // BIG sleep
388 #else // Simulation part 361 #else // Simulation part
389 return(CLOCK_STOP); // DEEP sleep 362 return(CLOCK_STOP); // DEEP sleep
390 #endif 363 #endif
391 return(CLOCK_STOP); // omaps00090550
392 } 364 }
393 #endif /* !RUN_FLASH */ 365 #endif /* !RUN_FLASH */
394 366
395 #ifndef RUN_INT_RAM 367 #ifndef RUN_INT_RAM
396 /*-------------------------------------------------------*/ 368 /*-------------------------------------------------------*/
519 const T_CONFIG_FILE *f1 = config_files_band; 491 const T_CONFIG_FILE *f1 = config_files_band;
520 UWORD8 i; 492 UWORD8 i;
521 WORD32 offset; 493 WORD32 offset;
522 char name[64]; 494 char name[64];
523 char *p; 495 char *p;
524 #if (L1_FF_MULTIBAND == 0)
525 UWORD8 std = l1_config.std.id; 496 UWORD8 std = l1_config.std.id;
526 #endif
527 497
528 #if FFS_WORKAROUND == 1 498 #if FFS_WORKAROUND == 1
529 struct stat_s stat; 499 struct stat_s stat;
530 UWORD16 time; 500 UWORD16 time;
531 #endif 501 #endif
532 #if (L1_FF_MULTIBAND == 0)
533 for (i=0; i< GSM_BANDS; i++) 502 for (i=0; i< GSM_BANDS; i++)
534 { 503 {
535 if(std_config[std].band[i] !=0 ) 504 if(std_config[std].band[i] !=0 )
536 { 505 {
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]; 506 f1 = &config_files_band[0];
542 while (f1->name != NULL) 507 while (f1->name != NULL)
543 { 508 {
544 offset = (WORD32) f1->addr - (WORD32) &rf_band[0]; //offset in bytes 509 offset = (WORD32) f1->addr - (WORD32) &rf_band[0]; //offset in bytes
545 p = ((char *) &rf_band[i]) + offset; 510 p = ((char *) &rf_band[i]) + offset;
546 if (type == '*' || type == f1->name[0]) 511 if (type == '*' || type == f1->name[0])
547 { 512 {
548 strcpy(name, &f1->name[1]); 513 strcpy(name, &f1->name[1]);
549 strcat(name, "."); 514 strcat(name, ".");
550 #if (L1_FF_MULTIBAND == 0)
551 strcat(name, band_config[std_config[std].band[i]].name); 515 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 516
556 if (read == 1) 517 if (read == 1)
557 cal_fread(name, p, f1->size); 518 cal_fread(name, p, f1->size);
558 else //write == 0 519 else //write == 0
559 { 520 {
573 } 534 }
574 } 535 }
575 f1++; 536 f1++;
576 } 537 }
577 } 538 }
578 #if (L1_FF_MULTIBAND == 0) 539 }
579 }
580 #endif
581 } 540 }
582 541
583 542
584 /*-------------------------------------------------------*/ 543 /*-------------------------------------------------------*/
585 /* Cust_init_std() */ 544 /* Cust_init_std() */
587 /* Parameters : */ 546 /* Parameters : */
588 /* Return : */ 547 /* Return : */
589 /* Functionality : Init Standard variable configuration */ 548 /* Functionality : Init Standard variable configuration */
590 /*-------------------------------------------------------*/ 549 /*-------------------------------------------------------*/
591 void Cust_init_std(void) 550 void Cust_init_std(void)
592 #if (L1_FF_MULTIBAND == 0)
593 { 551 {
594 UWORD8 std = l1_config.std.id; 552 UWORD8 std = l1_config.std.id;
595 UWORD8 band1, band2; 553 UWORD8 band1, band2;
596 T_RF_BAND *pt1, *pt2; 554 T_RF_BAND *pt1, *pt2;
597 555
649 l1_config.std.radio_band_support = rf.radio_band_support; 607 l1_config.std.radio_band_support = rf.radio_band_support;
650 608
651 //TBD: DRP Calib: Currently the Calib Data are only used for the routines, TBD add to l1_config. from saved Calibration 609 //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 ? 610 // on a need basis ?
653 } 611 }
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 612
682 613
683 /*-------------------------------------------------------*/ 614 /*-------------------------------------------------------*/
684 /* Cust_init_params() */ 615 /* Cust_init_params() */
685 /*-------------------------------------------------------*/ 616 /*-------------------------------------------------------*/
769 l1_config.params.il_min = IL_MIN; 700 l1_config.params.il_min = IL_MIN;
770 701
771 l1_config.params.fixed_txpwr = FIXED_TXPWR; 702 l1_config.params.fixed_txpwr = FIXED_TXPWR;
772 l1_config.params.eeprom_afc = rf.afc.eeprom_afc; 703 l1_config.params.eeprom_afc = rf.afc.eeprom_afc;
773 l1_config.params.setup_afc_and_rf = SETUP_AFC_AND_RF; 704 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 705
776 l1_config.params.psi_sta_inv = rf.afc.psi_sta_inv; 706 l1_config.params.psi_sta_inv = rf.afc.psi_sta_inv;
777 l1_config.params.psi_st = rf.afc.psi_st; 707 l1_config.params.psi_st = rf.afc.psi_st;
778 l1_config.params.psi_st_32 = rf.afc.psi_st_32; 708 l1_config.params.psi_st_32 = rf.afc.psi_st_32;
779 l1_config.params.psi_st_inv = rf.afc.psi_st_inv; 709 l1_config.params.psi_st_inv = rf.afc.psi_st_inv;
785 #else 715 #else
786 #if (VCXO_ALGO == 1) 716 #if (VCXO_ALGO == 1)
787 l1_config.params.afc_dac_center = rf.afc.dac_center; // VCXO - assuming DAC linearity 717 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 718 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 719 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 720 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 721 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 722 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 723 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 724 l1_config.params.rgap_bad_snr_count_B = C_RGAP_BAD_SNR_COUNT_B; // VCXO - Prediction SNR count
799 #endif 725 #endif
898 /*-------------------------------------------------------*/ 824 /*-------------------------------------------------------*/
899 /* Parameters : */ 825 /* Parameters : */
900 /* Return : */ 826 /* Return : */
901 /* Functionality : returns agc value */ 827 /* Functionality : returns agc value */
902 /*-------------------------------------------------------*/ 828 /*-------------------------------------------------------*/
903 WORD8 Cust_get_agc_from_IL(UWORD16 radio_freq, UWORD16 agc_index, UWORD8 table_id,UWORD8 lna_off_val) 829 WORD8 Cust_get_agc_from_IL(UWORD16 radio_freq, UWORD16 agc_index, UWORD8 table_id)
904 { 830 {
905 831 WORD8 agc_value;
906 UWORD16 agc_index_temp; 832
907
908 // radio_freq currently not used 833 // radio_freq currently not used
909 // this parameter is passed in order to allow band dependent tables for specific RFs 834 // 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) 835 // (e.g. dual band RF with separate AGC H/W blocks for GSM and DCS)
911 836
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) 837 if (agc_index > 120)
915 agc_index = 120; // Clip agc_index 838 agc_index = 120; // Clip agc_index
916 839
917 switch (table_id) 840 switch (table_id)
918 { 841 {
919 case MAX_ID: return(rf.rx.agc.il2agc_max[agc_index]); 842 case MAX_ID:
920 case AV_ID: return(rf.rx.agc.il2agc_av[agc_index]); 843 agc_value = rf.rx.agc.il2agc_max[agc_index];
921 case PWR_ID: return(rf.rx.agc.il2agc_pwr[agc_index]); 844 break;
845 case AV_ID:
846 agc_value = rf.rx.agc.il2agc_av[agc_index];
847 break;
848 case PWR_ID:
849 agc_value = rf.rx.agc.il2agc_pwr[agc_index];
850 break;
922 } 851 }
923 return (0);//omaps00090550 852
853 return agc_value;
924 } 854 }
925 855
926 /*-------------------------------------------------------*/ 856 /*-------------------------------------------------------*/
927 /* Cust_get_agc_band */ 857 /* Cust_get_agc_band */
928 /*-------------------------------------------------------*/ 858 /*-------------------------------------------------------*/
936 UWORD16 Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band) 866 UWORD16 Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band)
937 #else 867 #else
938 UWORD16 inline Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band) 868 UWORD16 inline Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band)
939 #endif 869 #endif
940 { 870 {
941 // WORD32 i =0 ; //omaps00090550 871 WORD32 i ;
942 UWORD8 band_number; 872
943 873 for (i=0;i<RF_RX_CAL_CHAN_SIZE;i++)
944 for (band_number=0;band_number<RF_RX_CAL_CHAN_SIZE;band_number++)
945 { 874 {
946 if (arfcn <= rf_band[gsm_band].rx.agc_bands[band_number].upper_bound) 875 if (arfcn <= rf_band[gsm_band].rx.agc_bands[i].upper_bound)
947 return(band_number); 876 return(i);
948 } 877 }
949 // Should never happen! 878 // Should never happen!
950 return(0); 879 return(0);
951 } 880 }
952 881
953 #if (L1_FF_MULTIBAND == 0)
954 /*-------------------------------------------------------*/ 882 /*-------------------------------------------------------*/
955 /* Cust_is_band_high */ 883 /* Cust_is_band_high */
956 /*-------------------------------------------------------*/ 884 /*-------------------------------------------------------*/
957 /* Parameters : arfcn */ 885 /* Parameters : arfcn */
958 /* Return : 0 if low band */ 886 /* Return : 0 if low band */
969 max_carrier = band_config[std_config[std].band[0]].max_carrier; 897 max_carrier = band_config[std_config[std].band[0]].max_carrier;
970 898
971 return(((radio_freq >= l1_config.std.first_radio_freq) && 899 return(((radio_freq >= l1_config.std.first_radio_freq) &&
972 (radio_freq < (l1_config.std.first_radio_freq + max_carrier))) ? MULTI_BAND1 : MULTI_BAND2); 900 (radio_freq < (l1_config.std.first_radio_freq + max_carrier))) ? MULTI_BAND1 : MULTI_BAND2);
973 } 901 }
974 #endif
975 902
976 /*-------------------------------------------------------*/ 903 /*-------------------------------------------------------*/
977 /* l1ctl_encode_delta2() */ 904 /* l1ctl_encode_delta2() */
978 /*-------------------------------------------------------*/ 905 /*-------------------------------------------------------*/
979 /* Parameters : */ 906 /* Parameters : */
983 WORD8 l1ctl_encode_delta2(UWORD16 radio_freq) 910 WORD8 l1ctl_encode_delta2(UWORD16 radio_freq)
984 { 911 {
985 WORD8 delta2_freq; 912 WORD8 delta2_freq;
986 UWORD16 i; 913 UWORD16 i;
987 UWORD16 arfcn; 914 UWORD16 arfcn;
988 #if (L1_FF_MULTIBAND == 0)
989 UWORD8 band; 915 UWORD8 band;
990 916
991 band = Cust_is_band_high(radio_freq); 917 band = Cust_is_band_high(radio_freq);
992 arfcn = Convert_l1_radio_freq(radio_freq); 918 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 919
999 i = Cust_get_agc_band(arfcn,band); // 920 i = Cust_get_agc_band(arfcn,band); //
1000 delta2_freq = rf_band[band].rx.agc_bands[i].agc_calib; 921 delta2_freq = rf_band[band].rx.agc_bands[i].agc_calib;
1001 922
1002 //temperature compensation 923 //temperature compensation
1010 } 931 }
1011 932
1012 return(delta2_freq); 933 return(delta2_freq);
1013 } 934 }
1014 935
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 /************************************/ 936 /************************************/
1102 /* TX Management */ 937 /* TX Management */
1103 /************************************/ 938 /************************************/
1104 /*-------------------------------------------------------*/ 939 /*-------------------------------------------------------*/
1105 /* Cust_get_ramp_tab */ 940 /* Cust_get_ramp_tab */
1116 */ 951 */
1117 /*-------------------------------------------------------*/ 952 /*-------------------------------------------------------*/
1118 953
1119 void Cust_get_ramp_tab(API *a_ramp, UWORD8 txpwr_ramp_up, UWORD8 txpwr_ramp_down, UWORD16 radio_freq) 954 void Cust_get_ramp_tab(API *a_ramp, UWORD8 txpwr_ramp_up, UWORD8 txpwr_ramp_down, UWORD16 radio_freq)
1120 { 955 {
1121 UWORD16 index_up, index_down,j, arfcn; 956 UWORD16 index_up, index_down, j;
1122 #if (L1_FF_MULTIBAND == 0)
1123 UWORD8 band; 957 UWORD8 band;
1124 958
1125 band = Cust_is_band_high(radio_freq); 959 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 960
1133 index_up = rf_band[band].tx.levels[txpwr_ramp_up].ramp_index; 961 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; 962 index_down = rf_band[band].tx.levels[txpwr_ramp_down].ramp_index;
1135 963
1136 #if ((ANALOG == 1) || (ANALOG == 2) || (ANALOG == 3)) 964 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2) || (ANLG_FAM == 3))
1137 for (j=0; j<16; j++) 965 for (j=0; j<16; j++)
1138 { 966 {
1139 a_ramp[j]=((rf_band[band].tx.ramp_tables[index_down].ramp_down[j])<<11) | 967 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) | 968 ((rf_band[band].tx.ramp_tables[index_up].ramp_up[j]) << 6) |
1141 0x14; 969 0x14;
1142 } 970 }
1143 #endif 971 #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 } 972 }
1154 973
1155 /*-------------------------------------------------------*/ 974 /*-------------------------------------------------------*/
1156 /* get_pwr_data */ 975 /* get_pwr_data */
1157 /*-------------------------------------------------------*/ 976 /*-------------------------------------------------------*/
1158 /* Parameters : */ 977 /* Parameters : */
1159 /* Return : */ 978 /* Return : */
1160 /* Functionality : */ 979 /* Functionality : */
1161 /*-------------------------------------------------------*/ 980 /*-------------------------------------------------------*/
1162 981
1163 #if ((ANALOG == 1) || (ANALOG == 2) || (ANALOG == 3) || (RF_FAM == 61)) 982 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2) || (ANLG_FAM == 3))
1164 UWORD16 Cust_get_pwr_data(UWORD8 txpwr, UWORD16 radio_freq 983 UWORD16 Cust_get_pwr_data(UWORD8 txpwr, UWORD16 radio_freq)
1165 #if (REL99 && FF_PRF) 984 {
1166 , UWORD8 number_uplink_timeslot
1167 #endif
1168 )
1169 {
1170 985
1171 UWORD16 i,j; 986 UWORD16 i,j;
1172 UWORD16 arfcn; 987 UWORD16 arfcn;
1173 988 UWORD8 band;
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 989
1180 #if(ORDER2_TX_TEMP_CAL==1) 990 #if(ORDER2_TX_TEMP_CAL==1)
1181 WORD16 pwr_data; 991 WORD16 pwr_data;
1182 #else 992 #else
1183 UWORD16 pwr_data; 993 UWORD16 pwr_data;
1184 #endif 994 #endif
1185 995
1186 #if (L1_FF_MULTIBAND == 0) 996 band = Cust_is_band_high(radio_freq);
1187 UWORD8 band; 997 arfcn = Convert_l1_radio_freq(radio_freq);
1188 band = Cust_is_band_high(radio_freq); 998
1189 arfcn = Convert_l1_radio_freq(radio_freq); 999 i = rf_band[band].tx.levels[txpwr].chan_cal_index;
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; 1000 j=0;
1001 // get uncalibrated apc
1002 pwr_data = rf_band[band].tx.levels[txpwr].apc;
1213 1003
1214 while (arfcn > rf_band[band].tx.chan_cal_table[i][j].arfcn_limit) 1004 while (arfcn > rf_band[band].tx.chan_cal_table[i][j].arfcn_limit)
1215 j++; 1005 j++;
1216 1006
1217 // channel calibrate apc 1007 // channel calibrate apc
1218 pwr_data = ((UWORD32) (pwr_data * rf_band[band].tx.chan_cal_table[i][j].chan_cal))/128; 1008 pwr_data = ((UWORD32) (pwr_data * rf_band[band].tx.chan_cal_table[i][j].chan_cal))/128;
1219 1009
1220 // temperature compensate apc 1010 // temperature compensate apc
1221 { 1011 {
1222 T_TX_TEMP_CAL *pt; 1012 T_TX_TEMP_CAL *pt;
1223 1013
1224 pt = rf_band[band].tx.temp; 1014 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))) 1015 while (((WORD16)adc.converted[ADC_RFTEMP] > pt->temperature) && ((pt-rf_band[band].tx.temp) < (RF_TX_CAL_TEMP_SIZE-1)))
1226 pt++; 1016 pt++;
1227 #if(ORDER2_TX_TEMP_CAL==1) 1017 #if(ORDER2_TX_TEMP_CAL==1)
1228 pwr_data += (txpwr*(pt->a*txpwr + pt->b) + pt->c) / 64; //delta apc = ax^2+bx+c 1018 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; 1019 if(pwr_data < 0) pwr_data = 0;
1230 #else 1020 #else
1231 pwr_data += pt->apc_calib; 1021 pwr_data += pt->apc_calib;
1232 #endif 1022 #endif
1233 } 1023 }
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); 1024 return(pwr_data);
1252 } 1025 }
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 1026 #endif
1312 #endif /* !RUN_FLASH */ 1027 #endif /* !RUN_FLASH */
1313 1028
1314 #ifndef RUN_INT_RAM 1029 #ifndef RUN_INT_RAM
1315 /*-------------------------------------------------------*/ 1030 /*-------------------------------------------------------*/