forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules: hal_nordic: move nRF 802.15.4 Radio Driver glue to Zephyr
This commit moves all hal_nordic radio driver code that is strictly dependent on Zephyr into the Zephyr repository. Signed-off-by: Rafał Kuźnia <[email protected]>
- Loading branch information
1 parent
19e5a9c
commit dbd66c8
Showing
18 changed files
with
1,075 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
if(CONFIG_HAS_NORDIC_DRIVERS OR CONFIG_HAS_NRFX) | ||
zephyr_library() | ||
endif() | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if(CONFIG_HAS_NORDIC_DRIVERS) | ||
add_subdirectory(${ZEPHYR_CURRENT_MODULE_DIR}/drivers drivers) | ||
endif() | ||
if(CONFIG_NRF_802154_RADIO_DRIVER OR CONFIG_NRF_802154_SERIALIZATION) | ||
add_subdirectory(nrf_802154) | ||
endif () | ||
|
||
if(CONFIG_HAS_NRFX) | ||
add_subdirectory(nrfx) | ||
endif() | ||
add_subdirectory_ifdef(CONFIG_HAS_NRFX nrfx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_subdirectory_ifdef(CONFIG_NRF_802154_RADIO_DRIVER sl_opensource) | ||
add_subdirectory_ifdef(CONFIG_NRF_802154_RADIO_DRIVER radio) | ||
add_subdirectory_ifdef(CONFIG_NRF_802154_SERIALIZATION serialization) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set(NRF_802154_DRIVER_ROOT ${ZEPHYR_CURRENT_MODULE_DIR}/drivers/nrf_radio_802154) | ||
|
||
include(${NRF_802154_DRIVER_ROOT}/nrf_802154_driver_sources.cmake) | ||
|
||
zephyr_library() | ||
|
||
zephyr_include_directories(${NRF_802154_DRIVER_INCLUDE_DIRS}) | ||
|
||
if (CONFIG_SOC_SERIES_NRF52X) | ||
zephyr_library_sources( | ||
${NRF_802154_DRIVER_SOURCES_NRF52} | ||
) | ||
elseif (CONFIG_SOC_SERIES_NRF53X) | ||
zephyr_library_sources( | ||
${NRF_802154_DRIVER_SOURCES_NRF53} | ||
) | ||
else() | ||
message(FATAL_ERROR "SoC unsupported by this module") | ||
endif() | ||
|
||
if (CONFIG_NRF_802154_SL_OPENSOURCE) | ||
zephyr_library_sources( | ||
${NRF_802154_DRIVER_SOURCES_DIRECT} | ||
) | ||
|
||
else() | ||
zephyr_library_sources( | ||
${NRF_802154_DRIVER_SOURCES_SWI} | ||
) | ||
|
||
endif() | ||
|
||
zephyr_library_sources(${CMAKE_CURRENT_SOURCE_DIR}/platform/nrf_802154_random_zephyr.c) | ||
|
||
if( CONFIG_NRF_802154_CCA_MODE_ED) | ||
set(radio_cca_mode NRF_RADIO_CCA_MODE_ED) | ||
|
||
elseif( CONFIG_NRF_802154_CCA_MODE_CARRIER) | ||
set(radio_cca_mode NRF_RADIO_CCA_MODE_CARRIER) | ||
|
||
elseif( CONFIG_NRF_802154_CCA_MODE_CARRIER_AND_ED) | ||
set(radio_cca_mode NRF_RADIO_CCA_MODE_CARRIER_AND_ED) | ||
|
||
elseif( CONFIG_NRF_802154_CCA_MODE_CARRIER_OR_ED) | ||
set(radio_cca_mode NRF_RADIO_CCA_MODE_CARRIER_OR_ED) | ||
|
||
endif() | ||
|
||
zephyr_compile_definitions( | ||
# Radio driver shim layer uses raw api | ||
NRF_802154_USE_RAW_API=1 | ||
|
||
# Number of slots containing short addresses of nodes for which | ||
# pending data is stored. | ||
NRF_802154_PENDING_SHORT_ADDRESSES=${CONFIG_NRF_802154_PENDING_SHORT_ADDRESSES} | ||
|
||
# Number of slots containing extended addresses of nodes for which | ||
# pending data is stored. | ||
NRF_802154_PENDING_EXTENDED_ADDRESSES=${CONFIG_NRF_802154_PENDING_EXTENDED_ADDRESSES} | ||
|
||
# Number of buffers in receive queue. | ||
NRF_802154_RX_BUFFERS=${CONFIG_NRF_802154_RX_BUFFERS} | ||
|
||
# CCA mode | ||
NRF_802154_CCA_MODE_DEFAULT=${radio_cca_mode} | ||
|
||
# CCA mode options | ||
NRF_802154_CCA_CORR_LIMIT_DEFAULT=${CONFIG_NRF_802154_CCA_CORR_LIMIT} | ||
NRF_802154_CCA_CORR_THRESHOLD_DEFAULT=${CONFIG_NRF_802154_CCA_CORR_THRESHOLD} | ||
NRF_802154_CCA_ED_THRESHOLD_DEFAULT=${CONFIG_NRF_802154_CCA_ED_THRESHOLD} | ||
|
||
# Enable CSMA/CA | ||
NRF_802154_CSMA_CA_ENABLED=1 | ||
NRF_802154_TX_STARTED_NOTIFY_ENABLED=1 | ||
|
||
# ACK timeout | ||
NRF_802154_ACK_TIMEOUT_ENABLED=1 | ||
) | ||
|
||
if (CONFIG_IEEE802154_NRF5 OR NOT CONFIG_NRF_802154_SL_OPENSOURCE) | ||
zephyr_compile_definitions( | ||
NRF_802154_INTERNAL_RADIO_IRQ_HANDLING=0 | ||
) | ||
else() | ||
zephyr_compile_definitions( | ||
NRF_802154_INTERNAL_RADIO_IRQ_HANDLING=1 | ||
) | ||
endif() | ||
|
||
if (CONFIG_NRF_802154_SL_OPENSOURCE OR CONFIG_SOC_SERIES_NRF53X) | ||
zephyr_compile_definitions( | ||
# Disable Frame Timestamps | ||
NRF_802154_FRAME_TIMESTAMP_ENABLED=0 | ||
# Disable DTRX | ||
NRF_802154_DELAYED_TRX_ENABLED=0 | ||
# Disable IFS | ||
NRF_802154_IFS_ENABLED=0 | ||
) | ||
|
||
else() | ||
zephyr_compile_definitions( | ||
# Enable Frame Timestamps | ||
NRF_802154_FRAME_TIMESTAMP_ENABLED=1 | ||
# Enable DTRX | ||
NRF_802154_DELAYED_TRX_ENABLED=1 | ||
# Enable IFS | ||
NRF_802154_IFS_ENABLED=1 | ||
) | ||
endif() | ||
|
||
if (NOT CONFIG_NRF_802154_SL_OPENSOURCE) | ||
zephyr_compile_definitions( | ||
NRF_802154_VERIFY_PERIPHS_ALLOC_AGAINST_MPSL=1 | ||
) | ||
endif() |
43 changes: 43 additions & 0 deletions
43
modules/hal_nordic/nrf_802154/radio/platform/nrf_802154_random_zephyr.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2019 - 2021 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
||
#include <platform/temperature/nrf_802154_temperature.h> | ||
#include <drivers/entropy.h> | ||
|
||
static uint32_t state; | ||
|
||
static uint32_t next(void) | ||
{ | ||
uint32_t num = state; | ||
|
||
state = 1664525 * num + 1013904223; | ||
return num; | ||
} | ||
|
||
void nrf_802154_random_init(void) | ||
{ | ||
const struct device *dev; | ||
int err; | ||
|
||
dev = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); | ||
__ASSERT_NO_MSG(dev != NULL); | ||
|
||
do { | ||
err = entropy_get_entropy(dev, (uint8_t *)&state, sizeof(state)); | ||
__ASSERT_NO_MSG(err == 0); | ||
} while (state == 0); | ||
} | ||
|
||
void nrf_802154_random_deinit(void) | ||
{ | ||
/* Intentionally empty */ | ||
} | ||
|
||
uint32_t nrf_802154_random_get(void) | ||
{ | ||
return next(); | ||
} |
36 changes: 36 additions & 0 deletions
36
modules/hal_nordic/nrf_802154/serialization/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set(NRF_802154_SER_SOURCE_DIR ${ZEPHYR_CURRENT_MODULE_DIR}/drivers/nrf_802154_serialization) | ||
|
||
zephyr_library_named(nrf_802154_ser) | ||
|
||
zephyr_library_sources( | ||
${NRF_802154_SER_SOURCE_DIR}/spinel_base/spinel.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_buffer_allocator.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_buffer_mgr_dst.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_buffer_mgr_src.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_kvmap.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_spinel.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_spinel_dec.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/platform/nrf_802154_serialization_crit_sect.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/platform/nrf_802154_spinel_log.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/platform/nrf_802154_spinel_backend_ipc.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/platform/nrf_802154_spinel_response_notifier.c | ||
) | ||
|
||
zephyr_library_sources_ifdef( | ||
CONFIG_NRF_802154_SER_HOST | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_spinel_app.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_spinel_dec_app.c | ||
) | ||
|
||
zephyr_library_sources_ifdef( | ||
CONFIG_NRF_802154_SER_RADIO | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_spinel_net.c | ||
${NRF_802154_SER_SOURCE_DIR}/src/nrf_802154_spinel_dec_net.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/platform/nrf_802154_init_net.c | ||
) | ||
|
||
zephyr_include_directories(${NRF_802154_SER_SOURCE_DIR}/include) | ||
zephyr_library_include_directories(${NRF_802154_SER_SOURCE_DIR}/src/include) |
24 changes: 24 additions & 0 deletions
24
modules/hal_nordic/nrf_802154/serialization/platform/nrf_802154_init_net.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2020 - 2021 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <init.h> | ||
|
||
#include "nrf_802154.h" | ||
#include "nrf_802154_serialization.h" | ||
|
||
static int serialization_init(const struct device *dev) | ||
{ | ||
/* On NET core we don't use Zephyr's shim layer so we have to call inits manually */ | ||
nrf_802154_init(); | ||
|
||
nrf_802154_serialization_init(); | ||
|
||
return 0; | ||
} | ||
|
||
SYS_INIT(serialization_init, POST_KERNEL, CONFIG_NRF_802154_SER_RADIO_INIT_PRIO); | ||
BUILD_ASSERT(CONFIG_NRF_802154_SER_RADIO_INIT_PRIO < CONFIG_RPMSG_SERVICE_INIT_PRIORITY, | ||
"CONFIG_NRF_802154_SER_RADIO_INIT_PRIO must be lower than CONFIG_RPMSG_SERVICE_INIT_PRIORITY"); |
29 changes: 29 additions & 0 deletions
29
modules/hal_nordic/nrf_802154/serialization/platform/nrf_802154_serialization_crit_sect.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2021 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "nrf_802154_serialization_crit_sect.h" | ||
|
||
#ifndef TEST | ||
#include <irq.h> | ||
#endif | ||
|
||
void nrf_802154_serialization_crit_sect_enter(uint32_t *p_critical_section) | ||
{ | ||
#ifndef TEST | ||
*p_critical_section = irq_lock(); | ||
#else | ||
(void)p_critical_section; | ||
#endif | ||
} | ||
|
||
void nrf_802154_serialization_crit_sect_exit(uint32_t critical_section) | ||
{ | ||
#ifndef TEST | ||
irq_unlock(critical_section); | ||
#else | ||
(void)critical_section; | ||
#endif | ||
} |
Oops, something went wrong.