From 5ef63d83136aaa6e3e67ca7b5ccbc1b526475020 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Tue, 23 Nov 2021 16:42:42 +0100 Subject: [PATCH] Bluetooth: Controller: nordic: Rework hw resources files Move all defines that specifies (D)PPI resources which are used to dedicated files which have no include dependencies. This allow to use them in nrfx_glue.h to specify fixed (D)PPI channels used by the bluetooth. Additionally, added mask with GPIOTE channels used by the bluetooth controller. It was previously not defined which could lead to conflicts since same channels could be allocated by the nrfx_gpiote user Updated nrfx_glue.h to use new approach. Signed-off-by: Krzysztof Chruscinski --- modules/hal_nordic/nrfx/nrfx_glue.h | 55 ++++-- .../ll_sw/nordic/hal/nrf5/radio/radio.c | 6 - .../ll_sw/nordic/hal/nrf5/radio/radio_nrf5.h | 4 - .../ll_sw/nordic/hal/nrf5/radio/radio_nrf51.h | 1 - .../nordic/hal/nrf5/radio/radio_nrf52805.h | 1 - .../nordic/hal/nrf5/radio/radio_nrf52810.h | 2 - .../nordic/hal/nrf5/radio/radio_nrf52811.h | 2 - .../nordic/hal/nrf5/radio/radio_nrf52820.h | 2 - .../nordic/hal/nrf5/radio/radio_nrf52832.h | 2 - .../nordic/hal/nrf5/radio/radio_nrf52833.h | 2 - .../nordic/hal/nrf5/radio/radio_nrf52840.h | 2 - .../nordic/hal/nrf5/radio/radio_nrf5340.h | 2 - .../nordic/hal/nrf5/radio/radio_nrf5_dppi.h | 112 +----------- .../nrf5/radio/radio_nrf5_dppi_resources.h | 133 ++++++++++++++ .../nordic/hal/nrf5/radio/radio_nrf5_ppi.h | 161 +---------------- .../hal/nrf5/radio/radio_nrf5_ppi_resources.h | 164 ++++++++++++++++++ .../hal/nrf5/radio/radio_nrf5_resources.h | 103 +++++++++++ .../nordic/hal/nrf5/radio/radio_sim_nrfxx.h | 2 - 18 files changed, 447 insertions(+), 309 deletions(-) create mode 100644 subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi_resources.h create mode 100644 subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi_resources.h create mode 100644 subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h diff --git a/modules/hal_nordic/nrfx/nrfx_glue.h b/modules/hal_nordic/nrfx/nrfx_glue.h index 1d6d3199914..6fef79ab101 100644 --- a/modules/hal_nordic/nrfx/nrfx_glue.h +++ b/modules/hal_nordic/nrfx/nrfx_glue.h @@ -272,39 +272,58 @@ void nrfx_busy_wait(uint32_t usec_to_wait); NRFX_PPI_GROUPS_USED_BY_MPSL) /** @brief Bitmask that defines GPIOTE channels that are reserved for use outside of the nrfx library. */ -#define NRFX_GPIOTE_CHANNELS_USED 0 +#define NRFX_GPIOTE_CHANNELS_USED NRFX_GPIOTE_CHANNELS_USED_BY_BT_CTLR #if defined(CONFIG_BT_CTLR) -extern const uint32_t z_bt_ctlr_used_nrf_ppi_channels; -extern const uint32_t z_bt_ctlr_used_nrf_ppi_groups; -#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR z_bt_ctlr_used_nrf_ppi_channels -#define NRFX_PPI_GROUPS_USED_BY_BT_CTLR z_bt_ctlr_used_nrf_ppi_groups +#include <../subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h> + +#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_CHANNELS +#define NRFX_PPI_GROUPS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_GROUPS +#define NRFX_GPIOTE_CHANNELS_USED_BY_BT_CTLR BT_CTLR_USED_GPIOTE_CHANNELS #else -#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR 0 -#define NRFX_PPI_GROUPS_USED_BY_BT_CTLR 0 +#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR 0 +#define NRFX_PPI_GROUPS_USED_BY_BT_CTLR 0 +#define NRFX_GPIOTE_CHANNELS_USED_BY_BT_CTLR 0 #endif #if defined(CONFIG_NRF_802154_RADIO_DRIVER) -extern const uint32_t g_nrf_802154_used_nrf_ppi_channels; -extern const uint32_t g_nrf_802154_used_nrf_ppi_groups; -#define NRFX_PPI_CHANNELS_USED_BY_802154_DRV g_nrf_802154_used_nrf_ppi_channels -#define NRFX_PPI_GROUPS_USED_BY_802154_DRV g_nrf_802154_used_nrf_ppi_groups +#if defined(NRF52_SERIES) +#include <../src/nrf_802154_peripherals_nrf52.h> +#define NRFX_PPI_CHANNELS_USED_BY_802154_DRV NRF_802154_PPI_CHANNELS_USED_MASK +#define NRFX_PPI_GROUPS_USED_BY_802154_DRV NRF_802154_PPI_GROUPS_USED_MASK +#elif defined(NRF53_SERIES) +#include <../src/nrf_802154_peripherals_nrf53.h> +#define NRFX_PPI_CHANNELS_USED_BY_802154_DRV NRF_802154_DPPI_CHANNELS_USED_MASK +#define NRFX_PPI_GROUPS_USED_BY_802154_DRV NRF_802154_DPPI_GROUPS_USED_MASK #else +#error Unsupported chip family +#endif +#else // CONFIG_NRF_802154_RADIO_DRIVER #define NRFX_PPI_CHANNELS_USED_BY_802154_DRV 0 #define NRFX_PPI_GROUPS_USED_BY_802154_DRV 0 -#endif +#endif // CONFIG_NRF_802154_RADIO_DRIVER -#if defined(CONFIG_NRF_802154_RADIO_DRIVER) && \ - !defined(CONFIG_NRF_802154_SL_OPENSOURCE) -extern const uint32_t z_mpsl_used_nrf_ppi_channels; -extern const uint32_t z_mpsl_used_nrf_ppi_groups; -#define NRFX_PPI_CHANNELS_USED_BY_MPSL z_mpsl_used_nrf_ppi_channels -#define NRFX_PPI_GROUPS_USED_BY_MPSL z_mpsl_used_nrf_ppi_groups +#if defined(CONFIG_NRF_802154_RADIO_DRIVER) && !defined(CONFIG_NRF_802154_SL_OPENSOURCE) +#include +#define NRFX_PPI_CHANNELS_USED_BY_MPSL MPSL_RESERVED_PPI_CHANNELS +#define NRFX_PPI_GROUPS_USED_BY_MPSL 0 #else #define NRFX_PPI_CHANNELS_USED_BY_MPSL 0 #define NRFX_PPI_GROUPS_USED_BY_MPSL 0 #endif +#if NRF_802154_VERIFY_PERIPHS_ALLOC_AGAINST_MPSL +BUILD_ASSERT( + (NRFX_PPI_CHANNELS_USED_BY_802154_DRV & NRFX_PPI_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT( + (NRFX_PPI_GROUPS_USED_BY_802154_DRV & NRFX_PPI_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); +#endif // NRF_802154_VERIFY_PERIPHS_ALLOC_AGAINST_MPSL + /** @brief Bitmask that defines EGU instances that are reserved for use outside of the nrfx library. */ #define NRFX_EGUS_USED 0 diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c index f78fbe5cecf..a4bd5383361 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c @@ -122,12 +122,6 @@ BUILD_ASSERT(DT_NODE_HAS_COMPAT(NRF_GPIO_CSN_CTLR, nordic_nrf_gpio), #endif /* HAL_RADIO_FEM_IS_NRF21540 */ -/* The following two constants are used in nrfx_glue.h for marking these PPI - * channels and groups as occupied and thus unavailable to other modules. - */ -const uint32_t z_bt_ctlr_used_nrf_ppi_channels = HAL_USED_PPI_CHANNELS; -const uint32_t z_bt_ctlr_used_nrf_ppi_groups = HAL_USED_PPI_GROUPS; - static radio_isr_cb_t isr_cb; static void *isr_cb_param; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5.h index fb21672d274..6a4a3c3ed0b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5.h @@ -50,10 +50,6 @@ #include -#define HAL_PALNA_GPIOTE_CHAN 0 -#define HAL_PDN_GPIOTE_CHAN 1 -#define HAL_CSN_GPIOTE_CHAN 2 - /* This has to come before the ppi/dppi includes below. */ #include "radio_nrf5_fem.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf51.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf51.h index 35c1ac808a6..b63d5c03d7b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf51.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf51.h @@ -8,7 +8,6 @@ #if !defined(CONFIG_BT_CTLR_TIFS_HW) #define SW_SWITCH_TIMER NRF_TIMER1 #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ /* TXEN->TXIDLE + TXIDLE->TX in microseconds. */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52805.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52805.h index 2013381be2f..ad5453a1bbe 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52805.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52805.h @@ -190,7 +190,6 @@ #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52810.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52810.h index 9c5479f867b..2136d871451 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52810.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52810.h @@ -189,8 +189,6 @@ #define SW_SWITCH_TIMER NRF_TIMER1 #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52811.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52811.h index 8ea7faeda4d..3aaad1ade90 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52811.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52811.h @@ -353,8 +353,6 @@ #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #define SW_SWITCH_TIMER_EVTS_COMP_S2_BASE 2 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52820.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52820.h index 46f6e9a5317..a76f0457bd4 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52820.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52820.h @@ -353,8 +353,6 @@ #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #define SW_SWITCH_TIMER_EVTS_COMP_S2_BASE 2 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52832.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52832.h index 77d89ff7ffc..696c7ece7ac 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52832.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52832.h @@ -190,8 +190,6 @@ #define SW_SWITCH_TIMER NRF_TIMER1 #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52833.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52833.h index f9d8347cb28..15593561a2b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52833.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52833.h @@ -353,8 +353,6 @@ #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #define SW_SWITCH_TIMER_EVTS_COMP_S2_BASE 2 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52840.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52840.h index 6382757d182..8c3f7c15c4f 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52840.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf52840.h @@ -354,8 +354,6 @@ #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #define SW_SWITCH_TIMER_EVTS_COMP_S2_BASE 2 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5340.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5340.h index c50035564b9..08f2a6541fc 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5340.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5340.h @@ -354,8 +354,6 @@ #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #define SW_SWITCH_TIMER_EVTS_COMP_S2_BASE 2 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h index c8019cc16bc..a6fdfdb5b3a 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h @@ -4,7 +4,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - #if defined(CONFIG_SOC_NRF5340_CPUNET) || defined(DPPI_PRESENT) #include @@ -15,6 +14,8 @@ #include #include +#include "radio_nrf5_dppi_resources.h" + static inline void hal_radio_nrf_ppi_channels_enable(uint32_t mask) { nrf_dppi_channels_enable(NRF_DPPIC, mask); @@ -29,10 +30,6 @@ static inline void hal_radio_nrf_ppi_channels_disable(uint32_t mask) * Enable Radio on Event Timer tick: * wire the EVENT_TIMER EVENTS_COMPARE[0] event to RADIO TASKS_TXEN/RXEN task. */ -#define HAL_RADIO_ENABLE_ON_TICK_PPI 6 -#define HAL_RADIO_ENABLE_TX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI -#define HAL_RADIO_ENABLE_RX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI - static inline void hal_radio_enable_on_tick_ppi_config_and_enable(uint8_t trx) { nrf_timer_publish_set(EVENT_TIMER, NRF_TIMER_EVENT_COMPARE0, HAL_RADIO_ENABLE_ON_TICK_PPI); @@ -63,8 +60,6 @@ static inline void hal_radio_enable_on_tick_ppi_config_and_enable(uint8_t trx) * wire the RADIO EVENTS_ADDRESS event to the * EVENT_TIMER TASKS_CAPTURE[
] task. */ -#define HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI 9 - static inline void hal_radio_recv_timeout_cancel_ppi_config(void) { nrf_radio_publish_set(NRF_RADIO, @@ -78,8 +73,6 @@ static inline void hal_radio_recv_timeout_cancel_ppi_config(void) * wire the EVENT_TIMER EVENTS_COMPARE[] event * to the RADIO TASKS_DISABLE task. */ -#define HAL_RADIO_DISABLE_ON_HCTO_PPI 10 - static inline void hal_radio_disable_on_hcto_ppi_config(void) { nrf_timer_publish_set(EVENT_TIMER, @@ -93,8 +86,6 @@ static inline void hal_radio_disable_on_hcto_ppi_config(void) * wire the RADIO EVENTS_END event to the * EVENT_TIMER TASKS_CAPTURE[] task. */ -#define HAL_RADIO_END_TIME_CAPTURE_PPI 11 - static inline void hal_radio_end_time_capture_ppi_config(void) { nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_END, HAL_RADIO_END_TIME_CAPTURE_PPI); @@ -106,8 +97,6 @@ static inline void hal_radio_end_time_capture_ppi_config(void) * Start event timer on RTC tick: * wire the RTC0 EVENTS_COMPARE[2] event to EVENT_TIMER TASKS_START task. */ -#define HAL_EVENT_TIMER_START_PPI 7 - static inline void hal_event_timer_start_ppi_config(void) { nrf_rtc_publish_set(NRF_RTC0, NRF_RTC_EVENT_COMPARE_2, HAL_EVENT_TIMER_START_PPI); @@ -119,8 +108,6 @@ static inline void hal_event_timer_start_ppi_config(void) * wire the RADIO EVENTS_READY event to the * EVENT_TIMER TASKS_CAPTURE[] task. */ -#define HAL_RADIO_READY_TIME_CAPTURE_PPI 8 - static inline void hal_radio_ready_time_capture_ppi_config(void) { nrf_radio_publish_set(NRF_RADIO, @@ -136,8 +123,6 @@ static inline void hal_radio_ready_time_capture_ppi_config(void) * Note: we do not need an additional PPI, since we have already set up * a PPI to publish RADIO ADDRESS event. */ -#define HAL_TRIGGER_CRYPT_PPI HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI - static inline void hal_trigger_crypt_ppi_config(void) { nrf_radio_publish_set(NRF_RADIO, @@ -149,8 +134,6 @@ static inline void hal_trigger_crypt_ppi_config(void) * Trigger automatic address resolution on Bit counter match: * wire the RADIO EVENTS_BCMATCH event to the AAR TASKS_START task. */ -#define HAL_TRIGGER_AAR_PPI 12 - static inline void hal_trigger_aar_ppi_config(void) { nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_BCMATCH, HAL_TRIGGER_AAR_PPI); @@ -160,8 +143,6 @@ static inline void hal_trigger_aar_ppi_config(void) /******************************************************************************* * Trigger Radio Rate override upon Rateboost event. */ -#define HAL_TRIGGER_RATEOVERRIDE_PPI 13 - static inline void hal_trigger_rateoverride_ppi_config(void) { nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_RATEBOOST, HAL_TRIGGER_RATEOVERRIDE_PPI); @@ -169,14 +150,7 @@ static inline void hal_trigger_rateoverride_ppi_config(void) } /******************************************************************************/ -#define HAL_ENABLE_PALNA_PPI 5 - -#if defined(HAL_RADIO_FEM_IS_NRF21540) -#define HAL_DISABLE_PALNA_PPI 4 -#else -#define HAL_DISABLE_PALNA_PPI HAL_ENABLE_PALNA_PPI -#endif - +#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN) static inline void hal_palna_ppi_setup(void) { nrf_timer_publish_set(EVENT_TIMER, NRF_TIMER_EVENT_COMPARE2, @@ -191,6 +165,7 @@ static inline void hal_palna_ppi_setup(void) nrf_gpiote_subscribe_set(NRF_GPIOTE, task, HAL_DISABLE_PALNA_PPI); #endif } +#endif /* defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN) */ /******************************************************************************/ #if defined(HAL_RADIO_FEM_IS_NRF21540) @@ -229,9 +204,6 @@ static inline void hal_lna_ppi_setup(void) #endif /* !HAL_RADIO_GPIO_LNA_POL_INV */ } -#define HAL_ENABLE_FEM_PPI 3 -#define HAL_DISABLE_FEM_PPI HAL_DISABLE_PALNA_PPI - static inline void hal_fem_ppi_setup(void) { nrf_gpiote_task_t task; @@ -278,8 +250,6 @@ static inline void hal_fem_ppi_setup(void) * Note: we do not need an additional PPI, since we have already set up * a PPI to publish RADIO END event. */ -#define HAL_SW_SWITCH_TIMER_CLEAR_PPI HAL_RADIO_END_TIME_CAPTURE_PPI - static inline void hal_sw_switch_timer_clear_ppi_config(void) { nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_END, HAL_SW_SWITCH_TIMER_CLEAR_PPI); @@ -318,7 +288,6 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * 2 adjacent PPIs (8 & 9) and 2 adjacent PPI groups are used for this wiring; * must be 0 or 1. must be a valid TIMER CC register offset. */ -#define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE 14 #define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(index) \ (HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE + (index)) @@ -343,7 +312,6 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * Note: we do not need an additional PPI, since we have already set up * a PPI to publish RADIO END event. */ -#define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI HAL_SW_SWITCH_TIMER_CLEAR_PPI #define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_EVT \ (NRF_RADIO->PUBLISH_END) #define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_EVT \ @@ -373,12 +341,9 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * We use the same PPI for the alternative SW Switch Timer compare * event. */ -#define HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE 14 #define HAL_SW_SWITCH_RADIO_ENABLE_PPI(index) \ (HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE + (index)) -#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE \ - HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE #define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI(index) \ (HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE + (index)) @@ -410,7 +375,6 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * * Note: We already have a PPI where we publish the RATEBOOST event. */ -#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI HAL_TRIGGER_RATEOVERRIDE_PPI #define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI_REGISTER_EVT \ NRF_RADIO->PUBLISH_RATEBOOST #define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI_EVT \ @@ -630,71 +594,3 @@ static inline void hal_radio_group_task_disable_ppi_setup(void) #endif /* !CONFIG_BT_CTLR_TIFS_HW */ #endif /* CONFIG_SOC_NRF5340_CPUNET || DPPI_PRESENT */ - -/******************************************************************************/ - -#define HAL_USED_PPI_CHANNELS \ - (BIT(HAL_RADIO_ENABLE_TX_ON_TICK_PPI) | \ - BIT(HAL_RADIO_ENABLE_RX_ON_TICK_PPI) | \ - BIT(HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI) | \ - BIT(HAL_RADIO_DISABLE_ON_HCTO_PPI) | \ - BIT(HAL_RADIO_END_TIME_CAPTURE_PPI) | \ - BIT(HAL_EVENT_TIMER_START_PPI) | \ - BIT(HAL_RADIO_READY_TIME_CAPTURE_PPI) | \ - BIT(HAL_TRIGGER_CRYPT_PPI) | \ - BIT(HAL_TRIGGER_AAR_PPI) | \ - HAL_USED_PPI_CHANNELS_2 | HAL_USED_PPI_CHANNELS_3 | \ - HAL_USED_PPI_CHANNELS_4 | HAL_USED_PPI_CHANNELS_5 | \ - HAL_USED_PPI_CHANNELS_6) - -#if defined(HAL_TRIGGER_RATEOVERRIDE_PPI) -#define HAL_USED_PPI_CHANNELS_2 \ - BIT(HAL_TRIGGER_RATEOVERRIDE_PPI) -#else -#define HAL_USED_PPI_CHANNELS_2 0 -#endif - -#if defined(HAL_ENABLE_PALNA_PPI) -#define HAL_USED_PPI_CHANNELS_3 \ - (BIT(HAL_ENABLE_PALNA_PPI) | \ - BIT(HAL_DISABLE_PALNA_PPI)) -#else -#define HAL_USED_PPI_CHANNELS_3 0 -#endif - -#if defined(HAL_SW_SWITCH_TIMER_CLEAR_PPI) -#define HAL_USED_PPI_CHANNELS_4 \ - (BIT(HAL_SW_SWITCH_TIMER_CLEAR_PPI) | \ - BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE) | \ - BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE + 1) | \ - BIT(HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI) | \ - BIT(HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE) | \ - BIT(HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE + 1)) -#else -#define HAL_USED_PPI_CHANNELS_4 0 -#endif - -#if defined(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE) -#define HAL_USED_PPI_CHANNELS_5 \ - (BIT(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE) | \ - BIT(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE + 1) | \ - BIT(HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI)) -#else -#define HAL_USED_PPI_CHANNELS_5 0 -#endif - -#if defined(HAL_ENABLE_FEM_PPI) -#define HAL_USED_PPI_CHANNELS_6 \ - (BIT(HAL_ENABLE_FEM_PPI) | \ - BIT(HAL_DISABLE_FEM_PPI)) -#else -#define HAL_USED_PPI_CHANNELS_6 0 -#endif - -#if defined(SW_SWITCH_TIMER_TASK_GROUP_BASE) -#define HAL_USED_PPI_GROUPS \ - (BIT(SW_SWITCH_TIMER_TASK_GROUP_BASE) | \ - BIT(SW_SWITCH_TIMER_TASK_GROUP_BASE + 1)) -#else -#define HAL_USED_PPI_GROUPS 0 -#endif diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi_resources.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi_resources.h new file mode 100644 index 00000000000..a1d3146a62a --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi_resources.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#if defined(CONFIG_SOC_NRF5340_CPUNET) || defined(DPPI_PRESENT) + +/******************************************************************************* + * Enable Radio on Event Timer tick: + * wire the EVENT_TIMER EVENTS_COMPARE[0] event to RADIO TASKS_TXEN/RXEN task. + */ +#define HAL_RADIO_ENABLE_ON_TICK_PPI 6 +#define HAL_RADIO_ENABLE_TX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI +#define HAL_RADIO_ENABLE_RX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI + +/******************************************************************************* + * Capture event timer on Address reception: + * wire the RADIO EVENTS_ADDRESS event to the + * EVENT_TIMER TASKS_CAPTURE[
] task. + */ +#define HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI 9 + +/******************************************************************************* + * Disable Radio on HCTO: + * wire the EVENT_TIMER EVENTS_COMPARE[] event + * to the RADIO TASKS_DISABLE task. + */ +#define HAL_RADIO_DISABLE_ON_HCTO_PPI 10 + +/******************************************************************************* + * Capture event timer on Radio end: + * wire the RADIO EVENTS_END event to the + * EVENT_TIMER TASKS_CAPTURE[] task. + */ +#define HAL_RADIO_END_TIME_CAPTURE_PPI 11 + +/******************************************************************************* + * Start event timer on RTC tick: + * wire the RTC0 EVENTS_COMPARE[2] event to EVENT_TIMER TASKS_START task. + */ +#define HAL_EVENT_TIMER_START_PPI 7 + +/******************************************************************************* + * Capture event timer on Radio ready: + * wire the RADIO EVENTS_READY event to the + * EVENT_TIMER TASKS_CAPTURE[] task. + */ +#define HAL_RADIO_READY_TIME_CAPTURE_PPI 8 + +/******************************************************************************* + * Trigger encryption task upon address reception: + * wire the RADIO EVENTS_ADDRESS event to the CCM TASKS_CRYPT task. + * + * Note: we do not need an additional PPI, since we have already set up + * a PPI to publish RADIO ADDRESS event. + */ +#define HAL_TRIGGER_CRYPT_PPI HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI + +/******************************************************************************* + * Trigger automatic address resolution on Bit counter match: + * wire the RADIO EVENTS_BCMATCH event to the AAR TASKS_START task. + */ +#define HAL_TRIGGER_AAR_PPI 12 + +/******************************************************************************* + * Trigger Radio Rate override upon Rateboost event. + */ +#define HAL_TRIGGER_RATEOVERRIDE_PPI 13 + +/******************************************************************************/ +#define HAL_ENABLE_PALNA_PPI 5 + +#if defined(HAL_RADIO_FEM_IS_NRF21540) +#define HAL_DISABLE_PALNA_PPI 4 +#else +#define HAL_DISABLE_PALNA_PPI HAL_ENABLE_PALNA_PPI +#endif + +#define HAL_ENABLE_FEM_PPI 3 +#define HAL_DISABLE_FEM_PPI HAL_DISABLE_PALNA_PPI + +/******************************************************************************/ +#if !defined(CONFIG_BT_CTLR_TIFS_HW) +/* DPPI setup used for SW-based auto-switching during TIFS. */ + +/* Clear SW-switch timer on packet end: + * wire the RADIO EVENTS_END event to SW_SWITCH_TIMER TASKS_CLEAR task. + * + * Note: we do not need an additional PPI, since we have already set up + * a PPI to publish RADIO END event. + */ +#define HAL_SW_SWITCH_TIMER_CLEAR_PPI HAL_RADIO_END_TIME_CAPTURE_PPI + +/* Wire a SW SWITCH TIMER EVENTS_COMPARE[] event + * to a PPI GROUP TASK DISABLE task (PPI group with index ). + * 2 adjacent PPIs (8 & 9) and 2 adjacent PPI groups are used for this wiring; + * must be 0 or 1. must be a valid TIMER CC register offset. + */ +#define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE 14 + +/* Enable the SW Switch PPI Group on RADIO END Event. + * + * Note: we do not need an additional PPI, since we have already set up + * a PPI to publish RADIO END event. + */ +#define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI HAL_SW_SWITCH_TIMER_CLEAR_PPI + +/* Enable Radio on SW Switch timer event. + * Wire a SW SWITCH TIMER EVENTS_COMPARE[] event + * to a RADIO Enable task (TX or RX). + * + * Note: + * We use the same PPI as for disabling the SW Switch PPI groups, + * since we need to listen for the same event (SW Switch event). + * + * We use the same PPI for the alternative SW Switch Timer compare + * event. + */ +#define HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE 14 + +#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE \ + HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE + +/* Cancel the SW switch timer running considering S8 timing: + * wire the RADIO EVENTS_RATEBOOST event to SW_SWITCH_TIMER TASKS_CAPTURE task. + * + * Note: We already have a PPI where we publish the RATEBOOST event. + */ +#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI HAL_TRIGGER_RATEOVERRIDE_PPI + +#endif /* !CONFIG_BT_CTLR_TIFS_HW */ + +#endif /* CONFIG_SOC_NRF5340_CPUNET || DPPI_PRESENT */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h index 1701ce72ba5..f16e4d78c3f 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h @@ -4,11 +4,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ - #if defined(CONFIG_SOC_SERIES_NRF51X) || defined(CONFIG_SOC_COMPATIBLE_NRF52X) #include +#include "radio_nrf5_ppi_resources.h" + static inline void hal_radio_nrf_ppi_channels_enable(uint32_t mask) { nrf_ppi_channels_enable(NRF_PPI, mask); @@ -28,17 +29,6 @@ static inline void hal_radio_nrf_ppi_channels_disable(uint32_t mask) */ #if (EVENT_TIMER_ID == 0) -/* PPI channel 20 is pre-programmed with the following fixed settings: - * EEP: TIMER0->EVENTS_COMPARE[0] - * TEP: RADIO->TASKS_TXEN - */ -#define HAL_RADIO_ENABLE_TX_ON_TICK_PPI 20 -/* PPI channel 21 is pre-programmed with the following fixed settings: - * EEP: TIMER0->EVENTS_COMPARE[0] - * TEP: RADIO->TASKS_RXEN - */ -#define HAL_RADIO_ENABLE_RX_ON_TICK_PPI 21 - static inline void hal_radio_enable_on_tick_ppi_config_and_enable(uint8_t trx) { /* No need to configure anything for the pre-programmed channels. @@ -56,10 +46,6 @@ static inline void hal_radio_enable_on_tick_ppi_config_and_enable(uint8_t trx) #else -#define HAL_RADIO_ENABLE_ON_TICK_PPI 2 -#define HAL_RADIO_ENABLE_TX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI -#define HAL_RADIO_ENABLE_RX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI - static inline void hal_radio_enable_on_tick_ppi_config_and_enable(uint8_t trx) { uint32_t event_address = (trx ? (uint32_t)&(NRF_RADIO->TASKS_TXEN) @@ -84,12 +70,6 @@ static inline void hal_radio_enable_on_tick_ppi_config_and_enable(uint8_t trx) */ #if (EVENT_TIMER_ID == 0) -/* PPI channel 26 is pre-programmed with the following fixed settings: - * EEP: RADIO->EVENTS_ADDRESS - * TEP: TIMER0->TASKS_CAPTURE[1] - */ -#define HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI 26 - static inline void hal_radio_recv_timeout_cancel_ppi_config(void) { /* No need to configure anything for the pre-programmed channel. */ @@ -97,8 +77,6 @@ static inline void hal_radio_recv_timeout_cancel_ppi_config(void) #else -#define HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI 3 - static inline void hal_radio_recv_timeout_cancel_ppi_config(void) { nrf_ppi_channel_endpoint_setup( @@ -120,12 +98,6 @@ static inline void hal_radio_recv_timeout_cancel_ppi_config(void) */ #if (EVENT_TIMER_ID == 0) -/* PPI channel 22 is pre-programmed with the following fixed settings: - * EEP: TIMER0->EVENTS_COMPARE[1] - * TEP: RADIO->TASKS_DISABLE - */ -#define HAL_RADIO_DISABLE_ON_HCTO_PPI 22 - static inline void hal_radio_disable_on_hcto_ppi_config(void) { /* No need to configure anything for the pre-programmed channel. */ @@ -133,8 +105,6 @@ static inline void hal_radio_disable_on_hcto_ppi_config(void) #else -#define HAL_RADIO_DISABLE_ON_HCTO_PPI 4 - static inline void hal_radio_disable_on_hcto_ppi_config(void) { nrf_ppi_channel_endpoint_setup( @@ -156,12 +126,6 @@ static inline void hal_radio_disable_on_hcto_ppi_config(void) */ #if (EVENT_TIMER_ID == 0) -/* PPI channel 27 is pre-programmed with the following fixed settings: - * EEP: RADIO->EVENTS_END - * TEP: TIMER0->TASKS_CAPTURE[2] - */ -#define HAL_RADIO_END_TIME_CAPTURE_PPI 27 - static inline void hal_radio_end_time_capture_ppi_config(void) { /* No need to configure anything for the pre-programmed channel. */ @@ -169,8 +133,6 @@ static inline void hal_radio_end_time_capture_ppi_config(void) #else -#define HAL_RADIO_END_TIME_CAPTURE_PPI 5 - static inline void hal_radio_end_time_capture_ppi_config(void) { nrf_ppi_channel_endpoint_setup( @@ -186,8 +148,6 @@ static inline void hal_radio_end_time_capture_ppi_config(void) * Start event timer on RTC tick: * wire the RTC0 EVENTS_COMPARE[2] event to EVENT_TIMER TASKS_START task. */ -#define HAL_EVENT_TIMER_START_PPI 6 - static inline void hal_event_timer_start_ppi_config(void) { nrf_ppi_channel_endpoint_setup( @@ -202,8 +162,6 @@ static inline void hal_event_timer_start_ppi_config(void) * wire the RADIO EVENTS_READY event to the * EVENT_TIMER TASKS_CAPTURE[] task. */ -#define HAL_RADIO_READY_TIME_CAPTURE_PPI 7 - static inline void hal_radio_ready_time_capture_ppi_config(void) { nrf_ppi_channel_endpoint_setup( @@ -221,8 +179,6 @@ static inline void hal_radio_ready_time_capture_ppi_config(void) * EEP: RADIO->EVENTS_ADDRESS * TEP: CCM->TASKS_CRYPT */ -#define HAL_TRIGGER_CRYPT_PPI 25 - static inline void hal_trigger_crypt_ppi_config(void) { /* No need to configure anything for the pre-programmed channel. */ @@ -236,8 +192,6 @@ static inline void hal_trigger_crypt_ppi_config(void) * EEP: RADIO->EVENTS_BCMATCH * TEP: AAR->TASKS_START */ -#define HAL_TRIGGER_AAR_PPI 23 - static inline void hal_trigger_aar_ppi_config(void) { /* No need to configure anything for the pre-programmed channel. */ @@ -247,9 +201,6 @@ static inline void hal_trigger_aar_ppi_config(void) * Trigger Radio Rate override upon Rateboost event. */ #if defined(CONFIG_HAS_HW_NRF_RADIO_BLE_CODED) - -#define HAL_TRIGGER_RATEOVERRIDE_PPI 14 - static inline void hal_trigger_rateoverride_ppi_config(void) { nrf_ppi_channel_endpoint_setup( @@ -258,13 +209,10 @@ static inline void hal_trigger_rateoverride_ppi_config(void) (uint32_t)&(NRF_RADIO->EVENTS_RATEBOOST), (uint32_t)&(NRF_CCM->TASKS_RATEOVERRIDE)); } - #endif /* CONFIG_HAS_HW_NRF_RADIO_BLE_CODED */ /******************************************************************************/ -#define HAL_ENABLE_PALNA_PPI 15 -#define HAL_DISABLE_PALNA_PPI 16 - +#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN) static inline void hal_palna_ppi_setup(void) { nrf_ppi_channel_endpoint_setup( @@ -278,6 +226,7 @@ static inline void hal_palna_ppi_setup(void) (uint32_t)&(NRF_RADIO->EVENTS_DISABLED), (uint32_t)&(NRF_GPIOTE->TASKS_OUT[HAL_PALNA_GPIOTE_CHAN])); } +#endif /* defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN) */ /******************************************************************************/ #if defined(HAL_RADIO_FEM_IS_NRF21540) @@ -291,9 +240,6 @@ static inline void hal_lna_ppi_setup(void) /* Nothing specific to LNA with FEM to handle inside TRX chains */ } -#define HAL_ENABLE_FEM_PPI 4 -#define HAL_DISABLE_FEM_PPI 5 - static inline void hal_fem_ppi_setup(void) { nrf_ppi_channel_and_fork_endpoint_setup( @@ -323,7 +269,6 @@ static inline void hal_fem_ppi_setup(void) * * Note: this PPI is not needed if we use a single TIMER instance in radio.c */ -#define HAL_SW_SWITCH_TIMER_CLEAR_PPI 8 static inline void hal_sw_switch_timer_clear_ppi_config(void) { @@ -343,7 +288,6 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * Note: in nRF52X this PPI channel is forked for both capturing and clearing * timer on RADIO EVENTS_END. */ -#define HAL_SW_SWITCH_TIMER_CLEAR_PPI HAL_RADIO_END_TIME_CAPTURE_PPI static inline void hal_sw_switch_timer_clear_ppi_config(void) { @@ -372,19 +316,14 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * 2 adjacent PPIs (9 & 10) and 2 adjacent PPI groups are used for this wiring; * must be 0 or 1. must be a valid TIMER CC register offset. */ -#if defined(CONFIG_SOC_NRF52805) /* Because nRF52805 has limited number of programmable PPI channels, * tIFS Trx SW switching on this SoC can be used only when pre-programmed * PPI channels are also in use, i.e. when TIMER0 is the event timer. */ -#if (EVENT_TIMER_ID == 0) -#define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE 2 -#else +#if (EVENT_TIMER_ID != 0) && defined(CONFIG_SOC_NRF52805) #error "tIFS Trx SW switch can be used on this SoC only with TIMER0 as the event timer" #endif -#else /* -> !defined(CONFIG_SOC_NRF52805) */ -#define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE 9 -#endif + #define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(index) \ (HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE + (index)) #define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_EVT(chan) \ @@ -399,15 +338,6 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) /* Wire the RADIO EVENTS_END event to one of the PPI GROUP TASK ENABLE task. * 2 adjacent PPI groups are used for this wiring. 'index' must be 0 or 1. */ -#if defined(CONFIG_SOC_NRF52805) -#if (EVENT_TIMER_ID == 0) -#define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI 9 -#else -#error "tIFS Trx SW switch can be used on this SoC only with TIMER0 as the event timer" -#endif -#else /* -> !defined(CONFIG_SOC_NRF52805) */ -#define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI 11 -#endif #define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_EVT \ ((uint32_t)&(NRF_RADIO->EVENTS_END)) #define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_TASK(index) \ @@ -419,15 +349,6 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * 2 adjacent PPIs (12 & 13) are used for this wiring; must be 0 or 1. * must be a valid TIMER CC register offset. */ -#if defined(CONFIG_SOC_NRF52805) -#if (EVENT_TIMER_ID == 0) -#define HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE 4 -#else -#error "tIFS Trx SW switch can be used on this SoC only with TIMER0 as the event timer" -#endif -#else /* -> !defined(CONFIG_SOC_NRF52805) */ -#define HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE 12 -#endif #define HAL_SW_SWITCH_RADIO_ENABLE_PPI(index) \ (HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE + (index)) #define HAL_SW_SWITCH_RADIO_ENABLE_PPI_REGISTER_EVT(chan) \ @@ -526,14 +447,12 @@ static inline void hal_radio_sw_switch_cleanup(void) /* Wire the SW SWITCH TIMER EVENTS_COMPARE[] event * to RADIO TASKS_TXEN/RXEN task. */ -#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE 17 #define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI(index) \ (HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE + (index)) /* Cancel the SW switch timer running considering S8 timing: * wire the RADIO EVENTS_RATEBOOST event to SW_SWITCH_TIMER TASKS_CAPTURE task. */ -#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI 19 #define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI_REGISTER_EVT \ NRF_PPI->CH[HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI].EEP #define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI_EVT \ @@ -648,71 +567,3 @@ static inline void hal_radio_sw_switch_ppi_group_setup(void) #endif /* !CONFIG_BT_CTLR_TIFS_HW */ #endif /* CONFIG_SOC_SERIES_NRF51X || CONFIG_SOC_COMPATIBLE_NRF52X */ - -/******************************************************************************/ - -#define HAL_USED_PPI_CHANNELS \ - (BIT(HAL_RADIO_ENABLE_TX_ON_TICK_PPI) | \ - BIT(HAL_RADIO_ENABLE_RX_ON_TICK_PPI) | \ - BIT(HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI) | \ - BIT(HAL_RADIO_DISABLE_ON_HCTO_PPI) | \ - BIT(HAL_RADIO_END_TIME_CAPTURE_PPI) | \ - BIT(HAL_EVENT_TIMER_START_PPI) | \ - BIT(HAL_RADIO_READY_TIME_CAPTURE_PPI) | \ - BIT(HAL_TRIGGER_CRYPT_PPI) | \ - BIT(HAL_TRIGGER_AAR_PPI) | \ - HAL_USED_PPI_CHANNELS_2 | HAL_USED_PPI_CHANNELS_3 | \ - HAL_USED_PPI_CHANNELS_4 | HAL_USED_PPI_CHANNELS_5 | \ - HAL_USED_PPI_CHANNELS_6) - -#if defined(HAL_TRIGGER_RATEOVERRIDE_PPI) -#define HAL_USED_PPI_CHANNELS_2 \ - BIT(HAL_TRIGGER_RATEOVERRIDE_PPI) -#else -#define HAL_USED_PPI_CHANNELS_2 0 -#endif - -#if defined(HAL_ENABLE_PALNA_PPI) -#define HAL_USED_PPI_CHANNELS_3 \ - (BIT(HAL_ENABLE_PALNA_PPI) | \ - BIT(HAL_DISABLE_PALNA_PPI)) -#else -#define HAL_USED_PPI_CHANNELS_3 0 -#endif - -#if defined(HAL_SW_SWITCH_TIMER_CLEAR_PPI) -#define HAL_USED_PPI_CHANNELS_4 \ - (BIT(HAL_SW_SWITCH_TIMER_CLEAR_PPI) | \ - BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE) | \ - BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE + 1) | \ - BIT(HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI) | \ - BIT(HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE) | \ - BIT(HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE + 1)) -#else -#define HAL_USED_PPI_CHANNELS_4 0 -#endif - -#if defined(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE) -#define HAL_USED_PPI_CHANNELS_5 \ - (BIT(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE) | \ - BIT(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE + 1) | \ - BIT(HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI)) -#else -#define HAL_USED_PPI_CHANNELS_5 0 -#endif - -#if defined(HAL_ENABLE_FEM_PPI) -#define HAL_USED_PPI_CHANNELS_6 \ - (BIT(HAL_ENABLE_FEM_PPI) | \ - BIT(HAL_DISABLE_FEM_PPI)) -#else -#define HAL_USED_PPI_CHANNELS_6 0 -#endif - -#if defined(SW_SWITCH_TIMER_TASK_GROUP_BASE) -#define HAL_USED_PPI_GROUPS \ - (BIT(SW_SWITCH_TIMER_TASK_GROUP_BASE) | \ - BIT(SW_SWITCH_TIMER_TASK_GROUP_BASE + 1)) -#else -#define HAL_USED_PPI_GROUPS 0 -#endif diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi_resources.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi_resources.h new file mode 100644 index 00000000000..681651688f1 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi_resources.h @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include "radio_nrf5_fem.h" + +#if defined(CONFIG_BT_CTLR_TIFS_HW) || !defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) + +/* PPI channel 20 is pre-programmed with the following fixed settings: + * EEP: TIMER0->EVENTS_COMPARE[0] + * TEP: RADIO->TASKS_TXEN + */ +#define HAL_RADIO_ENABLE_TX_ON_TICK_PPI 20 +/* PPI channel 21 is pre-programmed with the following fixed settings: + * EEP: TIMER0->EVENTS_COMPARE[0] + * TEP: RADIO->TASKS_RXEN + */ +#define HAL_RADIO_ENABLE_RX_ON_TICK_PPI 21 + +/* PPI channel 26 is pre-programmed with the following fixed settings: + * EEP: RADIO->EVENTS_ADDRESS + * TEP: TIMER0->TASKS_CAPTURE[1] + */ +#define HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI 26 + +/* PPI channel 22 is pre-programmed with the following fixed settings: + * EEP: TIMER0->EVENTS_COMPARE[1] + * TEP: RADIO->TASKS_DISABLE + */ +#define HAL_RADIO_DISABLE_ON_HCTO_PPI 22 + +/* PPI channel 27 is pre-programmed with the following fixed settings: + * EEP: RADIO->EVENTS_END + * TEP: TIMER0->TASKS_CAPTURE[2] + */ +#define HAL_RADIO_END_TIME_CAPTURE_PPI 27 + +#else /* CONFIG_BT_CTLR_TIFS_HW || !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ + +#define HAL_RADIO_ENABLE_ON_TICK_PPI 2 +#define HAL_RADIO_ENABLE_TX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI +#define HAL_RADIO_ENABLE_RX_ON_TICK_PPI HAL_RADIO_ENABLE_ON_TICK_PPI +#define HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI 3 +#define HAL_RADIO_DISABLE_ON_HCTO_PPI 4 +#define HAL_RADIO_END_TIME_CAPTURE_PPI 5 + +#endif /* CONFIG_BT_CTLR_TIFS_HW || !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ + +/* Start event timer on RTC tick wire the RTC0 EVENTS_COMPARE[2] event to + * EVENT_TIMER TASKS_START task. + */ +#define HAL_EVENT_TIMER_START_PPI 6 + +/* Capture event timer on Radio ready, wire the RADIO EVENTS_READY event to the + * EVENT_TIMER TASKS_CAPTURE[] task. + */ +#define HAL_RADIO_READY_TIME_CAPTURE_PPI 7 + +/* Trigger encryption task upon address reception: + * wire the RADIO EVENTS_ADDRESS event to the CCM TASKS_CRYPT task. + * + * PPI channel 25 is pre-programmed with the following fixed settings: + * EEP: RADIO->EVENTS_ADDRESS + * TEP: CCM->TASKS_CRYPT + */ +#define HAL_TRIGGER_CRYPT_PPI 25 + +/* Trigger automatic address resolution on Bit counter match: + * wire the RADIO EVENTS_BCMATCH event to the AAR TASKS_START task. + * + * PPI channel 23 is pre-programmed with the following fixed settings: + * EEP: RADIO->EVENTS_BCMATCH + * TEP: AAR->TASKS_START + */ +#define HAL_TRIGGER_AAR_PPI 23 + +/* Trigger Radio Rate override upon Rateboost event. */ +#if defined(CONFIG_HAS_HW_NRF_RADIO_BLE_CODED) +#define HAL_TRIGGER_RATEOVERRIDE_PPI 14 +#endif /* CONFIG_HAS_HW_NRF_RADIO_BLE_CODED */ + +#define HAL_ENABLE_PALNA_PPI 15 +#define HAL_DISABLE_PALNA_PPI 16 + +#if defined(HAL_RADIO_FEM_IS_NRF21540) +#define HAL_ENABLE_FEM_PPI 4 +#define HAL_DISABLE_FEM_PPI 5 +#endif /* HAL_RADIO_FEM_IS_NRF21540 */ + +#if !defined(CONFIG_BT_CTLR_TIFS_HW) +/* PPI setup used for SW-based auto-switching during TIFS. */ + +#if !defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) + +/* Clear SW-switch timer on packet end: + * wire the RADIO EVENTS_END event to SW_SWITCH_TIMER TASKS_CLEAR task. + * + * Note: this PPI is not needed if we use a single TIMER instance in radio.c + */ +#define HAL_SW_SWITCH_TIMER_CLEAR_PPI 8 + +#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ + +/* Clear event timer (sw-switch timer) on Radio end: + * wire the RADIO EVENTS_END event to the + * EVENT_TIMER TASKS_CLEAR task. + * + * Note: in nRF52X this PPI channel is forked for both capturing and clearing + * timer on RADIO EVENTS_END. + */ +#define HAL_SW_SWITCH_TIMER_CLEAR_PPI HAL_RADIO_END_TIME_CAPTURE_PPI + +#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ + +/* Wire a SW SWITCH TIMER EVENTS_COMPARE[] event + * to a PPI GROUP TASK DISABLE task (PPI group with index ). + * 2 adjacent PPIs (9 & 10) and 2 adjacent PPI groups are used for this wiring; + * must be 0 or 1. must be a valid TIMER CC register offset. + */ +#if defined(CONFIG_SOC_NRF52805) +#define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE 2 +#else /* CONFIG_SOC_NRF52805 */ +#define HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE 9 +#endif + +/* Wire the RADIO EVENTS_END event to one of the PPI GROUP TASK ENABLE task. + * 2 adjacent PPI groups are used for this wiring. 'index' must be 0 or 1. + */ +#if defined(CONFIG_SOC_NRF52805) +#define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI 9 +#else /* CONFIG_SOC_NRF52805 */ +#define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI 11 +#endif + +/*Enable Radio at specific time-stamp: + * wire the SW SWITCH TIMER EVENTS_COMPARE[] event + * to RADIO TASKS_TXEN/RXEN task. + * 2 adjacent PPIs (12 & 13) are used for this wiring; must be 0 or 1. + * must be a valid TIMER CC register offset. + */ +#if defined(CONFIG_SOC_NRF52805) +#define HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE 4 +#else /* CONFIG_SOC_NRF52805 */ +#define HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE 12 +#endif + +#if defined(CONFIG_BT_CTLR_PHY_CODED) && \ + defined(CONFIG_HAS_HW_NRF_RADIO_BLE_CODED) + +/* Wire the SW SWITCH TIMER EVENTS_COMPARE[] event + * to RADIO TASKS_TXEN/RXEN task. + */ +#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE 17 + +/* Cancel the SW switch timer running considering S8 timing: + * wire the RADIO EVENTS_RATEBOOST event to SW_SWITCH_TIMER TASKS_CAPTURE task. + */ +#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI 19 + +#endif /* CONFIG_HAS_HW_NRF_RADIO_BLE_CODED */ + +#endif /* !CONFIG_BT_CTLR_TIFS_HW */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h new file mode 100644 index 00000000000..6e666560da2 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "radio_nrf5_fem.h" + +#ifdef DPPI_PRESENT +#include "radio_nrf5_dppi_resources.h" +#else +#include "radio_nrf5_ppi_resources.h" +#endif + +#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || \ + defined(HAL_RADIO_GPIO_HAVE_LNA_PIN) +#define HAL_PALNA_GPIOTE_CHAN 0 +#define HAL_PALNA_GPIOTE_MASK BIT(HAL_PALNA_GPIOTE_CHAN) +#else +#define HAL_PALNA_GPIOTE_MASK 0 +#endif + +#if defined(HAL_RADIO_FEM_IS_NRF21540) +#define HAL_PDN_GPIOTE_CHAN 1 +#define HAL_CSN_GPIOTE_CHAN 2 +#define HAL_PDN_CSN_GPIOTE_MASK (BIT(HAL_PDN_GPIOTE_CHAN) | BIT(HAL_CSN_GPIOTE_CHAN)) +#else +#define HAL_PDN_CSN_GPIOTE_MASK 0 +#endif + +/* Mask with all GPIOTE channels used by the bluetooth controller. */ +#define BT_CTLR_USED_GPIOTE_CHANNELS (HAL_PALNA_GPIOTE_MASK | HAL_PDN_CSN_GPIOTE_MASK) + +/* Mask with all (D)PPI channels used by the bluetooth controller. */ +#define BT_CTLR_USED_PPI_CHANNELS \ + (BIT(HAL_RADIO_ENABLE_TX_ON_TICK_PPI) | \ + BIT(HAL_RADIO_ENABLE_RX_ON_TICK_PPI) | \ + BIT(HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI) | \ + BIT(HAL_RADIO_DISABLE_ON_HCTO_PPI) | \ + BIT(HAL_RADIO_END_TIME_CAPTURE_PPI) | \ + BIT(HAL_EVENT_TIMER_START_PPI) | \ + BIT(HAL_RADIO_READY_TIME_CAPTURE_PPI) | \ + BIT(HAL_TRIGGER_CRYPT_PPI) | \ + BIT(HAL_TRIGGER_AAR_PPI) | \ + BT_CTLR_USED_PPI_CHANNELS_2 | BT_CTLR_USED_PPI_CHANNELS_3 | \ + BT_CTLR_USED_PPI_CHANNELS_4 | BT_CTLR_USED_PPI_CHANNELS_5 | \ + BT_CTLR_USED_PPI_CHANNELS_6) + +#if defined(HAL_TRIGGER_RATEOVERRIDE_PPI) +#define BT_CTLR_USED_PPI_CHANNELS_2 \ + BIT(HAL_TRIGGER_RATEOVERRIDE_PPI) +#else +#define BT_CTLR_USED_PPI_CHANNELS_2 0 +#endif + +#if defined(HAL_ENABLE_PALNA_PPI) +#define BT_CTLR_USED_PPI_CHANNELS_3 \ + (BIT(HAL_ENABLE_PALNA_PPI) | \ + BIT(HAL_DISABLE_PALNA_PPI)) +#else +#define BT_CTLR_USED_PPI_CHANNELS_3 0 +#endif + +#if defined(HAL_SW_SWITCH_TIMER_CLEAR_PPI) +#define BT_CTLR_USED_PPI_CHANNELS_4 \ + (BIT(HAL_SW_SWITCH_TIMER_CLEAR_PPI) | \ + BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE) | \ + BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_BASE + 1) | \ + BIT(HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI) | \ + BIT(HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE) | \ + BIT(HAL_SW_SWITCH_RADIO_ENABLE_PPI_BASE + 1)) +#else +#define BT_CTLR_USED_PPI_CHANNELS_4 0 +#endif + +#if defined(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE) +#define BT_CTLR_USED_PPI_CHANNELS_5 \ + (BIT(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE) | \ + BIT(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE + 1) | \ + BIT(HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI)) +#else +#define BT_CTLR_USED_PPI_CHANNELS_5 0 +#endif + +#if defined(HAL_ENABLE_FEM_PPI) +#define BT_CTLR_USED_PPI_CHANNELS_6 \ + (BIT(HAL_ENABLE_FEM_PPI) | \ + BIT(HAL_DISABLE_FEM_PPI)) +#else +#define BT_CTLR_USED_PPI_CHANNELS_6 0 +#endif + +#if !defined(CONFIG_BT_CTLR_TIFS_HW) +#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 +#endif + +/* Mask with all (D)PPI groups used by the bluetooth controller. */ +#if defined(SW_SWITCH_TIMER_TASK_GROUP_BASE) +#define BT_CTLR_USED_PPI_GROUPS \ + (BIT(SW_SWITCH_TIMER_TASK_GROUP_BASE) | \ + BIT(SW_SWITCH_TIMER_TASK_GROUP_BASE + 1)) +#else +#define BT_CTLR_USED_PPI_GROUPS 0 +#endif diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_sim_nrfxx.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_sim_nrfxx.h index a98a9f94612..d4cf3d93ce8 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_sim_nrfxx.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_sim_nrfxx.h @@ -193,8 +193,6 @@ #define SW_SWITCH_TIMER NRF_TIMER1 #define SW_SWITCH_TIMER_EVTS_COMP_BASE 0 #endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ - -#define SW_SWITCH_TIMER_TASK_GROUP_BASE 0 #endif /* !CONFIG_BT_CTLR_TIFS_HW */ static inline void hal_radio_reset(void)