From 9948d97230b53f50130df95161a0b9cd4fe9f085 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 12 Jan 2023 10:53:19 +0100 Subject: [PATCH] Use GPIO flag and fix bug --- executables/nr-ru.c | 8 ++++---- radio/COMMON/common_lib.h | 8 +++++++- radio/USRP/USERSPACE/LIB/usrp_lib.cpp | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 6610a96151..9cddebf6bd 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -733,8 +733,8 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { T_INT(0), T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot,fp,0)], fp->samples_per_subframe * 4)); int sf_extension = 0; int siglen=fp->get_samples_per_slot(slot,fp); - int flags=0,flags_gpio=0; radio_tx_burst_flag_t flags_burst = TX_BURST_INVALID; + radio_tx_gpio_flag_t flags_gpio = 0; if (cfg->cell_config.frame_duplex_type.value == TDD && !get_softmodem_params()->continuous_tx) { int slot_type = nr_slot_select(cfg,frame,slot%fp->slots_per_frame); @@ -796,11 +796,11 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { if (slot==30 || slot==70) beam=3|8; */ - flags_gpio = beam & 0x1000; //enable change of gpio + flags_gpio = beam | TX_GPIO_CHANGE; //enable change of gpio } - flags = flags_burst | flags_gpio<<4; - + const int flags = flags_burst | flags_gpio << 4; + if (proc->first_tx == 1) proc->first_tx = 0; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS, flags ); diff --git a/radio/COMMON/common_lib.h b/radio/COMMON/common_lib.h index efb77fdf91..9492e036b7 100644 --- a/radio/COMMON/common_lib.h +++ b/radio/COMMON/common_lib.h @@ -160,6 +160,12 @@ typedef enum { TX_BURST_END_NO_TIME_SPEC = 10, } radio_tx_burst_flag_t; +/*! \brief Radio TX GPIO flags: MSB to enable sending GPIO command, 12 LSB carry GPIO values */ +typedef enum { + /* first 12 bits reserved for beams */ + TX_GPIO_CHANGE = 0x1000, +} radio_tx_gpio_flag_t; + /*! \brief Structure used for initializing UDP read threads */ typedef struct { openair0_device *device; @@ -317,7 +323,7 @@ typedef struct { int cc; signed char first_packet; signed char last_packet; - int flags_gpio; + radio_tx_gpio_flag_t flags_gpio; } openair0_write_package_t; typedef struct { diff --git a/radio/USRP/USERSPACE/LIB/usrp_lib.cpp b/radio/USRP/USERSPACE/LIB/usrp_lib.cpp index 1800c866ce..12a07ad20e 100644 --- a/radio/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/radio/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -390,7 +390,7 @@ static int trx_usrp_write(openair0_device *device, int nsamps2; // aligned to upper 32 or 16 byte boundary radio_tx_burst_flag_t flags_burst = (radio_tx_burst_flag_t) (flags & 0xf); - int flags_gpio = (flags>>4)&0x1fff; //MSB to enable sending GPIO command, 12 LSB carry GPIO values + radio_tx_gpio_flag_t flags_gpio = (radio_tx_gpio_flag_t) ((flags >> 4) & 0x1fff); int end; openair0_thread_t *write_thread = &device->write_thread; @@ -466,7 +466,7 @@ static int trx_usrp_write(openair0_device *device, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHING_GPIO,1); // bit 13 enables gpio - if (flags_gpio&0x1000) { + if ((flags_gpio & TX_GPIO_CHANGE) != 0) { // push GPIO bits s->usrp->set_command_time(s->tx_md.time_spec); s->usrp->set_gpio_attr(s->gpio_bank, "OUT", flags_gpio, MAN_MASK);