printf("Error in number of subcarrier in channel estimation\n");
break;
}
if (subcarrier_spacing){
pilot_pos_format2 = pilot_pos_format2_15k;
pilot_pos1 = pilot_pos1_15k;
pilot_pos2 = pilot_pos2_15k;
}else{
pilot_pos_format2 = pilot_pos_format2_3_75k;
pilot_pos1 = pilot_pos1_3_75k;
pilot_pos2 = pilot_pos2_3_75k;
}
ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
//u=frame_parms->npusch_config_common.ul_ReferenceSignalsNPUSCH.grouphop[n_s][index_Nsc_RU]; // Vincent: may be adapted for Nsc_RU, see 36.211, Section 10.1.4.1.3
if (index_Nsc_RU){ // NB-IoT: a shift ul_sc_start is added in order to get the same position of the first pilot in rxdataF_ext and ul_ref_sigs_rx_NB_IoT
pilot_sig = &ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][24-(ul_sc_start<<1)]; // pilot values are the same every slots
}else{
pilot_sig = &ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][24 + 2*12*(n_s)-(ul_sc_start<<1)]; // pilot values depends on the slots
}
for (k=0;k<12;k++){
// Multiplication by the complex conjugate of the pilot
// ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
// u=frame_parms->npusch_config_common.ul_ReferenceSignalsNPUSCH.grouphop[Ns+(subframe<<1)][index_Nsc_RU]; // Vincent: may be adapted for Nsc_RU, see 36.211, Section 10.1.4.1.3
// // // because the ifft is not power preserving, we should apply the factor sqrt(power_correction) here, but we rather apply power_correction here and nothing after the next fft
if (coarse){ // coarse = 1: first estimation at 240 kHz
length_seq_NPRACH = (length_CP_0+5*8192)/128;
length_CP = length_CP_0/128;
length_symbol = 64;
offset_start = 0;
length_correl_window = 80; //20512/sub_sampling_rate; // corresponds to the max TA, i.e. 667.66 micro s //FRAME_LENGTH_COMPLEX_SUB_SAMPLES - 4*length_seq_NPRACH+1;
fs_sub_sampled = (uint32_t)fs/128;
}else{
length_seq_NPRACH = (length_CP_0+5*8192)/16;
length_CP = length_CP_0/16;
length_symbol = 8192/16;
offset_estimation = 8 * estimated_TA_coarse;
base_length = 32;
// we arbitrarily define the length of correl window as base_length samples.
// Check if offset_estimation is close to zero or 1282 (max lentgh of delays)
for (n=0;n<length_correl_window;n++){ // loops over samples %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for (k=0;k<4*length_seq_NPRACH;k++){ ///// creation of two variables for tab indexes /// replace "2*(float)M_PI*estimated_CFO*k/fs_sub_sampled" and "2*(n+offset_start+k)"
// sub-optimal ML TA estimation /============================================================/
for (k=0;k<4;k++){ // loop over the 4 sequences of a preamble
pow_n1 = 1;
for (o=0;o<5;o++){ // loop over the symbols of a sequence
for (m=0;m<length_symbol;m++){
// mon_variable=k*length_seq_NPRACH + o*length_symbol + length_CP + m ///////////////////////////////////////////////////////////////////////////////////////////////
sub_sequence_reference_re[k][m] = sub_sequence_reference_re[k][m] + pow_n1 * signal_CFO_compensed_re[k*length_seq_NPRACH + o*length_symbol + length_CP + m] / 5; // average over the 5 symbols of a group
sub_sequence_reference_im[k][m] = sub_sequence_reference_im[k][m] + pow_n1 * signal_CFO_compensed_im [k*length_seq_NPRACH + o*length_symbol + length_CP + m]/ 5; // average over the 5 symbols of a group
}
pow_n1 = -pow_n1;
}
}
pow_n1 = 1;
for (k=0;k<4;k++){ // loop over the 4 sequences of a preamble
pow_n1 = 1;
for (o=0;o<5;o++){ // loop over the symbols of a sequence // mon_variable=k*length_seq_NPRACH+o*length_symbol +length_CP +m///////////////////////////////////////////////
int16_t*sub_sampling_NB_IoT(int16_t*input_buffer,uint32_tlength_input,uint32_t*length_ouput,uint16_tsub_sampling_rate){// void function ////// adding flag for switching between output_buffers
eNB->UL_INFO.nrach_ind.number_of_initial_scs_detected=1;//!!!!!!!!!!!!! // should be set to zero in every call of UL_indication !!!!!!!!!!!!!!!!!!!!!!!