diff --git a/subsys/bluetooth/controller/hal/swi.h b/subsys/bluetooth/controller/hal/swi.h new file mode 100644 index 0000000000..2c5762bbb3 --- /dev/null +++ b/subsys/bluetooth/controller/hal/swi.h @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2019 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "hal/swi_vendor_hal.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/irq_vendor_hal.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/irq_vendor_hal.h deleted file mode 100644 index de13525f2d..0000000000 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/irq_vendor_hal.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright (c) 2018 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "hal/nrf5/nrf5_sw_irqs.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c index 44f457c2bb..ee50a953dc 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/mayfly.c @@ -8,13 +8,14 @@ #include #include +#include "hal/nrf5/swi.h" + #include "util/memq.h" #include "util/mayfly.h" #define LOG_MODULE_NAME bt_ctlr_nrf5_mayfly #include "common/log.h" #include "hal/debug.h" -#include "hal/nrf5/nrf5_sw_irqs.h" #if defined(CONFIG_BT_LL_SW_LEGACY) #define MAYFLY_CALL_ID_WORKER MAYFLY_CALL_ID_0 @@ -35,9 +36,9 @@ void mayfly_enable_cb(u8_t caller_id, u8_t callee_id, u8_t enable) LL_ASSERT(callee_id == MAYFLY_CALL_ID_JOB); if (enable) { - irq_enable(HAL_RADIO_SW_IRQ); + irq_enable(HAL_SWI_JOB_IRQ); } else { - irq_disable(HAL_RADIO_SW_IRQ); + irq_disable(HAL_SWI_JOB_IRQ); } } @@ -48,14 +49,14 @@ u32_t mayfly_is_enabled(u8_t caller_id, u8_t callee_id) switch (callee_id) { #if defined(CONFIG_BT_LL_SW_SPLIT) case MAYFLY_CALL_ID_LLL: - return irq_is_enabled(HAL_RADIO_LLL_IRQ); + return irq_is_enabled(HAL_SWI_RADIO_IRQ); #endif /* CONFIG_BT_LL_SW_SPLIT */ case MAYFLY_CALL_ID_WORKER: - return irq_is_enabled(RTC0_IRQn); + return irq_is_enabled(HAL_SWI_WORKER_IRQ); case MAYFLY_CALL_ID_JOB: - return irq_is_enabled(HAL_RADIO_SW_IRQ); + return irq_is_enabled(HAL_SWI_JOB_IRQ); default: LL_ASSERT(0); @@ -105,16 +106,16 @@ void mayfly_pend(u8_t caller_id, u8_t callee_id) switch (callee_id) { #if defined(CONFIG_BT_LL_SW_SPLIT) case MAYFLY_CALL_ID_LLL: - hal_nrf5_pend_lll_irq(); + hal_swi_lll_pend(); break; #endif /* CONFIG_BT_LL_SW_SPLIT */ case MAYFLY_CALL_ID_WORKER: - NVIC_SetPendingIRQ(RTC0_IRQn); + hal_swi_worker_pend(); break; case MAYFLY_CALL_ID_JOB: - hal_nrf5_pend_job_irq(); + hal_swi_job_pend(); break; default: diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/nrf5_sw_irqs.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/nrf5_sw_irqs.h deleted file mode 100644 index 214c6b1be6..0000000000 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/nrf5_sw_irqs.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#if defined(CONFIG_SOC_SERIES_NRF51X) || defined(CONFIG_SOC_COMPATIBLE_NRF52X) - -static inline void hal_nrf5_irq_init(void) -{ - /* No platform-specific initialization required. */ -} - -/* SW IRQs required for the nRF5 BLE Controller (Split Architecture). */ -#if defined(CONFIG_BT_LL_SW_SPLIT) -#define HAL_RADIO_LLL_IRQ NRF5_IRQ_SWI4_IRQn -#define HAL_RADIO_ULL_LOW_IRQ NRF5_IRQ_SWI5_IRQn - -#define HAL_RADIO_SW_IRQ HAL_RADIO_ULL_LOW_IRQ - -static inline void hal_nrf5_pend_lll_irq(void) -{ - NVIC_SetPendingIRQ(HAL_RADIO_LLL_IRQ); -} - -#elif defined(CONFIG_BT_LL_SW_LEGACY) -/* A single SW IRQ is required for the nRF Legacy BLE Controller. */ -#define HAL_RADIO_SW_IRQ NRF5_IRQ_SWI5_IRQn - -#else -#error "CTRL architecture not defined" -#endif - -static inline void hal_nrf5_pend_job_irq(void) -{ - NVIC_SetPendingIRQ(HAL_RADIO_SW_IRQ); -} - -#endif /* CONFIG_SOC_SERIES_NRF51X || CONFIG_SOC_COMPATIBLE_NRF52X */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/swi.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/swi.h new file mode 100644 index 0000000000..e3505762e6 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/swi.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#if defined(CONFIG_SOC_SERIES_NRF51X) || defined(CONFIG_SOC_COMPATIBLE_NRF52X) + +static inline void hal_swi_init(void) +{ + /* No platform-specific initialization required. */ +} + +/* SW IRQs required for the nRF5 BLE Controller. */ +#if defined(CONFIG_BT_LL_SW_SPLIT) +/* Split architecture uses max. two SWI */ +#define HAL_SWI_RADIO_IRQ NRF5_IRQ_SWI4_IRQn +#define HAL_SWI_WORKER_IRQ NRF5_IRQ_RTC0_IRQn + +#if (CONFIG_BT_CTLR_ULL_HIGH_PRIO == CONFIG_BT_CTLR_ULL_LOW_PRIO) +#define HAL_SWI_JOB_IRQ HAL_SWI_WORKER_IRQ +#else +#define HAL_SWI_JOB_IRQ NRF5_IRQ_SWI5_IRQn +#endif + +static inline void hal_swi_lll_pend(void) +{ + NVIC_SetPendingIRQ(HAL_SWI_RADIO_IRQ); +} + +#elif defined(CONFIG_BT_LL_SW_LEGACY) +/* Legacy controller uses max. one SWI */ +#define HAL_SWI_WORKER_IRQ NRF5_IRQ_RTC0_IRQn +#define HAL_SWI_JOB_IRQ NRF5_IRQ_SWI5_IRQn + +#else +#error "CTRL architecture not defined" +#endif + +static inline void hal_swi_worker_pend(void) +{ + NVIC_SetPendingIRQ(HAL_SWI_WORKER_IRQ); +} + +static inline void hal_swi_job_pend(void) +{ + NVIC_SetPendingIRQ(HAL_SWI_JOB_IRQ); +} + +#endif /* CONFIG_SOC_SERIES_NRF51X || CONFIG_SOC_COMPATIBLE_NRF52X */ diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/swi_vendor_hal.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/swi_vendor_hal.h new file mode 100644 index 0000000000..4ccdfe02d2 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/swi_vendor_hal.h @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2019 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "hal/nrf5/swi.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c index c1f4e65907..1b2585c82b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c @@ -13,10 +13,10 @@ #include +#include "hal/swi.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" -#include "hal/irq_vendor_hal.h" #include "util/mem.h" #include "util/memq.h" @@ -90,10 +90,14 @@ static void rtc0_nrf5_isr(void *arg) mayfly_run(TICKER_USER_ID_ULL_HIGH); +#if (CONFIG_BT_CTLR_ULL_HIGH_PRIO == CONFIG_BT_CTLR_ULL_LOW_PRIO) + mayfly_run(TICKER_USER_ID_ULL_LOW); +#endif + DEBUG_TICKER_ISR(0); } -static void lll_nrf5_isr(void *arg) +static void swi_lll_nrf5_isr(void *arg) { DEBUG_RADIO_ISR(1); @@ -102,7 +106,8 @@ static void lll_nrf5_isr(void *arg) DEBUG_RADIO_ISR(0); } -static void ull_low_nrf5_isr(void *arg) +#if (CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO) +static void swi_ull_low_nrf5_isr(void *arg) { DEBUG_TICKER_JOB(1); @@ -110,6 +115,7 @@ static void ull_low_nrf5_isr(void *arg) DEBUG_TICKER_JOB(0); } +#endif int lll_init(void) { @@ -146,26 +152,26 @@ int lll_init(void) } /* Initialize SW IRQ structure */ - hal_nrf5_irq_init(); + hal_swi_init(); /* Connect ISRs */ IRQ_DIRECT_CONNECT(NRF5_IRQ_RADIO_IRQn, CONFIG_BT_CTLR_LLL_PRIO, radio_nrf5_isr, 0); IRQ_CONNECT(NRF5_IRQ_RTC0_IRQn, CONFIG_BT_CTLR_ULL_HIGH_PRIO, rtc0_nrf5_isr, NULL, 0); -#if HAL_RADIO_LLL_IRQ != HAL_RADIO_ULL_LOW_IRQ - IRQ_CONNECT(HAL_RADIO_LLL_IRQ, CONFIG_BT_CTLR_LLL_PRIO, - lll_nrf5_isr, NULL, 0); - IRQ_CONNECT(HAL_RADIO_ULL_LOW_IRQ, CONFIG_BT_CTLR_ULL_LOW_PRIO, - ull_low_nrf5_isr, NULL, 0); + IRQ_CONNECT(HAL_SWI_RADIO_IRQ, CONFIG_BT_CTLR_LLL_PRIO, + swi_lll_nrf5_isr, NULL, 0); +#if (CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO) + IRQ_CONNECT(HAL_SWI_JOB_IRQ, CONFIG_BT_CTLR_ULL_LOW_PRIO, + swi_ull_low_nrf5_isr, NULL, 0); #endif /* Enable IRQs */ irq_enable(NRF5_IRQ_RADIO_IRQn); irq_enable(NRF5_IRQ_RTC0_IRQn); -#if HAL_RADIO_LLL_IRQ != HAL_RADIO_ULL_LOW_IRQ - irq_enable(HAL_RADIO_LLL_IRQ); - irq_enable(HAL_RADIO_ULL_LOW_IRQ); + irq_enable(HAL_SWI_RADIO_IRQ); +#if (CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO) + irq_enable(HAL_SWI_JOB_IRQ); #endif return 0;