From b6c2a2b06e6c64421d642ac658fea87937ba83bd Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Mon, 30 Jul 2018 10:45:24 -0500 Subject: [PATCH] [kw41z] load bytes into TX Packet Buffer in order (#2882) The MKW41Z Reference Manual Section 44.6.2.7 states: - "The 802.15.4 Link Layer software prepares data to be transmitted, by loading the octets, in order, into the Packet Buffer." This commit maintains a separate buffer for building the transmit frame then copies the buffer just before the transmit frame is submitted to the radio. --- examples/platforms/kw41z/radio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/platforms/kw41z/radio.c b/examples/platforms/kw41z/radio.c index 1edd21836..c26dff9ca 100644 --- a/examples/platforms/kw41z/radio.c +++ b/examples/platforms/kw41z/radio.c @@ -101,6 +101,7 @@ static otError sTxStatus; static otRadioFrame sTxFrame; static otRadioFrame sRxFrame; +static uint8_t sTxData[OT_RADIO_FRAME_MAX_SIZE]; #if DOUBLE_BUFFERING static uint8_t sRxData[OT_RADIO_FRAME_MAX_SIZE]; #endif @@ -357,6 +358,14 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) *(uint8_t *)ZLL->PKT_BUFFER_TX = aFrame->mLength; + /* MKW41Z Reference Manual Section 44.6.2.7 states: "The 802.15.4 + * Link Layer software prepares data to be transmitted, by loading + * the octets, in order, into the Packet Buffer." */ + for (int i = 0; i < aFrame->mLength - sizeof(uint16_t); i++) + { + ((uint8_t *)ZLL->PKT_BUFFER_TX)[1 + i] = sTxFrame.mPsdu[i]; + } + /* Set CCA mode */ ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_CCATYPE_MASK; ZLL->PHY_CTRL |= ZLL_PHY_CTRL_CCATYPE(DEFAULT_CCA_MODE); @@ -929,7 +938,7 @@ void kw41zRadioInit(void) rf_set_tx_power(0); sTxFrame.mLength = 0; - sTxFrame.mPsdu = (uint8_t *)ZLL->PKT_BUFFER_TX + 1; + sTxFrame.mPsdu = sTxData; sRxFrame.mLength = 0; #if DOUBLE_BUFFERING sRxFrame.mPsdu = sRxData;