FreeCalypso > hg > freecalypso-citrine
comparison L1/cfile/l1_ctl.c @ 8:b36540edb046
L1/cfile/l1_*.c: initial import from tcs211-l1-reconst
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 05:45:03 +0000 |
parents | 75a11d740a02 |
children | b80f0c5016ee |
comparison
equal
deleted
inserted
replaced
7:b7d857ebc9ca | 8:b36540edb046 |
---|---|
7 * | 7 * |
8 ************* Revision Controle System Header *************/ | 8 ************* Revision Controle System Header *************/ |
9 | 9 |
10 #define L1_CTL_C | 10 #define L1_CTL_C |
11 | 11 |
12 #include "config.h" | 12 #include "l1_macro.h" |
13 #include "l1_confg.h" | 13 #include "l1_confg.h" |
14 #include "l1_macro.h" | |
15 | 14 |
16 #if (CODE_VERSION == SIMULATION) | 15 #if (CODE_VERSION == SIMULATION) |
17 #include <string.h> | 16 #include <string.h> |
18 #include "l1_types.h" | 17 #include "l1_types.h" |
19 #include "sys_types.h" | 18 #include "sys_types.h" |
102 //ADDED FOR AAC | 101 //ADDED FOR AAC |
103 #if (L1_AAC == 1) | 102 #if (L1_AAC == 1) |
104 #include "l1aac_defty.h" | 103 #include "l1aac_defty.h" |
105 #endif | 104 #endif |
106 #include "l1_defty.h" | 105 #include "l1_defty.h" |
107 #include "../../gpf/inc/cust_os.h" | 106 #include "cust_os.h" |
108 #include "l1_msgty.h" | 107 #include "l1_msgty.h" |
109 #include "l1_varex.h" | 108 #include "l1_varex.h" |
110 #include "l1_proto.h" | 109 #include "l1_proto.h" |
111 #include "l1_tabs.h" | 110 #include "l1_tabs.h" |
112 #include "l1_ctl.h" | 111 #include "l1_ctl.h" |
146 | 145 |
147 /************************************/ | 146 /************************************/ |
148 /* Automatic frequency compensation */ | 147 /* Automatic frequency compensation */ |
149 /************************************/ | 148 /************************************/ |
150 | 149 |
150 /* | |
151 * FreeCalypso TCS211 reconstruction: the following 3 functions | |
152 * have been added in the LoCosto version of this module. | |
153 * We have conditioned them out in order to match the original | |
154 * TCS211 object; their uses have been conditioned out as well. | |
155 * | |
156 * These functions will need to re-enabled when their uses are | |
157 * re-enabled. | |
158 */ | |
159 | |
160 #if 0 | |
161 | |
151 #define L1_WORD16_POS_MAX (32767) | 162 #define L1_WORD16_POS_MAX (32767) |
152 #define L1_WORD16_NEG_MAX (-32768) | 163 #define L1_WORD16_NEG_MAX (-32768) |
153 #define L1_WORD32_POS_MAX ((unsigned long)(1<<31)-1) | 164 #define L1_WORD32_POS_MAX ((unsigned long)(1<<31)-1) |
154 #define L1_WORD32_NEG_MAX (-(unsigned long)(1<<31)) | 165 #define L1_WORD32_NEG_MAX (-(unsigned long)(1<<31)) |
155 | 166 |
223 result = L1_WORD32_NEG_MAX; | 234 result = L1_WORD32_NEG_MAX; |
224 } | 235 } |
225 } | 236 } |
226 return(result); | 237 return(result); |
227 } | 238 } |
228 | 239 #endif |
229 | 240 |
230 INLINE WORD32 Add_40b( WORD32 guard1guard2, WORD32 lvar1, WORD32 lvar2, WORD16 *guardout ) | 241 INLINE WORD32 Add_40b( WORD32 guard1guard2, WORD32 lvar1, WORD32 lvar2, WORD16 *guardout ) |
231 { | 242 { |
232 WORD32 result, temp, carry, Lvar1, Lvar2; | 243 WORD32 result, temp, carry, Lvar1, Lvar2; |
233 WORD16 guard1,guard2; | 244 WORD16 guard1,guard2; |
393 static WORD16 psi_quant; /* F13.3 */ | 404 static WORD16 psi_quant; /* F13.3 */ |
394 static WORD16 quant_avg; | 405 static WORD16 quant_avg; |
395 static UWORD32 M_Count; | 406 static UWORD32 M_Count; |
396 static WORD32 psi_avg[C_PSI_AVG_SIZE_D+1]; // Data history array | 407 static WORD32 psi_avg[C_PSI_AVG_SIZE_D+1]; // Data history array |
397 static WORD16 B_Count; // Counter for consecutive SNR below C_thr_snr | 408 static WORD16 B_Count; // Counter for consecutive SNR below C_thr_snr |
398 UWORD16 L = 10433; // Gain algo2 | 409 #if 0 /* LoCosto added var */ |
410 UWORD16 L = 10433; // Gain algo2 | |
411 #endif | |
399 static UWORD16 first_avg; | 412 static UWORD16 first_avg; |
400 static UWORD16 good_snr; | 413 static UWORD16 good_snr; |
401 | 414 |
402 /* to be able to keep in memory the old AFC variables in case of spurious | 415 /* to be able to keep in memory the old AFC variables in case of spurious |
403 FB detection */ | 416 FB detection */ |
407 #endif | 420 #endif |
408 #if (L1_FF_MULTIBAND == 1) | 421 #if (L1_FF_MULTIBAND == 1) |
409 UWORD8 physical_band_id; | 422 UWORD8 physical_band_id; |
410 #endif | 423 #endif |
411 | 424 |
412 | 425 #if 0 /* LoCosto added var init */ |
413 //Set AFC close loop gain for ALGO_AFC_LQG_PREDICTOR. | 426 //Set AFC close loop gain for ALGO_AFC_LQG_PREDICTOR. |
414 if(l1_mode==I_MODE)//MS is in Idle mode | 427 if(l1_mode==I_MODE)//MS is in Idle mode |
415 L = 41732; //F0.20 L=41732/2^20 = 0.04 | 428 L = 41732; //F0.20 L=41732/2^20 = 0.04 |
416 else //All other modes than Idle | 429 else //All other modes than Idle |
417 L = 10433; //F0.20 L=10433/2^20 = 0.01 | 430 L = 10433; //F0.20 L=10433/2^20 = 0.01 |
418 | 431 #endif |
419 | 432 |
420 #if (L1_FF_MULTIBAND == 0) | 433 #if (L1_FF_MULTIBAND == 0) |
421 | 434 |
422 if (((l1_config.std.id == DUAL) || (l1_config.std.id == DUALEXT) || (l1_config.std.id == DUAL_US)) && | 435 if (((l1_config.std.id == DUAL) || (l1_config.std.id == DUALEXT) || (l1_config.std.id == DUAL_US)) && |
423 #if (VCXO_ALGO == 1) | 436 #if (VCXO_ALGO == 1) |
654 | 667 |
655 }/*end AFC_CLOSE_LOOP*/ | 668 }/*end AFC_CLOSE_LOOP*/ |
656 } /* end else AFC_INIT*/ | 669 } /* end else AFC_INIT*/ |
657 | 670 |
658 *frame_count=0; | 671 *frame_count=0; |
659 //Locosto | 672 return(Psi_quant[C_N_del]>>3); /* F16.0 */ |
660 // return(Psi_quant[C_N_del]>>3); /* F16.0 */ | |
661 return(CONVERT_PSI_QUANT(Psi_quant[C_N_del])); /* F16.0 to 14.2 or 13.3 */ | |
662 | 673 |
663 #else | 674 #else |
664 | 675 |
665 } /* end case algo 1 */ | 676 } /* end case algo 1 */ |
666 | 677 |
676 case AFC_INIT_CENTER : | 687 case AFC_INIT_CENTER : |
677 case AFC_INIT_MAX : | 688 case AFC_INIT_MAX : |
678 case AFC_INIT_MIN : | 689 case AFC_INIT_MIN : |
679 quant_avg = 0; | 690 quant_avg = 0; |
680 M_Count = 0; | 691 M_Count = 0; |
681 for (i = 0; i <= C_PSI_AVG_SIZE_D ; i++) //omaps00090550 | 692 #if 0 /* present in LoCosto but not in TCS211 */ |
682 psi_avg[i] = 0; | 693 for (i = 0; i <= C_PSI_AVG_SIZE_D ; i++) //omaps00090550 |
683 first_avg = 1; | 694 psi_avg[i] = 0; |
684 good_snr = 0; | 695 #endif |
696 first_avg = 1; | |
697 good_snr = 0; | |
685 | 698 |
686 // DAC search algorithm is as follows - up to 12 attempts are made | 699 // DAC search algorithm is as follows - up to 12 attempts are made |
687 // DAC search algorithm uses three values : DAC_center -> DAC_max -> DAC_min -> | 700 // DAC search algorithm uses three values : DAC_center -> DAC_max -> DAC_min -> |
688 // The first four attempts are made on DAC_center | 701 // The first four attempts are made on DAC_center |
689 // The next four attempts are made on DAC_max | 702 // The next four attempts are made on DAC_max |
750 /*we check if var_32 + 0.5*2**19 is a multiple of 2**19 */ | 763 /*we check if var_32 + 0.5*2**19 is a multiple of 2**19 */ |
751 var_16 = (WORD16) | 764 var_16 = (WORD16) |
752 ((WORD32) (((WORD32)(var_32 + (1<<18))) / (1<<19))); | 765 ((WORD32) (((WORD32)(var_32 + (1<<18))) / (1<<19))); |
753 var_16 = var_16 * 8; | 766 var_16 = var_16 * 8; |
754 #endif | 767 #endif |
768 | |
769 #if 0 /* LoCosto code with saturation */ | |
755 if (var_16 > C_max_step) | 770 if (var_16 > C_max_step) |
756 psi_quant = Add_Sat_sign_16b(psi_quant,C_max_step); | 771 psi_quant = Add_Sat_sign_16b(psi_quant,C_max_step); |
757 else if (var_16 < C_min_step) | 772 else if (var_16 < C_min_step) |
758 psi_quant = Add_Sat_sign_16b(psi_quant,C_min_step); | 773 psi_quant = Add_Sat_sign_16b(psi_quant,C_min_step); |
759 else psi_quant = Add_Sat_sign_16b(psi_quant,var_16); /* F13.3 */ | 774 else psi_quant = Add_Sat_sign_16b(psi_quant,var_16); /* F13.3 */ |
775 #else /* matching TCS211 */ | |
776 if (var_16 > C_max_step) | |
777 psi_quant += C_max_step; | |
778 else if (var_16 < C_min_step) | |
779 psi_quant += C_min_step; | |
780 else psi_quant += var_16; /* F13.3 */ | |
781 #endif | |
782 | |
760 /* F0.32 * F13.3 = F5.35 */ | 783 /* F0.32 * F13.3 = F5.35 */ |
761 psi_past[C_N_del]=Mult_40b(l1_config.params.psi_st_32,psi_quant, &guardout); | 784 psi_past[C_N_del]=Mult_40b(l1_config.params.psi_st_32,psi_quant, &guardout); |
762 /* (F13.3<<16 )+(F5.35>>16) = F13.19 */ | 785 /* (F13.3<<16 )+(F5.35>>16) = F13.19 */ |
763 psi_past[C_N_del]=((WORD32)guardout<<16)+((UWORD32)psi_past[C_N_del]>>16); | 786 psi_past[C_N_del]=((WORD32)guardout<<16)+((UWORD32)psi_past[C_N_del]>>16); |
764 | 787 |
844 | 867 |
845 Phi_32 = psi_past[C_N_del] - psi_past[0]; /* F13.19 */ | 868 Phi_32 = psi_past[C_N_del] - psi_past[0]; /* F13.19 */ |
846 /* Phi = angle - Phi_32*/ | 869 /* Phi = angle - Phi_32*/ |
847 Phi_32 = ((WORD32) angle << 4) - Phi_32; | 870 Phi_32 = ((WORD32) angle << 4) - Phi_32; |
848 /* F1.15 * 4 = F13.19 */ | 871 /* F1.15 * 4 = F13.19 */ |
849 Phi = (WORD16)((WORD32)((WORD32)(Phi_32 + (1<<3)))/ (1<<4)); /* F17.15 */ | 872 #if 0 /* LoCosto code */ |
873 Phi = (WORD16)((WORD32)((WORD32)(Phi_32 + (1<<3)))/ (1<<4)); /* F17.15 */ | |
874 #else /* TCS211 reconstruction */ | |
875 Phi = Phi_32 >> 4; | |
876 #endif | |
850 /* (F0.20 * F1.15) >> 16 = F13.19 */ | 877 /* (F0.20 * F1.15) >> 16 = F13.19 */ |
851 var_32 = (L * Phi + (1<<15)) >> 16; | 878 #if 0 /* LoCosto code with saturation and L */ |
852 psi_past[C_N_del] = Add_Sat_sign_32b(psi_past[C_N_del],var_32); | 879 var_32 = (L * Phi + (1<<15)) >> 16; |
853 | 880 psi_past[C_N_del] = Add_Sat_sign_32b(psi_past[C_N_del],var_32); |
881 #else /* matching TCS211 */ | |
882 psi_past[C_N_del] += (10433 * Phi) >> 16; | |
883 #endif | |
854 | 884 |
855 } | 885 } |
856 else | 886 else |
857 { | 887 { |
858 /************************************/ | 888 /************************************/ |
882 // Predict with 0th order estimation is the default | 912 // Predict with 0th order estimation is the default |
883 | 913 |
884 // Predict with 1st order estimation | 914 // Predict with 1st order estimation |
885 if (l1_config.params.rgap_algo >= 1) | 915 if (l1_config.params.rgap_algo >= 1) |
886 { | 916 { |
917 #if 0 /* LoCosto code with saturation */ | |
887 psi_past[C_N_del] = Add_Sat_sign_32b(psi_past[C_N_del], | 918 psi_past[C_N_del] = Add_Sat_sign_32b(psi_past[C_N_del], |
888 ((quant_avg * (l1_config.params.rgap_bad_snr_count_B))/(C_MSIZE)) | 919 ((quant_avg * (l1_config.params.rgap_bad_snr_count_B))/(C_MSIZE)) |
889 ); | 920 ); |
921 #else /* matching TCS211 */ | |
922 psi_past[C_N_del] += | |
923 ((quant_avg * (l1_config.params.rgap_bad_snr_count_B))/(C_MSIZE)); | |
924 #endif | |
890 } | 925 } |
891 | 926 |
892 B_Count= B_Count - l1_config.params.rgap_bad_snr_count_B; | 927 B_Count= B_Count - l1_config.params.rgap_bad_snr_count_B; |
893 | 928 |
894 // Indicate by raising first_avg flag that a reception gap has occurred | 929 // Indicate by raising first_avg flag that a reception gap has occurred |
904 } | 939 } |
905 | 940 |
906 /* Quantize psi value */ | 941 /* Quantize psi value */ |
907 | 942 |
908 /* F0.19 * 16.0 = F16.19 */ | 943 /* F0.19 * 16.0 = F16.19 */ |
909 var_32 = Sat_Mult_20sign_16unsign(psi_past[C_N_del],l1_config.params.psi_st_inv); | 944 #if 0 /* LoCosto code */ |
945 var_32 = Sat_Mult_20sign_16unsign(psi_past[C_N_del],l1_config.params.psi_st_inv); | |
946 #else /* TCS211 reconstruction */ | |
947 var_32 = psi_past[C_N_del] * l1_config.params.psi_st_inv; | |
948 #endif | |
910 | 949 |
911 #if(RF_FAM == 61) | 950 #if(RF_FAM == 61) |
912 /* In order to implement the NINT function for a F13.3,*/ | 951 /* In order to implement the NINT function for a F13.3,*/ |
913 /*we check if var_32 + 0.5*2**18 is a multiple of 2**18 */ | 952 /*we check if var_32 + 0.5*2**18 is a multiple of 2**18 */ |
914 var_16 = (WORD16) | 953 var_16 = (WORD16) |
930 break; | 969 break; |
931 } // switch phase | 970 } // switch phase |
932 | 971 |
933 *frame_count = 0; | 972 *frame_count = 0; |
934 | 973 |
935 //Locosto | 974 return (psi_quant >> 3); /* F16.0 */ |
936 // return (psi_quant >> 3); /* F16.0 */ | |
937 return(CONVERT_PSI_QUANT(psi_quant)); /* F16.0 to 14.2 or 13.3 */ | |
938 } /* end case algo 2 */ | 975 } /* end case algo 2 */ |
939 | 976 |
940 /* algo1 + init + estimator/predictor */ | 977 /* algo1 + init + estimator/predictor */ |
941 case ALGO_AFC_KALMAN_PREDICTOR: | 978 case ALGO_AFC_KALMAN_PREDICTOR: |
942 { | 979 { |
947 // directly loaded from EEPROM, and "snr" variable is not meaningful. | 984 // directly loaded from EEPROM, and "snr" variable is not meaningful. |
948 /* Static variables initialisation */ | 985 /* Static variables initialisation */ |
949 | 986 |
950 quant_avg = 0; | 987 quant_avg = 0; |
951 M_Count = 0; | 988 M_Count = 0; |
952 for (i = 0; i <=C_PSI_AVG_SIZE_D ; i++) //omaps00090550 | 989 #if 0 /* present in LoCosto but not in TCS211 */ |
953 psi_avg[i] = 0; | 990 for (i = 0; i <=C_PSI_AVG_SIZE_D ; i++) //omaps00090550 |
954 first_avg = 1; | 991 psi_avg[i] = 0; |
955 good_snr = 0; | 992 #endif |
993 first_avg = 1; | |
994 good_snr = 0; | |
956 | 995 |
957 // DAC search algorithm is as follows - up to 12 attempts are made | 996 // DAC search algorithm is as follows - up to 12 attempts are made |
958 // DAC search algorithm uses three values : DAC_center -> DAC_max -> DAC_min -> | 997 // DAC search algorithm uses three values : DAC_center -> DAC_max -> DAC_min -> |
959 // The first four attempts are made on DAC_center | 998 // The first four attempts are made on DAC_center |
960 // The next four attempts are made on DAC_max | 999 // The next four attempts are made on DAC_max |
1025 /* In order to implement the NINT function for a F16.0, we check */ | 1064 /* In order to implement the NINT function for a F16.0, we check */ |
1026 /* if var_32 + 0.5*2**19 is a multiple of 2**19 */ | 1065 /* if var_32 + 0.5*2**19 is a multiple of 2**19 */ |
1027 quotient=(WORD16)((WORD32)(((WORD32)(var_32+(1<<18)))/(1<<19))); | 1066 quotient=(WORD16)((WORD32)(((WORD32)(var_32+(1<<18)))/(1<<19))); |
1028 var_16=quotient*8; | 1067 var_16=quotient*8; |
1029 #endif | 1068 #endif |
1069 | |
1070 #if 0 /* LoCosto code with saturation */ | |
1030 if (var_16>C_max_step) | 1071 if (var_16>C_max_step) |
1031 Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],C_max_step); | 1072 Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],C_max_step); |
1032 else | 1073 else if (var_16<C_min_step) |
1033 if(var_16<C_min_step) | 1074 Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],C_min_step); |
1034 Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],C_min_step); | 1075 else Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],var_16); /* F13.3 */ |
1035 else Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],var_16); /* F13.3 */ | 1076 #else /* matching TCS211 */ |
1036 | 1077 if (var_16>C_max_step) |
1037 | 1078 Psi_quant[C_N_del] += C_max_step; |
1079 else if (var_16<C_min_step) | |
1080 Psi_quant[C_N_del] += C_min_step; | |
1081 else Psi_quant[C_N_del] += var_16; /* F13.3 */ | |
1082 #endif | |
1038 | 1083 |
1039 /* F0.32 * F13.3 = F5.35 */ | 1084 /* F0.32 * F13.3 = F5.35 */ |
1040 Psi=Mult_40b(l1_config.params.psi_st_32,Psi_quant[C_N_del], &guardout); | 1085 Psi=Mult_40b(l1_config.params.psi_st_32,Psi_quant[C_N_del], &guardout); |
1041 /* (F13.3<<16 )+(F5.35>>16) = F13.19 */ | 1086 /* (F13.3<<16 )+(F5.35>>16) = F13.19 */ |
1042 Psi=((WORD32)guardout<<16)+((UWORD32)Psi>>16); | 1087 Psi=((WORD32)guardout<<16)+((UWORD32)Psi>>16); |
1151 var1=(WORD32)guard1<<24; | 1196 var1=(WORD32)guard1<<24; |
1152 var1=var1/num; | 1197 var1=var1/num; |
1153 var1=(WORD32)var1<<8; | 1198 var1=(WORD32)var1<<8; |
1154 /* var2 is an unsigned variable, var1 contains signed guard*/ | 1199 /* var2 is an unsigned variable, var1 contains signed guard*/ |
1155 /* bits. */ | 1200 /* bits. */ |
1156 var2= ((WORD32)(denom)/(num)); //omaps00090550 | 1201 #if 0 /* fixed LoCosto code */ |
1202 var2= ((WORD32)(denom)/(num)); //omaps00090550 | |
1203 #else /* matching TCS211 */ | |
1204 var2= denom / num; | |
1205 #endif | |
1157 K = (var1+var2)<<1; /* F1.39 / F12.20 = F13.19 */ | 1206 K = (var1+var2)<<1; /* F1.39 / F12.20 = F13.19 */ |
1158 /* F13.19 << 1 = F12.20 */ | 1207 /* F13.19 << 1 = F12.20 */ |
1159 | 1208 |
1160 /* Clipping of the Kalman gain */ | 1209 /* Clipping of the Kalman gain */ |
1161 if (K>=C_thr_K) | 1210 if (K>=C_thr_K) |
1273 Psi_quant[C_N_del]=C_min_step; | 1322 Psi_quant[C_N_del]=C_min_step; |
1274 else Psi_quant[C_N_del]=var_16; /* F13.3 */ | 1323 else Psi_quant[C_N_del]=var_16; /* F13.3 */ |
1275 | 1324 |
1276 | 1325 |
1277 }/*end AFC_CLOSE_LOOP*/ | 1326 }/*end AFC_CLOSE_LOOP*/ |
1278 } /* end else AFC_INIT*/ | 1327 } /* end else AFC_INIT*/ |
1279 | 1328 |
1280 *frame_count = 0; | 1329 *frame_count = 0; |
1281 //Locosto | 1330 return(Psi_quant[C_N_del]>>3); /* F16.0 */ |
1282 // return(Psi_quant[C_N_del]>>3); /* F16.0 */ | |
1283 return(((CONVERT_PSI_QUANT(Psi_quant[C_N_del]))&0x3FFF)); /* F16.0 to 14.2 or 13.3 */ | |
1284 } /* end case algo 3 */ | 1331 } /* end case algo 3 */ |
1285 #endif | 1332 #endif |
1286 | 1333 |
1287 #if (VCXO_ALGO == 1) | 1334 #if (VCXO_ALGO == 1) |
1288 default: | 1335 default: |
1628 TOA_estimated=IZW; | 1675 TOA_estimated=IZW; |
1629 TOA_estimated *= 4; // unit in QBit | 1676 TOA_estimated *= 4; // unit in QBit |
1630 } | 1677 } |
1631 else | 1678 else |
1632 { | 1679 { |
1633 UWORD32 TOA_divisor = 0; | 1680 #if 0 /* fix added in LoCosto, not present in TCS211 */ |
1681 UWORD32 TOA_divisor; | |
1682 #endif | |
1634 TOA_estimated=(TOASP[IZW]*IZW)+(TOASP[IZW-1]*(IZW-1)>>C_GEW); | 1683 TOA_estimated=(TOASP[IZW]*IZW)+(TOASP[IZW-1]*(IZW-1)>>C_GEW); |
1635 TOA_estimated *= 8; //F13.3 in order to have qBit precision | 1684 TOA_estimated *= 8; //F13.3 in order to have qBit precision |
1685 #if 0 | |
1636 TOA_divisor = TOASP[IZW]+(TOASP[IZW-1] >> C_GEW); | 1686 TOA_divisor = TOASP[IZW]+(TOASP[IZW-1] >> C_GEW); |
1637 if (TOA_divisor!=0) | 1687 if (TOA_divisor!=0) |
1688 #endif | |
1638 { | 1689 { |
1639 TOA_estimated/= TOASP[IZW]+(TOASP[IZW-1] >> C_GEW); | 1690 TOA_estimated /= TOASP[IZW]+(TOASP[IZW-1] >> C_GEW); |
1640 TOA_estimated /= 2; // unit in QBit ("/8" then "*4" = "/2") | 1691 TOA_estimated /= 2; // unit in QBit ("/8" then "*4" = "/2") |
1641 } | 1692 } |
1693 #if 0 | |
1642 else | 1694 else |
1643 { | 1695 { |
1644 TOA_estimated = 0; | 1696 TOA_estimated = 0; |
1645 } | 1697 } |
1698 #endif | |
1646 } | 1699 } |
1647 | 1700 |
1648 if (Trans_active) | 1701 if (Trans_active) |
1649 TOA_estimated=(TOA_estimated+(Old_TOA_estimated+4)) / 2; | 1702 TOA_estimated=(TOA_estimated+(Old_TOA_estimated+4)) / 2; |
1650 | 1703 |
1828 /* Functionality : */ | 1881 /* Functionality : */ |
1829 /*-------------------------------------------------------*/ | 1882 /*-------------------------------------------------------*/ |
1830 #if(L1_FF_MULTIBAND == 0) | 1883 #if(L1_FF_MULTIBAND == 0) |
1831 WORD8 l1ctl_encode_delta1(UWORD16 radio_freq) | 1884 WORD8 l1ctl_encode_delta1(UWORD16 radio_freq) |
1832 { | 1885 { |
1886 WORD8 freq_band; | |
1887 | |
1833 switch(l1_config.std.id) | 1888 switch(l1_config.std.id) |
1834 { | 1889 { |
1835 case GSM: | 1890 case GSM: |
1836 case GSM_E: | 1891 case GSM_E: |
1837 case DCS1800: | 1892 case DCS1800: |
1838 case PCS1900: | 1893 case PCS1900: |
1839 case GSM850: | 1894 case GSM850: |
1840 return(l1_config.std.cal_freq1_band1); | 1895 freq_band = l1_config.std.cal_freq1_band1; |
1896 break; | |
1841 case DUAL: | 1897 case DUAL: |
1842 case DUALEXT: | 1898 case DUALEXT: |
1843 case DUAL_US: | 1899 case DUAL_US: |
1844 if(radio_freq >= l1_config.std.first_radio_freq_band2) | 1900 if(radio_freq >= l1_config.std.first_radio_freq_band2) |
1845 return(l1_config.std.cal_freq1_band2); | 1901 freq_band = l1_config.std.cal_freq1_band2; |
1846 else | 1902 else |
1847 return(l1_config.std.cal_freq1_band1); | 1903 freq_band = l1_config.std.cal_freq1_band1; |
1848 } | 1904 break; |
1849 return 0;//omaps00090550 | 1905 } |
1850 | 1906 return(freq_band); |
1851 } | 1907 } |
1852 #endif | 1908 #endif |
1853 /*-------------------------------------------------------*/ | 1909 /*-------------------------------------------------------*/ |
1854 /* l1ctl_encode_lna() */ | 1910 /* l1ctl_encode_lna() */ |
1855 /*-------------------------------------------------------*/ | 1911 /*-------------------------------------------------------*/ |
1925 /* LOW_AGC agc setting, then store, for the considered */ | 1981 /* LOW_AGC agc setting, then store, for the considered */ |
1926 /* carrier, the input level. */ | 1982 /* carrier, the input level. */ |
1927 /*-------------------------------------------------------*/ | 1983 /*-------------------------------------------------------*/ |
1928 UWORD8 l1ctl_csgc(UWORD8 pm, UWORD16 radio_freq) | 1984 UWORD8 l1ctl_csgc(UWORD8 pm, UWORD16 radio_freq) |
1929 { | 1985 { |
1930 WORD16 current_IL, current_calibrated_IL =0; //omaps00090550 | 1986 WORD16 current_IL, current_calibrated_IL; |
1931 WORD8 delta1_freq, delta2_freq; | 1987 WORD8 delta1_freq, delta2_freq; |
1932 WORD16 delta_drp_gain=0; | 1988 WORD16 delta_drp_gain=0; |
1933 UWORD32 index; | 1989 UWORD32 index; |
1934 UWORD16 g_magic; | 1990 UWORD16 g_magic; |
1935 UWORD16 arfcn; | 1991 #if (RF_FAM == 61) && (L1_FF_MULTIBAND == 0) |
1992 UWORD16 arfcn; | |
1993 #endif | |
1936 UWORD16 dco_algo_ctl_pw_temp = 0; | 1994 UWORD16 dco_algo_ctl_pw_temp = 0; |
1937 UWORD8 if_ctl = 0; | 1995 UWORD8 if_ctl = 0; |
1938 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) | 1996 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
1939 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; | 1997 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; |
1940 #endif | 1998 #endif |
1941 | 1999 |
1942 #if (L1_FF_MULTIBAND == 0) | 2000 #if (L1_FF_MULTIBAND == 0) |
1943 | 2001 |
1944 // initialize index | 2002 // initialize index |
1953 | 2011 |
1954 delta1_freq = l1ctl_encode_delta1(radio_freq); | 2012 delta1_freq = l1ctl_encode_delta1(radio_freq); |
1955 delta2_freq = l1ctl_encode_delta2(radio_freq); | 2013 delta2_freq = l1ctl_encode_delta2(radio_freq); |
1956 | 2014 |
1957 g_magic = l1ctl_get_g_magic(radio_freq); | 2015 g_magic = l1ctl_get_g_magic(radio_freq); |
1958 #if (L1_FF_MULTIBAND == 0) | 2016 |
2017 #if (RF_FAM == 61) && (L1_FF_MULTIBAND == 0) | |
1959 arfcn = Convert_l1_radio_freq(radio_freq); | 2018 arfcn = Convert_l1_radio_freq(radio_freq); |
1960 #endif | 2019 #endif |
1961 | 2020 |
1962 if (l1a_l1s_com.full_list.meas_1st_pass_read) | 2021 if (l1a_l1s_com.full_list.meas_1st_pass_read) |
1963 { | 2022 { |
1965 // with measurement achieved with HIGH_AGC setting. We are working | 2024 // with measurement achieved with HIGH_AGC setting. We are working |
1966 // with non calibrated IL to avoid saturation | 2025 // with non calibrated IL to avoid saturation |
1967 #if(RF_FAM == 61) | 2026 #if(RF_FAM == 61) |
1968 #if (CODE_VERSION != SIMULATION) | 2027 #if (CODE_VERSION != SIMULATION) |
1969 | 2028 |
1970 #if (PWMEAS_IF_MODE_FORCE == 0) | 2029 #if (PWMEAS_IF_MODE_FORCE == 0) |
1971 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_INVALID , | 2030 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_INVALID , |
1972 0, | 2031 0, |
1973 radio_freq,if_threshold); | 2032 radio_freq,if_threshold); |
1974 #else | 2033 #else |
1975 if_ctl = IF_120KHZ_DSP; | 2034 if_ctl = IF_120KHZ_DSP; |
1976 dco_algo_ctl_pw_temp = DCO_IF_0KHZ; | 2035 dco_algo_ctl_pw_temp = DCO_IF_0KHZ; |
1977 #endif | 2036 #endif |
1978 | 2037 |
1979 #if (L1_FF_MULTIBAND == 0) | 2038 #if (L1_FF_MULTIBAND == 0) |
1980 delta_drp_gain = drp_gain_correction(arfcn, LNA_ON, (l1_config.params.high_agc << 1)); // F7.1 format | 2039 delta_drp_gain = drp_gain_correction(arfcn, LNA_ON, (l1_config.params.high_agc << 1)); // F7.1 format |
1981 #else | 2040 #else |
1982 delta_drp_gain = drp_gain_correction(radio_freq, LNA_ON, (l1_config.params.high_agc << 1)); // F7.1 format | 2041 delta_drp_gain = drp_gain_correction(radio_freq, LNA_ON, (l1_config.params.high_agc << 1)); // F7.1 format |
1983 #endif // MULTIBAND == 0 else | 2042 #endif // MULTIBAND == 0 else |
1984 | 2043 |
1985 if(if_ctl == IF_100KHZ_DSP){ | 2044 if(if_ctl == IF_100KHZ_DSP){ |
1986 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ; | 2045 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ; |
1987 } | 2046 } |
1988 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/ | 2047 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/ |
2043 // we validate the measure and save input_level and lna_off fields. | 2102 // we validate the measure and save input_level and lna_off fields. |
2044 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), | 2103 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), |
2045 &(l1a_l1s_com.last_input_level[index].lna_off), | 2104 &(l1a_l1s_com.last_input_level[index].lna_off), |
2046 radio_freq); | 2105 radio_freq); |
2047 | 2106 |
2048 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)current_IL; | 2107 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)current_IL + |
2108 l1ctl_get_lna_att(radio_freq) * | |
2109 l1a_l1s_com.last_input_level[index].lna_off; | |
2110 | |
2049 l1a_l1s_com.full_list.sat_flag[l1a_l1s_com.full_list.next_to_read] = 0; | 2111 l1a_l1s_com.full_list.sat_flag[l1a_l1s_com.full_list.next_to_read] = 0; |
2050 } | 2112 } |
2051 } | 2113 } |
2052 else // 2nd pass if any. | 2114 else // 2nd pass if any. |
2053 { | 2115 { |
2055 // fields. | 2117 // fields. |
2056 #if(RF_FAM == 61) | 2118 #if(RF_FAM == 61) |
2057 #if (CODE_VERSION != SIMULATION) | 2119 #if (CODE_VERSION != SIMULATION) |
2058 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_INVALID, | 2120 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_INVALID, |
2059 0,radio_freq,if_threshold); | 2121 0,radio_freq,if_threshold); |
2060 #if (L1_FF_MULTIBAND == 0) | 2122 #if (L1_FF_MULTIBAND == 0) |
2061 delta_drp_gain = drp_gain_correction(arfcn, LNA_ON, (l1_config.params.low_agc << 1)); // F7.1 format | 2123 delta_drp_gain = drp_gain_correction(arfcn, LNA_ON, (l1_config.params.low_agc << 1)); // F7.1 format |
2062 #else | 2124 #else |
2063 delta_drp_gain = drp_gain_correction(radio_freq, LNA_ON, (l1_config.params.low_agc << 1)); // F7.1 format | 2125 delta_drp_gain = drp_gain_correction(radio_freq, LNA_ON, (l1_config.params.low_agc << 1)); // F7.1 format |
2064 #endif | 2126 #endif |
2065 if(if_ctl == IF_100KHZ_DSP){ | 2127 if(if_ctl == IF_100KHZ_DSP){ |
2066 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ; | 2128 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ; |
2067 } | 2129 } |
2068 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/ | 2130 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/ |
2069 delta_drp_gain += SCF_ATTENUATION_LIF_120KHZ; | 2131 delta_drp_gain += SCF_ATTENUATION_LIF_120KHZ; |
2087 | 2149 |
2088 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), | 2150 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), |
2089 &(l1a_l1s_com.last_input_level[index].lna_off), | 2151 &(l1a_l1s_com.last_input_level[index].lna_off), |
2090 radio_freq); | 2152 radio_freq); |
2091 | 2153 |
2092 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)current_IL; | 2154 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)current_IL + |
2155 l1ctl_get_lna_att(radio_freq) * | |
2156 l1a_l1s_com.last_input_level[index].lna_off; | |
2093 | 2157 |
2094 l1a_l1s_com.full_list.sat_flag[l1a_l1s_com.full_list.next_to_read] = 0; | 2158 l1a_l1s_com.full_list.sat_flag[l1a_l1s_com.full_list.next_to_read] = 0; |
2095 } | 2159 } |
2096 | 2160 |
2097 return((UWORD8)current_calibrated_IL); | 2161 return((UWORD8)current_calibrated_IL); |
2114 WORD32 last_known_agc; | 2178 WORD32 last_known_agc; |
2115 WORD32 current_IL, current_calibrated_IL; | 2179 WORD32 current_IL, current_calibrated_IL; |
2116 WORD8 delta1_freq, delta2_freq; | 2180 WORD8 delta1_freq, delta2_freq; |
2117 WORD16 delta_drp_gain=0; | 2181 WORD16 delta_drp_gain=0; |
2118 WORD32 index, lna_value; | 2182 WORD32 index, lna_value; |
2119 UWORD16 arfcn; | 2183 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2184 UWORD16 arfcn; | |
2185 #endif | |
2120 UWORD16 dco_algo_ctl_pw_temp = 0; | 2186 UWORD16 dco_algo_ctl_pw_temp = 0; |
2121 UWORD8 if_ctl = 0; | 2187 UWORD8 if_ctl = 0; |
2122 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) | 2188 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2123 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; | 2189 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; |
2124 #endif | 2190 #endif |
2125 | 2191 |
2126 #if (L1_FF_MULTIBAND == 0) | 2192 #if (L1_FF_MULTIBAND == 0) |
2127 | 2193 |
2128 // initialize index | 2194 // initialize index |
2137 delta1_freq = l1ctl_encode_delta1(radio_freq); | 2203 delta1_freq = l1ctl_encode_delta1(radio_freq); |
2138 delta2_freq = l1ctl_encode_delta2(radio_freq); | 2204 delta2_freq = l1ctl_encode_delta2(radio_freq); |
2139 | 2205 |
2140 lna_value = lna_off * l1ctl_get_lna_att(radio_freq); | 2206 lna_value = lna_off * l1ctl_get_lna_att(radio_freq); |
2141 | 2207 |
2142 last_known_agc = (Cust_get_agc_from_IL(radio_freq, last_known_il >> 1, PWR_ID, lna_off)) << 1; | 2208 last_known_agc = (Cust_get_agc_from_IL(radio_freq, last_known_il >> 1, PWR_ID)) << 1; |
2143 // F7.1 in order to be compatible with | 2209 // F7.1 in order to be compatible with |
2144 // pm and IL formats [-20,+140 in F7.1] | 2210 // pm and IL formats [-20,+140 in F7.1] |
2145 // contain the input_level value we use | 2211 // contain the input_level value we use |
2146 // in the associated CTL task to build | 2212 // in the associated CTL task to build |
2147 // the agc used in this CTL. | 2213 // the agc used in this CTL. |
2148 #if (L1_FF_MULTIBAND == 0) | 2214 |
2215 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) | |
2216 #if (L1_FF_MULTIBAND == 0) | |
2149 arfcn = Convert_l1_radio_freq(radio_freq); | 2217 arfcn = Convert_l1_radio_freq(radio_freq); |
2150 #else | 2218 #else |
2151 arfcn=radio_freq; | 2219 arfcn = radio_freq; |
2152 #endif | 2220 #endif |
2221 #endif | |
2153 | 2222 |
2154 #if(RF_FAM == 61) | 2223 #if(RF_FAM == 61) |
2155 #if (CODE_VERSION != SIMULATION) | 2224 #if (CODE_VERSION != SIMULATION) |
2156 | 2225 |
2157 #if (PWMEAS_IF_MODE_FORCE == 0) | 2226 #if (PWMEAS_IF_MODE_FORCE == 0) |
2173 | 2242 |
2174 #endif | 2243 #endif |
2175 #endif | 2244 #endif |
2176 | 2245 |
2177 if (0==pm) // Check and filter illegal pm value by using last valid IL | 2246 if (0==pm) // Check and filter illegal pm value by using last valid IL |
2178 current_IL = l1a_l1s_com.last_input_level[index].input_level ; | 2247 current_IL = l1a_l1s_com.last_input_level[index].input_level - lna_value; |
2179 else | 2248 else |
2180 current_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); | 2249 current_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); |
2181 | 2250 |
2182 current_calibrated_IL = current_IL - delta1_freq - delta2_freq; | 2251 current_calibrated_IL = current_IL - delta1_freq - delta2_freq; |
2183 | 2252 |
2190 // we validate the measure and save input_level and lna_off fields | 2259 // we validate the measure and save input_level and lna_off fields |
2191 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), | 2260 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), |
2192 &(l1a_l1s_com.last_input_level[index].lna_off), | 2261 &(l1a_l1s_com.last_input_level[index].lna_off), |
2193 radio_freq); | 2262 radio_freq); |
2194 | 2263 |
2195 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)current_IL; | 2264 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)current_IL + |
2265 l1ctl_get_lna_att(radio_freq) * | |
2266 l1a_l1s_com.last_input_level[index].lna_off; | |
2196 | 2267 |
2197 return((UWORD8)current_calibrated_IL); | 2268 return((UWORD8)current_calibrated_IL); |
2198 } | 2269 } |
2199 | 2270 |
2200 | 2271 |
2215 WORD8 delta1_freq, delta2_freq; | 2286 WORD8 delta1_freq, delta2_freq; |
2216 WORD16 delta_high_drp_gain=0; | 2287 WORD16 delta_high_drp_gain=0; |
2217 WORD16 delta_low_drp_gain=0; | 2288 WORD16 delta_low_drp_gain=0; |
2218 WORD32 index; | 2289 WORD32 index; |
2219 UWORD16 g_magic; | 2290 UWORD16 g_magic; |
2220 UWORD16 arfcn; | 2291 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2292 UWORD16 arfcn; | |
2293 #endif | |
2221 UWORD16 dco_algo_ctl_pw_temp = 0; | 2294 UWORD16 dco_algo_ctl_pw_temp = 0; |
2222 UWORD8 if_ctl = 0; | 2295 UWORD8 if_ctl = 0; |
2223 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) | 2296 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2224 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; | 2297 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; |
2225 #endif | 2298 #endif |
2226 | 2299 |
2227 #if (L1_FF_MULTIBAND == 0) | 2300 #if (L1_FF_MULTIBAND == 0) |
2228 | 2301 |
2229 // initialize index | 2302 // initialize index |
2242 g_magic = l1ctl_get_g_magic(radio_freq); | 2315 g_magic = l1ctl_get_g_magic(radio_freq); |
2243 | 2316 |
2244 // lna_off was set to 0 during CTRL, so lna_value = 0 do not appear in the following | 2317 // lna_off was set to 0 during CTRL, so lna_value = 0 do not appear in the following |
2245 // formula. | 2318 // formula. |
2246 | 2319 |
2247 #if (L1_FF_MULTIBAND == 0) | 2320 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2321 #if (L1_FF_MULTIBAND == 0) | |
2248 arfcn = Convert_l1_radio_freq(radio_freq); | 2322 arfcn = Convert_l1_radio_freq(radio_freq); |
2249 #else | 2323 #else |
2250 arfcn=radio_freq; | 2324 arfcn = radio_freq; |
2251 #endif | 2325 #endif |
2326 #endif | |
2252 | 2327 |
2253 if ((0==pm_high_agc) || (0==pm_low_agc)) // Check and filter illegal pm value(s) by using last valid IL | 2328 if ((0==pm_high_agc) || (0==pm_low_agc)) // Check and filter illegal pm value(s) by using last valid IL |
2254 new_IL = l1a_l1s_com.last_input_level[index].input_level; | 2329 new_IL = l1a_l1s_com.last_input_level[index].input_level; |
2255 else | 2330 else |
2256 { | 2331 { |
2339 // setting the AGC for the next task. | 2414 // setting the AGC for the next task. |
2340 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), | 2415 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1), |
2341 &(l1a_l1s_com.last_input_level[index].lna_off), | 2416 &(l1a_l1s_com.last_input_level[index].lna_off), |
2342 radio_freq); | 2417 radio_freq); |
2343 | 2418 |
2344 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)new_IL; | 2419 l1a_l1s_com.last_input_level[index].input_level = (UWORD8)new_IL + |
2420 l1ctl_get_lna_att(radio_freq) * | |
2421 l1a_l1s_com.last_input_level[index].lna_off; | |
2345 } | 2422 } |
2346 | 2423 |
2347 | 2424 |
2348 /*-------------------------------------------------------*/ | 2425 /*-------------------------------------------------------*/ |
2349 /* l1ctl_find_max() */ | 2426 /* l1ctl_find_max() */ |
2393 WORD32 last_known_agc; | 2470 WORD32 last_known_agc; |
2394 UWORD8 IL_max; | 2471 UWORD8 IL_max; |
2395 WORD32 current_IL, current_calibrated_IL; | 2472 WORD32 current_IL, current_calibrated_IL; |
2396 UWORD8 i; | 2473 UWORD8 i; |
2397 WORD32 lna_value; | 2474 WORD32 lna_value; |
2398 UWORD16 arfcn; | 2475 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2476 UWORD16 arfcn; | |
2477 #endif | |
2399 UWORD8 lna_off; | 2478 UWORD8 lna_off; |
2400 UWORD16 dco_algo_ctl_pw_temp = 0; | 2479 UWORD16 dco_algo_ctl_pw_temp = 0; |
2401 UWORD8 if_ctl = 0; | 2480 UWORD8 if_ctl = 0; |
2402 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) | 2481 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2403 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; | 2482 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; |
2404 #endif | 2483 #endif |
2405 | 2484 |
2406 delta1_freq = l1ctl_encode_delta1(radio_freq); | 2485 delta1_freq = l1ctl_encode_delta1(radio_freq); |
2407 delta2_freq = l1ctl_encode_delta2(radio_freq); | 2486 delta2_freq = l1ctl_encode_delta2(radio_freq); |
2408 | 2487 |
2414 // that was applied to signal when performing the power | 2493 // that was applied to signal when performing the power |
2415 // measure. | 2494 // measure. |
2416 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq); | 2495 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq); |
2417 | 2496 |
2418 // Compute applied agc for this pm | 2497 // Compute applied agc for this pm |
2419 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID,l1a_l1s_com.Scell_used_IL_dd.lna_off )) << 1; | 2498 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID)) << 1; |
2420 // F7.1 in order to be compatible | 2499 // F7.1 in order to be compatible |
2421 // with pm and IL formats | 2500 // with pm and IL formats |
2422 // contain the input_level value we use | 2501 // contain the input_level value we use |
2423 // in the associated CTL task to build | 2502 // in the associated CTL task to build |
2424 // the agc used in this CTL. | 2503 // the agc used in this CTL. |
2425 | 2504 |
2426 #if (L1_FF_MULTIBAND == 0) | 2505 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2506 #if (L1_FF_MULTIBAND == 0) | |
2427 arfcn = Convert_l1_radio_freq(radio_freq); | 2507 arfcn = Convert_l1_radio_freq(radio_freq); |
2428 #else | 2508 #else |
2429 arfcn=radio_freq; | 2509 arfcn = radio_freq; |
2430 #endif | 2510 #endif |
2511 #endif | |
2431 | 2512 |
2432 #if(RF_FAM == 61) | 2513 #if(RF_FAM == 61) |
2433 #if (CODE_VERSION != SIMULATION) | 2514 #if (CODE_VERSION != SIMULATION) |
2434 | 2515 |
2435 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID , | 2516 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID , |
2446 | 2527 |
2447 #endif | 2528 #endif |
2448 #endif | 2529 #endif |
2449 | 2530 |
2450 if (0==pm) // Check and filter illegal pm value by using last valid IL | 2531 if (0==pm) // Check and filter illegal pm value by using last valid IL |
2451 current_IL = IL_info_ptr->input_level; | 2532 current_IL = IL_info_ptr->input_level - lna_value; |
2452 else | 2533 else |
2453 current_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); | 2534 current_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); |
2454 | 2535 |
2455 current_calibrated_IL = current_IL - delta1_freq - delta2_freq; | 2536 current_calibrated_IL = current_IL - delta1_freq - delta2_freq; |
2456 | 2537 |
2467 //input levels are always stored with lna_on | 2548 //input levels are always stored with lna_on |
2468 l1ctl_encode_lna( (UWORD8)(current_calibrated_IL>>1), | 2549 l1ctl_encode_lna( (UWORD8)(current_calibrated_IL>>1), |
2469 &(IL_info_ptr->lna_off), | 2550 &(IL_info_ptr->lna_off), |
2470 radio_freq ); | 2551 radio_freq ); |
2471 | 2552 |
2472 IL_info_ptr->input_level = IL_max; | 2553 IL_info_ptr->input_level = IL_max + l1ctl_get_lna_att(radio_freq) * |
2554 IL_info_ptr->lna_off; | |
2473 | 2555 |
2474 #if L2_L3_SIMUL | 2556 #if L2_L3_SIMUL |
2475 #if (DEBUG_TRACE==BUFFER_TRACE_PAGC) | 2557 #if (DEBUG_TRACE==BUFFER_TRACE_PAGC) |
2476 buffer_trace(4,IL_info_ptr->input_level,last_known_agc, | 2558 buffer_trace(4,IL_info_ptr->input_level,last_known_agc, |
2477 l1a_l1s_com.Scell_used_IL_dd.input_level,Cust_get_agc_from_IL(radio_freq, IL_max >> 1, MAX_ID, l1a_l1s_com.Scell_used_IL_dd.lna_off)); | 2559 l1a_l1s_com.Scell_used_IL_dd.input_level,Cust_get_agc_from_IL(radio_freq, IL_max >> 1, MAX_ID)); |
2478 #endif | 2560 #endif |
2479 #endif | 2561 #endif |
2480 | 2562 |
2481 return((UWORD8)current_calibrated_IL); | 2563 return((UWORD8)current_calibrated_IL); |
2482 } | 2564 } |
2503 WORD16 delta_drp_gain=0; | 2585 WORD16 delta_drp_gain=0; |
2504 UWORD8 i; | 2586 UWORD8 i; |
2505 UWORD8 *tab_ptr; | 2587 UWORD8 *tab_ptr; |
2506 T_DEDIC_SET *aset; | 2588 T_DEDIC_SET *aset; |
2507 WORD32 lna_value; | 2589 WORD32 lna_value; |
2508 UWORD16 arfcn; | 2590 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2591 UWORD16 arfcn; | |
2592 #endif | |
2509 UWORD8 lna_off; | 2593 UWORD8 lna_off; |
2510 UWORD16 dco_algo_ctl_pw_temp = 0; | 2594 UWORD16 dco_algo_ctl_pw_temp = 0; |
2511 UWORD8 if_ctl = 0; | 2595 UWORD8 if_ctl = 0; |
2512 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) | 2596 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2513 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; | 2597 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; |
2514 #endif | 2598 #endif |
2515 | 2599 |
2516 delta1_freq = l1ctl_encode_delta1(radio_freq); | 2600 delta1_freq = l1ctl_encode_delta1(radio_freq); |
2517 delta2_freq = l1ctl_encode_delta2(radio_freq); | 2601 delta2_freq = l1ctl_encode_delta2(radio_freq); |
2518 | 2602 |
2537 } | 2621 } |
2538 else | 2622 else |
2539 #endif | 2623 #endif |
2540 { | 2624 { |
2541 #if DPAGC_MAX_FLAG | 2625 #if DPAGC_MAX_FLAG |
2542 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID,l1a_l1s_com.Scell_used_IL_dd.lna_off)) << 1; | 2626 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID)) << 1; |
2543 // F7.1 in order to be compatible with pm and IL formats | 2627 // F7.1 in order to be compatible with pm and IL formats |
2544 #else | 2628 #else |
2545 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, AV_ID,l1a_l1s_com.Scell_used_IL_dd.lna_off)) << 1; | 2629 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, AV_ID)) << 1; |
2546 // F7.1 in order to be compatible with pm and IL formats | 2630 // F7.1 in order to be compatible with pm and IL formats |
2547 #endif | 2631 #endif |
2548 // input_level_dd : contain the input_level value we use | 2632 // input_level_dd : contain the input_level value we use |
2549 // in the associated CTL task to build the agc used in this CTL. | 2633 // in the associated CTL task to build the agc used in this CTL. |
2550 | 2634 |
2551 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq); | 2635 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq); |
2552 } | 2636 } |
2553 | 2637 |
2554 #if (L1_FF_MULTIBAND == 0) | 2638 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2639 #if (L1_FF_MULTIBAND == 0) | |
2555 arfcn = Convert_l1_radio_freq(radio_freq); | 2640 arfcn = Convert_l1_radio_freq(radio_freq); |
2556 #else | 2641 #else |
2557 arfcn=radio_freq; | 2642 arfcn = radio_freq; |
2558 #endif | 2643 #endif |
2644 #endif | |
2559 | 2645 |
2560 #if(RF_FAM == 61) | 2646 #if(RF_FAM == 61) |
2561 #if (CODE_VERSION != SIMULATION) | 2647 #if (CODE_VERSION != SIMULATION) |
2562 | 2648 |
2563 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID , | 2649 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID , |
2574 | 2660 |
2575 #endif | 2661 #endif |
2576 #endif | 2662 #endif |
2577 | 2663 |
2578 if (0==pm) // Check and filter illegal pm value by using last valid IL | 2664 if (0==pm) // Check and filter illegal pm value by using last valid IL |
2579 new_IL = IL_info_ptr->input_level; | 2665 new_IL = IL_info_ptr->input_level - lna_value; |
2580 else | 2666 else |
2581 new_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); | 2667 new_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); |
2582 | 2668 |
2583 current_calibrated_IL = new_IL - delta1_freq - delta2_freq; | 2669 current_calibrated_IL = new_IL - delta1_freq - delta2_freq; |
2584 | 2670 |
2661 // input_level is always store with lna_on | 2747 // input_level is always store with lna_on |
2662 l1ctl_encode_lna( (UWORD8)(current_calibrated_IL>>1), | 2748 l1ctl_encode_lna( (UWORD8)(current_calibrated_IL>>1), |
2663 &(IL_info_ptr->lna_off), | 2749 &(IL_info_ptr->lna_off), |
2664 radio_freq ); | 2750 radio_freq ); |
2665 | 2751 |
2666 IL_info_ptr->input_level = (UWORD8)new_IL ; | 2752 IL_info_ptr->input_level = (UWORD8)new_IL + l1ctl_get_lna_att(radio_freq) * |
2753 IL_info_ptr->lna_off; | |
2667 | 2754 |
2668 #if L2_L3_SIMUL | 2755 #if L2_L3_SIMUL |
2669 #if (DEBUG_TRACE==BUFFER_TRACE_DPAGC) | 2756 #if (DEBUG_TRACE==BUFFER_TRACE_DPAGC) |
2670 buffer_trace(4,IL_info_ptr->input_level,last_known_agc, | 2757 buffer_trace(4,IL_info_ptr->input_level,last_known_agc, |
2671 l1a_l1s_com.Scell_used_IL_dd.input_level,Cust_get_agc_from_IL(radio_freq, new_IL >> 1, MAX_ID,l1a_l1s_com.Scell_used_IL_dd.lna_off)); | 2758 l1a_l1s_com.Scell_used_IL_dd.input_level,Cust_get_agc_from_IL(radio_freq, new_IL >> 1, MAX_ID)); |
2672 #endif | 2759 #endif |
2673 #endif | 2760 #endif |
2674 | 2761 |
2675 return((UWORD8)current_calibrated_IL); | 2762 return((UWORD8)current_calibrated_IL); |
2676 } | 2763 } |
2694 WORD16 delta_drp_gain=0; | 2781 WORD16 delta_drp_gain=0; |
2695 UWORD8 i; | 2782 UWORD8 i; |
2696 UWORD8 *tab_ptr, *tab_amr_ptr; | 2783 UWORD8 *tab_ptr, *tab_amr_ptr; |
2697 T_DEDIC_SET *aset; | 2784 T_DEDIC_SET *aset; |
2698 WORD32 lna_value; | 2785 WORD32 lna_value; |
2699 UWORD16 arfcn; | 2786 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2787 UWORD16 arfcn; | |
2788 #endif | |
2700 UWORD8 lna_off; | 2789 UWORD8 lna_off; |
2701 UWORD16 dco_algo_ctl_pw_temp = 0; | 2790 UWORD16 dco_algo_ctl_pw_temp = 0; |
2702 UWORD8 if_ctl = 0; | 2791 UWORD8 if_ctl = 0; |
2703 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) | 2792 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2704 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; | 2793 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GSM; |
2732 } | 2821 } |
2733 else | 2822 else |
2734 #endif | 2823 #endif |
2735 { | 2824 { |
2736 #if DPAGC_MAX_FLAG | 2825 #if DPAGC_MAX_FLAG |
2737 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID,l1a_l1s_com.Scell_used_IL_dd.lna_off)) << 1; | 2826 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID)) << 1; |
2738 // F7.1 in order to be compatible with pm and IL formats | 2827 // F7.1 in order to be compatible with pm and IL formats |
2739 #else | 2828 #else |
2740 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, AV_ID,l1a_l1s_com.Scell_used_IL_dd.lna_off)) << 1; | 2829 last_known_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, AV_ID)) << 1; |
2741 // F7.1 in order to be compatible with pm and IL formats | 2830 // F7.1 in order to be compatible with pm and IL formats |
2742 #endif | 2831 #endif |
2743 // input_level_dd : contain the input_level value we use | 2832 // input_level_dd : contain the input_level value we use |
2744 // in the associated CTL task to build the agc used in this CTL. | 2833 // in the associated CTL task to build the agc used in this CTL. |
2745 | 2834 |
2746 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq); | 2835 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq); |
2747 } | 2836 } |
2748 | 2837 |
2749 #if (L1_FF_MULTIBAND == 0) | 2838 #if (RF_RAM == 61) && (CODE_VERSION != SIMULATION) |
2839 #if (L1_FF_MULTIBAND == 0) | |
2750 arfcn = Convert_l1_radio_freq(radio_freq); | 2840 arfcn = Convert_l1_radio_freq(radio_freq); |
2751 #else | 2841 #else |
2752 arfcn=radio_freq; | 2842 arfcn = radio_freq; |
2753 #endif | 2843 #endif |
2844 #endif | |
2754 | 2845 |
2755 #if(RF_FAM == 61) | 2846 #if(RF_FAM == 61) |
2756 #if (CODE_VERSION != SIMULATION) | 2847 #if (CODE_VERSION != SIMULATION) |
2757 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID , | 2848 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID , |
2758 l1a_l1s_com.Scell_used_IL_dd.input_level, | 2849 l1a_l1s_com.Scell_used_IL_dd.input_level, |
2767 } | 2858 } |
2768 #endif | 2859 #endif |
2769 #endif | 2860 #endif |
2770 | 2861 |
2771 if (0==pm) // Check and filter illegal pm value by using last valid IL | 2862 if (0==pm) // Check and filter illegal pm value by using last valid IL |
2772 new_IL = IL_info_ptr->input_level; | 2863 new_IL = IL_info_ptr->input_level - lna_value; |
2773 else | 2864 else |
2774 new_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); | 2865 new_IL = -(pm - (last_known_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq)); |
2775 | 2866 |
2776 current_calibrated_IL = new_IL - delta1_freq - delta2_freq; | 2867 current_calibrated_IL = new_IL - delta1_freq - delta2_freq; |
2777 | 2868 |
2869 // input_level is always store with lna_on | 2960 // input_level is always store with lna_on |
2870 | 2961 |
2871 l1ctl_encode_lna( (UWORD8)(current_calibrated_IL>>1), | 2962 l1ctl_encode_lna( (UWORD8)(current_calibrated_IL>>1), |
2872 &(IL_info_ptr->lna_off), | 2963 &(IL_info_ptr->lna_off), |
2873 radio_freq ); | 2964 radio_freq ); |
2874 IL_info_ptr->input_level = (UWORD8)new_IL ; | 2965 IL_info_ptr->input_level = (UWORD8)new_IL + l1ctl_get_lna_att(radio_freq) * |
2966 IL_info_ptr->lna_off; | |
2875 | 2967 |
2876 #if L2_L3_SIMUL | 2968 #if L2_L3_SIMUL |
2877 #if (DEBUG_TRACE==BUFFER_TRACE_DPAGC) | 2969 #if (DEBUG_TRACE==BUFFER_TRACE_DPAGC) |
2878 buffer_trace(4,IL_info_ptr->input_level,last_known_agc, | 2970 buffer_trace(4,IL_info_ptr->input_level,last_known_agc, |
2879 l1a_l1s_com.Scell_used_IL_dd.input_level,Cust_get_agc_from_IL(radio_freq, new_IL >> 1, MAX_ID,l1a_l1s_com.Scell_used_IL_dd.lna_off)); | 2971 l1a_l1s_com.Scell_used_IL_dd.input_level,Cust_get_agc_from_IL(radio_freq, new_IL >> 1, MAX_ID)); |
2880 #endif | 2972 #endif |
2881 #endif | 2973 #endif |
2882 | 2974 |
2883 return((UWORD8)current_calibrated_IL); | 2975 return((UWORD8)current_calibrated_IL); |
2884 } | 2976 } |
2940 /*-------------------------------------------------------*/ | 3032 /*-------------------------------------------------------*/ |
2941 /* Parameters : */ | 3033 /* Parameters : */ |
2942 /* Return : */ | 3034 /* Return : */ |
2943 /* Functionality : */ | 3035 /* Functionality : */ |
2944 /*-------------------------------------------------------*/ | 3036 /*-------------------------------------------------------*/ |
2945 UWORD16 l1ctl_update_TPU_with_toa(void) | 3037 void l1ctl_update_TPU_with_toa(void) |
2946 { | 3038 { |
2947 #if (TOA_ALGO != 0) | 3039 #if (TOA_ALGO != 0) |
2948 WORD16 toa_shift; | 3040 WORD16 toa_shift; |
2949 | 3041 |
2950 #if (TOA_ALGO == 2) | 3042 #if (TOA_ALGO == 2) |
3004 #else | 3096 #else |
3005 l1s.toa_shift = ISH_INVALID; // Reset the ISH. | 3097 l1s.toa_shift = ISH_INVALID; // Reset the ISH. |
3006 #endif | 3098 #endif |
3007 } | 3099 } |
3008 #endif | 3100 #endif |
3009 return 0; //omaps00090550 | |
3010 } | 3101 } |
3011 | 3102 |
3012 | 3103 |
3013 /*-------------------------------------------------------*/ | 3104 /*-------------------------------------------------------*/ |
3014 /* l1ctl_saic() */ | 3105 /* l1ctl_saic() */ |