Moved SR ready_to_send to srsLTE

This commit is contained in:
ismagom 2015-06-05 22:51:29 +02:00
parent 414643174b
commit 41b603e472
6 changed files with 40 additions and 48 deletions

View File

@ -152,10 +152,7 @@ private:
bool do_agc;
double last_gain;
uint32_t sr_N_offset;
uint32_t sr_periodicity;
bool sr_enabled;
uint32_t sr_n_pucch;
bool sr_is_ready_to_send(uint32_t tti);
bool init_(radio *radio_handler, tti_sync *ttisync, log *log_h, bool do_agc);

View File

@ -77,7 +77,6 @@ namespace ue {
PUCCH_N_PUCCH_2,
PUCCH_N_PUCCH_SR,
SR_PUCCH_RESINDEX,
SR_CONFIG_INDEX,
UCI_I_OFFSET_ACK,

View File

@ -153,15 +153,6 @@ bool phy::send_prach(uint32_t preamble_idx, int allowed_subframe, int target_pow
/* Send SR as soon as possible as defined in Section 10.2 of 36.213 */
void phy::send_sr(bool enable)
{
if (enable) {
// Get sr_periodicity and sr_N_offset from table 10.1-5
uint32_t I_sr = params_db.get_param(phy_params::SR_CONFIG_INDEX);
sr_n_pucch = params_db.get_param(phy_params::SR_PUCCH_RESINDEX);
srslte_ue_ul_sr_config(I_sr, &sr_periodicity, &sr_N_offset);
Info("SR I_sr=%d, periodicity=%d, N_offset=%d, n_pucch=%d\n", I_sr, sr_periodicity, sr_N_offset, sr_n_pucch);
sr_tx_tti = get_current_tti();
}
sr_enabled = enable;
}
@ -175,10 +166,12 @@ int phy::sr_last_tx_tti() {
bool phy::sr_is_ready_to_send(uint32_t tti_) {
if (sr_enabled) {
if ((10*tti_to_SFN(tti_)+tti_to_subf(tti_)-sr_N_offset)%sr_periodicity==0) {
// Get I_sr parameter
uint32_t I_sr = params_db.get_param(phy_params::SR_CONFIG_INDEX);
if (srslte_ue_ul_sr_send_tti(I_sr, tti_)) {
sr_enabled = false;
sr_tx_tti = tti_;
Debug("SR ready to send for TTI=%d\n", tti_);
Info("SR ready to send for TTI=%d\n", tti_);
return true;
}
}

View File

@ -151,8 +151,7 @@ SRSLTE_API void srslte_ue_ul_set_rnti(srslte_ue_ul_t *q,
/* Other static functions for UL PHY procedures defined in 36.213 */
SRSLTE_API int srslte_ue_ul_sr_config(uint32_t I_sr,
uint32_t *sr_periodicity,
uint32_t *sr_N_offset);
SRSLTE_API int srslte_ue_ul_sr_send_tti(uint32_t I_sr,
uint32_t current_tti);
#endif

View File

@ -175,7 +175,7 @@ int main(int argc, char **argv) {
if (nframe==9 || nframe==8) {
srslte_timestamp_add(&tstamp, 0, 2e-3);
if (nframe==8) {
//cuhd_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
cuhd_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
printf("Transmitting zeros\n");
} else {
cuhd_send_timed2(uhd, preamble, flen, tstamp.full_secs, tstamp.frac_secs, true, true);

View File

@ -377,37 +377,41 @@ int srslte_ue_ul_pusch_encode_cfg(srslte_ue_ul_t *q, srslte_pusch_cfg_t *cfg,
return ret;
}
/* Obtains Scheduling Request channel assignment as defined in Table 10.1-5, 36.213 */
int srslte_ue_ul_sr_config(uint32_t I_sr, uint32_t *sr_periodicity, uint32_t *sr_N_offset) {
if (sr_periodicity && sr_N_offset) {
if (I_sr < 5) {
*sr_periodicity = 5;
*sr_N_offset = I_sr;
} else if (I_sr < 15) {
*sr_periodicity = 10;
*sr_N_offset = I_sr-5;
} else if (I_sr < 35) {
*sr_periodicity = 20;
*sr_N_offset = I_sr-15;
} else if (I_sr < 75) {
*sr_periodicity = 40;
*sr_N_offset = I_sr-35;
} else if (I_sr < 155) {
*sr_periodicity = 80;
*sr_N_offset = I_sr-75;
} else if (I_sr < 157) {
*sr_periodicity = 2;
*sr_N_offset = I_sr-155;
} else if (I_sr == 157) {
*sr_periodicity = 1;
*sr_N_offset = I_sr-157;
} else {
return SRSLTE_ERROR;
}
/* Returns 1 if a SR needs to be sent at current_tti given I_sr, as defined in Section 10.1 of 36.213 */
int srslte_ue_ul_sr_send_tti(uint32_t I_sr, uint32_t current_tti) {
uint32_t sr_periodicity;
uint32_t sr_N_offset;
if (I_sr < 5) {
sr_periodicity = 5;
sr_N_offset = I_sr;
} else if (I_sr < 15) {
sr_periodicity = 10;
sr_N_offset = I_sr-5;
} else if (I_sr < 35) {
sr_periodicity = 20;
sr_N_offset = I_sr-15;
} else if (I_sr < 75) {
sr_periodicity = 40;
sr_N_offset = I_sr-35;
} else if (I_sr < 155) {
sr_periodicity = 80;
sr_N_offset = I_sr-75;
} else if (I_sr < 157) {
sr_periodicity = 2;
sr_N_offset = I_sr-155;
} else if (I_sr == 157) {
sr_periodicity = 1;
sr_N_offset = I_sr-157;
} else {
return SRSLTE_ERROR_INVALID_INPUTS;
return SRSLTE_ERROR;
}
uint32_t sfn = current_tti/10;
uint32_t subf = current_tti%10;
if ((10*sfn+subf-sr_N_offset)%sr_periodicity==0) {
return 1;
} else {
return SRSLTE_SUCCESS;
}
return SRSLTE_SUCCESS;
}