From 7ac94f674de0e91e53fe39c462698e9fa79f9734 Mon Sep 17 00:00:00 2001 From: tfrazel <39776922+tfrazel@users.noreply.github.com> Date: Mon, 4 Jun 2018 11:29:42 -0500 Subject: [PATCH] [kw41z] radio driver fix to allow channel change (#2757) The NXP KW41Z radio driver prohibited changing channels while in receive mode; this prevented the leader properly responding to MLE Announces from orphaned child devices. --- examples/platforms/kw41z/radio.c | 33 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/platforms/kw41z/radio.c b/examples/platforms/kw41z/radio.c index 1a9006dce..c503fb3e2 100644 --- a/examples/platforms/kw41z/radio.c +++ b/examples/platforms/kw41z/radio.c @@ -234,24 +234,25 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) sState = OT_RADIO_STATE_RECEIVE; - otEXPECT(rf_get_state() != XCVR_RX_c); + /* Check if the channel needs to be changed */ + if ((sChannel != aChannel) || (rf_get_state() != XCVR_RX_c)) + { + rf_abort(); + /* Set Power level for auto TX */ + rf_set_tx_power(sAutoTxPwrLevel); + rf_set_channel(aChannel); + sRxFrame.mChannel = aChannel; - rf_abort(); + /* Filter ACK frames during RX sequence */ + ZLL->RX_FRAME_FILTER &= ~(ZLL_RX_FRAME_FILTER_ACK_FT_MASK); + /* Clear all IRQ flags */ + ZLL->IRQSTS = ZLL->IRQSTS; + /* Start the RX sequence */ + ZLL->PHY_CTRL |= XCVR_RX_c; - /* Set Power level for auto TX */ - rf_set_tx_power(sAutoTxPwrLevel); - rf_set_channel(aChannel); - sRxFrame.mChannel = aChannel; - - /* Filter ACK frames during RX sequence */ - ZLL->RX_FRAME_FILTER &= ~(ZLL_RX_FRAME_FILTER_ACK_FT_MASK); - /* Clear all IRQ flags */ - ZLL->IRQSTS = ZLL->IRQSTS; - /* Start the RX sequence */ - ZLL->PHY_CTRL |= XCVR_RX_c; - - /* Unmask SEQ interrupt */ - ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_SEQMSK_MASK; + /* Unmask SEQ interrupt */ + ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_SEQMSK_MASK; + } exit: return status;