|
|
@ -518,28 +518,41 @@ void phy::run_rx_tx_state()
|
|
|
|
log_h->step(current_tti);
|
|
|
|
log_h->step(current_tti);
|
|
|
|
float cfo = srslte_ue_sync_get_cfo(&ue_sync)/15000;
|
|
|
|
float cfo = srslte_ue_sync_get_cfo(&ue_sync)/15000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool tx_zeros = true;
|
|
|
|
|
|
|
|
|
|
|
|
// Prepare transmission for the next tti
|
|
|
|
// Prepare transmission for the next tti
|
|
|
|
srslte_timestamp_add(&last_rx_time, 0, 1e-3);
|
|
|
|
srslte_timestamp_add(&last_rx_time, 0, 1e-3);
|
|
|
|
|
|
|
|
|
|
|
|
// send prach if we have to
|
|
|
|
// Generate scheduling request if we have to
|
|
|
|
|
|
|
|
if (sr_is_ready_to_send(current_tti+ul_buffer::tx_advance_sf)) {
|
|
|
|
|
|
|
|
get_ul_buffer_adv(current_tti)->generate_sr();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Every subframe, TX a PRACH or a PUSCH/PUCCH
|
|
|
|
if (prach_buffer.is_ready_to_send(current_tti)) {
|
|
|
|
if (prach_buffer.is_ready_to_send(current_tti)) {
|
|
|
|
|
|
|
|
// send prach if we have to
|
|
|
|
prach_buffer.send(radio_handler, cfo, last_rx_time);
|
|
|
|
prach_buffer.send(radio_handler, cfo, last_rx_time);
|
|
|
|
radio_handler->set_tx_gain(old_gain);
|
|
|
|
radio_handler->set_tx_gain(old_gain);
|
|
|
|
srslte_agc_lock(&ue_sync.agc, false);
|
|
|
|
srslte_agc_lock(&ue_sync.agc, false);
|
|
|
|
Info("Restoring AGC. Set TX gain to %.1f dB\n", old_gain);
|
|
|
|
Info("Restoring AGC. Set TX gain to %.1f dB\n", old_gain);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate scheduling request if we have to
|
|
|
|
// If we don't transmit PRACH, check if need to transmit PUSCH/PUCCH
|
|
|
|
if (sr_is_ready_to_send(current_tti+ul_buffer::tx_advance_sf)) {
|
|
|
|
} else if (get_ul_buffer_adv(current_tti)->is_released() || get_ul_buffer_adv(current_tti)->uci_ready()) {
|
|
|
|
get_ul_buffer_adv(current_tti)->generate_sr();
|
|
|
|
// If the packet was not generated by a call from MAC, means it's PUCCH. Generate now the signal
|
|
|
|
}
|
|
|
|
|
|
|
|
// send ul buffer if we have to
|
|
|
|
|
|
|
|
if (get_ul_buffer_adv(current_tti)->is_released() || get_ul_buffer_adv(current_tti)->uci_ready()) {
|
|
|
|
|
|
|
|
// Generate PUCCH if no UL grant
|
|
|
|
|
|
|
|
if (!get_ul_buffer_adv(current_tti)->is_released()) {
|
|
|
|
if (!get_ul_buffer_adv(current_tti)->is_released()) {
|
|
|
|
get_ul_buffer_adv(current_tti)->generate_data();
|
|
|
|
get_ul_buffer_adv(current_tti)->generate_data();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// And transmit
|
|
|
|
get_ul_buffer_adv(current_tti)->send(radio_handler, time_adv_sec, cfo, last_rx_time);
|
|
|
|
get_ul_buffer_adv(current_tti)->send(radio_handler, time_adv_sec, cfo, last_rx_time);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Transmit zeros to avoid transitions.
|
|
|
|
|
|
|
|
// FIXME: This keeps the TX RF chain always on. Should transmit zeros only before a true transmission
|
|
|
|
|
|
|
|
get_ul_buffer_adv(current_tti)->send_zeros(radio_handler, time_adv_sec, last_rx_time);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send ul buffer if we have to
|
|
|
|
|
|
|
|
// Generate PUCCH if no UL grant
|
|
|
|
|
|
|
|
|
|
|
|
// Receive alligned buffer for the current tti
|
|
|
|
// Receive alligned buffer for the current tti
|
|
|
|
get_dl_buffer(current_tti)->recv_ue_sync(&ue_sync, &last_rx_time);
|
|
|
|
get_dl_buffer(current_tti)->recv_ue_sync(&ue_sync, &last_rx_time);
|
|
|
|