From 888b9492707707d0502baddb999319db0ac16e40 Mon Sep 17 00:00:00 2001 From: Lukasz Maciejonczyk Date: Tue, 1 Jun 2021 14:36:48 +0200 Subject: [PATCH] drivers: ieee802154: configure IE header injection for nRF5 Pass enh ack data injection arguments to the nRF5 radio driver. Signed-off-by: Lukasz Maciejonczyk --- drivers/ieee802154/ieee802154_nrf5.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 06c5e873cb0cb..e973f2876bd97 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -41,6 +41,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include "ieee802154_nrf5.h" #include "nrf_802154.h" +#include "nrf_802154_const.h" #if defined(CONFIG_NRF_802154_SER_HOST) #include "nrf_802154_serialization_error.h" @@ -686,6 +687,27 @@ static int nrf5_configure(const struct device *dev, case IEEE802154_CONFIG_EVENT_HANDLER: nrf5_data.event_handler = config->event_handler; + case IEEE802154_CONFIG_ENH_ACK_HEADER_IE: { + uint8_t short_addr_le[SHORT_ADDRESS_SIZE]; + uint8_t ext_addr_le[EXTENDED_ADDRESS_SIZE]; + + /* We expect that addresses are in big endian format, but radio driver requires + * to have them in little endian. Convert addresses to little endian. + */ + sys_put_le16(config->ack_ie.short_addr, short_addr_le); + sys_memcpy_swap(ext_addr_le, config->ack_ie.ext_addr, EXTENDED_ADDRESS_SIZE); + + if (config->ack_ie.data_len > 0) { + nrf_802154_ack_data_set(short_addr_le, false, config->ack_ie.data, + config->ack_ie.data_len, NRF_802154_ACK_DATA_IE); + nrf_802154_ack_data_set(ext_addr_le, true, config->ack_ie.data, + config->ack_ie.data_len, NRF_802154_ACK_DATA_IE); + } else { + nrf_802154_ack_data_clear(short_addr_le, false, NRF_802154_ACK_DATA_IE); + nrf_802154_ack_data_clear(ext_addr_le, true, NRF_802154_ACK_DATA_IE); + } + } break; + default: return -EINVAL; }