drivers: ieee802154: Add support for IEEE 802.15.4 for nRF5340

This commit introduces support for IEEE 802.15.4 on nRF5340.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
This commit is contained in:
Jedrzej Ciupis 2020-11-13 16:39:45 +01:00 committed by Carles Cufí
commit 15fdd7175b
9 changed files with 129 additions and 12 deletions

View file

@ -42,7 +42,7 @@ config BOARD_ENABLE_CPUNET
the board, the application needs to take into consideration, that the
secure firmware image must already have configured GPIO allocation for the
Network MCU.
default y if (BT || NET_L2_IEEE802154)
default y if (BT || NRF_802154_SER_HOST)
config DOMAIN_CPUNET_BOARD
string

View file

@ -5,8 +5,9 @@
menuconfig IEEE802154_NRF5
bool "nRF52 series IEEE 802.15.4 Driver"
depends on NETWORKING && HAS_HW_NRF_RADIO_IEEE802154
select NRF_802154_RADIO_DRIVER
depends on NETWORKING
select NRF_802154_RADIO_DRIVER if HAS_HW_NRF_RADIO_IEEE802154
select NRF_802154_SER_HOST if !HAS_HW_NRF_RADIO_IEEE802154
if IEEE802154_NRF5

View file

@ -42,6 +42,10 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include "ieee802154_nrf5.h"
#include "nrf_802154.h"
#ifdef CONFIG_NRF_802154_SER_HOST
#include "nrf_802154_serialization_error.h"
#endif
struct nrf5_802154_config {
void (*irq_config_func)(const struct device *dev);
};
@ -53,6 +57,12 @@ static struct nrf5_802154_data nrf5_data;
#define FRAME_PENDING_BYTE 1
#define FRAME_PENDING_BIT (1 << 4)
#if defined(CONFIG_SOC_NRF5340_CPUAPP) || defined(CONFIG_SOC_NRF5340_CPUNET)
#define EUI64_ADDR (NRF_FICR->INFO.DEVICEID)
#else
#define EUI64_ADDR (NRF_FICR->DEVICEID)
#endif
/* Convenience defines for RADIO */
#define NRF5_802154_DATA(dev) \
((struct nrf5_802154_data * const)(dev)->data)
@ -77,8 +87,8 @@ static void nrf5_get_eui64(uint8_t *mac)
mac[index++] = IEEE802154_NRF5_VENDOR_OUI & 0xff;
/* Use device identifier assigned during the production. */
factoryAddress = (uint64_t)NRF_FICR->DEVICEID[0] << 32;
factoryAddress |= NRF_FICR->DEVICEID[1];
factoryAddress = (uint64_t)EUI64_ADDR[0] << 32;
factoryAddress |= EUI64_ADDR[1];
memcpy(mac + index, &factoryAddress, sizeof(factoryAddress) - index);
}
@ -175,7 +185,8 @@ static enum ieee802154_hw_caps nrf5_get_capabilities(const struct device *dev)
{
return IEEE802154_HW_FCS |
IEEE802154_HW_FILTER |
#if !defined(CONFIG_NRF_802154_SL_OPENSOURCE)
#if !defined(CONFIG_NRF_802154_SL_OPENSOURCE) && \
!defined(CONFIG_NRF_802154_SER_HOST)
IEEE802154_HW_CSMA |
#endif
IEEE802154_HW_2_4_GHZ |
@ -733,6 +744,13 @@ void nrf_802154_energy_detection_failed(nrf_802154_ed_error_t error)
}
}
#ifdef CONFIG_NRF_802154_SER_HOST
void nrf_802154_serialization_error(const nrf_802154_ser_err_data_t *p_err)
{
__ASSERT(false, "802.15.4 serialization error");
}
#endif
static const struct nrf5_802154_config nrf5_radio_cfg = {
.irq_config_func = nrf5_irq_config,
};

View file

@ -8,8 +8,6 @@
#ifndef ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_
#define ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_
#include "nrf_802154_config.h"
#define NRF5_FCS_LENGTH (2)
#define NRF5_PSDU_LENGTH (125)
#define NRF5_PHR_LENGTH (1)
@ -42,7 +40,7 @@ struct nrf5_802154_data {
/* Buffers for passing received frame pointers and data to the
* RX thread via rx_fifo object.
*/
struct nrf5_802154_rx_frame rx_frames[NRF_802154_RX_BUFFERS];
struct nrf5_802154_rx_frame rx_frames[CONFIG_NRF_802154_RX_BUFFERS];
/* Frame pending bit value in ACK sent for the last received frame. */
bool last_frame_ack_fpb;

View file

@ -3,7 +3,6 @@
config HAS_NORDIC_DRIVERS
bool
default y if HAS_HW_NRF_RADIO_IEEE802154
menu "Nordic drivers"
depends on HAS_NORDIC_DRIVERS
@ -94,11 +93,94 @@ config NRF_802154_RX_BUFFERS
int "nRF 802.15.4 receive buffers"
default 16
help
Number of buffers in nRF 802.15.4 driver receive queue.
Number of buffers in nRF 802.15.4 driver receive queue. If this value is modified,
its serialization host counterpart must be set to the exact same value.
endif # NRF_802154_RADIO_DRIVER
endmenu
config NRF_802154_SER_HOST
bool "nRF IEEE 802.15.4 Driver serialization host"
depends on !NRF_802154_RADIO_DRIVER
depends on !HAS_HW_NRF_RADIO_IEEE802154
select IPM
select IPM_NRFX
select IPM_MSG_CH_0_ENABLE
select IPM_MSG_CH_1_ENABLE
select IPM_MSG_CH_0_TX
select IPM_MSG_CH_1_RX
select OPENAMP
select IEEE802154_NRF5_EXT_IRQ_MGMT
help
Enable serialization of nRF IEEE 802.15.4 Driver. This option is to be
used if radio is not available in the core, but radio services are
provided by a serialization backend.
menuconfig NRF_802154_SER_RADIO
bool "nRF IEEE 802.15.4 Driver serialization radio"
depends on HAS_HW_NRF_RADIO_IEEE802154
depends on !IEEE802154_NRF5
select IPM
select IPM_NRFX
select IPM_MSG_CH_0_ENABLE
select IPM_MSG_CH_1_ENABLE
select IPM_MSG_CH_0_RX
select IPM_MSG_CH_1_TX
select OPENAMP
select NRF_802154_RADIO_DRIVER
help
Enable serialization of nRF IEEE 802.15.4 Driver. This option is to be
used if radio is available in the core to provide radio services over
a serialization backend.
if NRF_802154_SER_RADIO
config NRF_802154_SER_RADIO_INIT_PRIO
int "nRF52 IEEE 802.15.4 serialization initialization priority"
default 81
help
Set the initialization priority number. Do not mess with it unless
you know what you are doing.
endif
menu "nRF 802.15.4 serialization"
depends on NRF_802154_SER_HOST || NRF_802154_SER_RADIO
config NRF_802154_SER_LOG
bool "802.15.4 serialization logs"
default n
help
This option enable debug logs of 802.15.4 serialization module.
config NRF_802154_SER_BUFFER_ALLOCATOR_THREAD_SAFE
bool
# Hidden option
default y
help
This option specifies if buffers for 802.15.4 serialization are allocated
in a thread-safe manner.
config NRF_802154_SER_DEFAULT_RESPONSE_TIMEOUT
int "Default Spinel serialization response timeout in milliseconds"
default 500
help
This option specifies default timeout of spinel status response
in milliseconds.
if NRF_802154_SER_HOST
config NRF_802154_RX_BUFFERS
int "nRF 802.15.4 receive buffers"
default 16
help
Number of buffers in nRF 802.15.4 driver serialization host's receive queue.
If this value is modified, its remote counterpart must be set to the exact same value.
endif
endmenu # NRF_802154_SER_HOST || NRF_802154_SER_RADIO
endmenu # HAS_NORDIC_DRIVERS
config HAS_NRFX
bool

View file

@ -13,6 +13,7 @@ config SOC_SERIES_NRF52X
select HAS_SYS_POWER_STATE_DEEP_SLEEP_1
select XIP
select HAS_NRFX
select HAS_NORDIC_DRIVERS
select HAS_SEGGER_RTT
help
Enable support for NRF52 MCU series

View file

@ -24,4 +24,13 @@ config NRF5340_CPUAPP_ERRATUM19
locked with the SPU.
More info: https://infocenter.nordicsemi.com/topic/errata_nRF5340_EngA/ERR/nRF5340/EngineeringA/latest/anomaly_340_19.html?cp=3_0_1_0_1_15
config IEEE802154_NRF5
default IEEE802154
config NET_CONFIG_IEEE802154_DEV_NAME
default IEEE802154_NRF5_DRV_NAME
config HEAP_MEM_POOL_SIZE
default 4096 if NRF_802154_SER_HOST
endif # SOC_NRF5340_CPUAPP_QKAA

View file

@ -11,4 +11,11 @@ config SOC
config NUM_IRQS
default 30
config IEEE802154_NRF5
default y
depends on IEEE802154
config HEAP_MEM_POOL_SIZE
default 4096 if NRF_802154_SER_RADIO
endif # SOC_NRF5340_CPUNET_QKAA

View file

@ -12,6 +12,7 @@ config SOC_SERIES_NRF53X
select SOC_FAMILY_NRF
select XIP
select HAS_NRFX
select HAS_NORDIC_DRIVERS
select HAS_SEGGER_RTT
help
Enable support for NRF53 MCU series