From 4a77791cf5f7cedc842762be8b2b6775073d8c95 Mon Sep 17 00:00:00 2001 From: michael-west Date: Fri, 7 Apr 2023 10:37:42 -0700 Subject: [PATCH] b200: Fix invalid RF switch positions In some situations, the RF switches on the frontend would be placed in undefined states. This does not cause physical harm, but could distort signals or introduce noise. This fix ensures the RF switches are always in a defined state. Signed-off-by: michael-west --- host/lib/usrp/b200/b200_impl.cpp | 16 ++++++++-------- host/lib/usrp/b200/b200_regs.hpp | 8 +++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 6de161e87..03cc33102 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -1400,9 +1400,9 @@ void b200_impl::update_atrs(void) const bool enb_tx = bool(perif.tx_streamer.lock()); const bool is_rx2 = perif.ant_rx2; const uint32_t rxonly = (enb_rx) ? ((is_rx2) ? STATE_RX1_RX2 : STATE_RX1_TXRX) - : STATE_OFF; - const uint32_t txonly = (enb_tx) ? (STATE_TX1_TXRX) : STATE_OFF; - uint32_t fd = STATE_OFF; + : STATE_RX1_OFF; + const uint32_t txonly = (enb_tx) ? (STATE_TX1_TXRX) : STATE_RX1_OFF; + uint32_t fd = STATE_RX1_OFF; if (enb_rx and enb_tx) fd = STATE_FDX1_TXRX; if (enb_rx and not enb_tx) @@ -1410,7 +1410,7 @@ void b200_impl::update_atrs(void) if (not enb_rx and enb_tx) fd = txonly; gpio_atr_3000::sptr atr = perif.atr; - atr->set_atr_reg(ATR_REG_IDLE, STATE_OFF); + atr->set_atr_reg(ATR_REG_IDLE, STATE_RX1_OFF); atr->set_atr_reg(ATR_REG_RX_ONLY, rxonly); atr->set_atr_reg(ATR_REG_TX_ONLY, txonly); atr->set_atr_reg(ATR_REG_FULL_DUPLEX, fd); @@ -1421,9 +1421,9 @@ void b200_impl::update_atrs(void) const bool enb_tx = bool(perif.tx_streamer.lock()); const bool is_rx2 = perif.ant_rx2; const uint32_t rxonly = (enb_rx) ? ((is_rx2) ? STATE_RX2_RX2 : STATE_RX2_TXRX) - : STATE_OFF; - const uint32_t txonly = (enb_tx) ? (STATE_TX2_TXRX) : STATE_OFF; - uint32_t fd = STATE_OFF; + : STATE_RX2_OFF; + const uint32_t txonly = (enb_tx) ? (STATE_TX2_TXRX) : STATE_RX2_OFF; + uint32_t fd = STATE_RX2_OFF; if (enb_rx and enb_tx) fd = STATE_FDX2_TXRX; if (enb_rx and not enb_tx) @@ -1431,7 +1431,7 @@ void b200_impl::update_atrs(void) if (not enb_rx and enb_tx) fd = txonly; gpio_atr_3000::sptr atr = perif.atr; - atr->set_atr_reg(ATR_REG_IDLE, STATE_OFF); + atr->set_atr_reg(ATR_REG_IDLE, STATE_RX2_OFF); atr->set_atr_reg(ATR_REG_RX_ONLY, rxonly); atr->set_atr_reg(ATR_REG_TX_ONLY, txonly); atr->set_atr_reg(ATR_REG_FULL_DUPLEX, fd); diff --git a/host/lib/usrp/b200/b200_regs.hpp b/host/lib/usrp/b200/b200_regs.hpp index 4554eb52c..127f15b17 100644 --- a/host/lib/usrp/b200/b200_regs.hpp +++ b/host/lib/usrp/b200/b200_regs.hpp @@ -73,10 +73,10 @@ static const uint32_t LED_TXRX_TX2 = (1 << 0); /* ATR State Definitions. */ -static const uint32_t STATE_OFF = 0x00; - ///////////////////////// side 1 /////////////////////////////////// -static const uint32_t STATE_RX1_RX2 = (SFDX1_RX | SFDX1_TX | LED_RX1); +static const uint32_t STATE_RX1_OFF = (SFDX1_RX | SRX1_TX); + +static const uint32_t STATE_RX1_RX2 = (SFDX1_RX | SRX1_TX | LED_RX1); static const uint32_t STATE_RX1_TXRX = (SRX1_RX | SRX1_TX | LED_TXRX_RX1); @@ -86,6 +86,8 @@ static const uint32_t STATE_FDX1_TXRX = static const uint32_t STATE_TX1_TXRX = (TX_ENABLE1 | SFDX1_RX | SFDX1_TX | LED_TXRX_TX1); ///////////////////////// side 2 /////////////////////////////////// +static const uint32_t STATE_RX2_OFF = (SFDX2_RX | SRX2_TX); + static const uint32_t STATE_RX2_RX2 = (SFDX2_RX | SRX2_TX | LED_RX2); static const uint32_t STATE_RX2_TXRX = (SRX2_TX | SRX2_RX | LED_TXRX_RX2);