From b357f81ce9e95387936670f10134ff2c67d5fe06 Mon Sep 17 00:00:00 2001 From: Nidhal BEN OTHMEN Date: Fri, 14 Feb 2025 16:55:29 +0100 Subject: [PATCH] soc: stm32wbax: hci_if: Re-write enable/disable Radio IRQ with irq API Migrate LINKLAYER_PLAT_EnableRadioIT and LINKLAYER_PLAT_DisableRadioIT from linklayer_plat.c (hal/stm32 module) and adapt it using irq Zephyr APIs. Correct casting of irq type between using NVIC APIs or irq Zephyr APIs Signed-off-by: Nidhal BEN OTHMEN --- soc/st/stm32/stm32wbax/hci_if/host_stack_if.c | 8 ++-- .../stm32wbax/hci_if/linklayer_plat_adapt.c | 38 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/soc/st/stm32/stm32wbax/hci_if/host_stack_if.c b/soc/st/stm32/stm32wbax/hci_if/host_stack_if.c index 97479b2eff9..2c9f1e57b2c 100644 --- a/soc/st/stm32/stm32wbax/hci_if/host_stack_if.c +++ b/soc/st/stm32/stm32wbax/hci_if/host_stack_if.c @@ -58,13 +58,13 @@ static int stm32wba_ble_ctrl_init(void) { k_work_queue_init(&ble_ctrl_work_q); k_work_queue_start(&ble_ctrl_work_q, ble_ctrl_work_area, - K_THREAD_STACK_SIZEOF(ble_ctrl_work_area), - BLE_CTRL_THREAD_PRIO, NULL); + K_THREAD_STACK_SIZEOF(ble_ctrl_work_area), + BLE_CTRL_THREAD_PRIO, NULL); k_work_queue_init(&ll_work_q); k_work_queue_start(&ll_work_q, ll_work_area, - K_THREAD_STACK_SIZEOF(ll_work_area), - LL_THREAD_PRIO, NULL); + K_THREAD_STACK_SIZEOF(ll_work_area), + LL_THREAD_PRIO, NULL); k_work_init(&ble_ctrl_stack_work, &ble_ctrl_stack_handler); k_work_init(&bpka_work, &bpka_work_handler); diff --git a/soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c b/soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c index 7731489f317..d446a41d9bf 100644 --- a/soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c +++ b/soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c @@ -74,7 +74,7 @@ void radio_high_prio_isr(void) void radio_low_prio_isr(void) { - irq_disable((IRQn_Type)RADIO_SW_LOW_INTR_NUM); + irq_disable(RADIO_SW_LOW_INTR_NUM); low_isr_callback(); @@ -85,7 +85,7 @@ void radio_low_prio_isr(void) } /* Re-enable SW radio low interrupt */ - irq_enable((IRQn_Type)RADIO_SW_LOW_INTR_NUM); + irq_enable(RADIO_SW_LOW_INTR_NUM); ISR_DIRECT_PM(); } @@ -96,22 +96,22 @@ void link_layer_register_isr(void) ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_INTR_NUM, 0, 0, reschedule); /* Ensure the IRQ is disabled before enabling it at run time */ - irq_disable((IRQn_Type)RADIO_INTR_NUM); + irq_disable(RADIO_INTR_NUM); - irq_connect_dynamic((IRQn_Type)RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z, + irq_connect_dynamic(RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z, (void (*)(const void *))radio_high_prio_isr, NULL, 0); - irq_enable((IRQn_Type)RADIO_INTR_NUM); + irq_enable(RADIO_INTR_NUM); ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_SW_LOW_INTR_NUM, 0, 0, reschedule); /* Ensure the IRQ is disabled before enabling it at run time */ - irq_disable((IRQn_Type)RADIO_SW_LOW_INTR_NUM); + irq_disable(RADIO_SW_LOW_INTR_NUM); - irq_connect_dynamic((IRQn_Type)RADIO_SW_LOW_INTR_NUM, RADIO_SW_LOW_INTR_PRIO, + irq_connect_dynamic(RADIO_SW_LOW_INTR_NUM, RADIO_SW_LOW_INTR_PRIO, (void (*)(const void *))radio_low_prio_isr, NULL, 0); - irq_enable((IRQn_Type)RADIO_SW_LOW_INTR_NUM); + irq_enable(RADIO_SW_LOW_INTR_NUM); } @@ -124,19 +124,15 @@ void LINKLAYER_PLAT_TriggerSwLowIT(uint8_t priority) /* Check if a SW low interrupt as already been raised. * Nested call far radio low isr are not supported **/ - - if (NVIC_GetActive(RADIO_SW_LOW_INTR_NUM) == 0) { + if (NVIC_GetActive((IRQn_Type)RADIO_SW_LOW_INTR_NUM) == 0) { /* No nested SW low ISR, default behavior */ - if (priority == 0) { low_isr_priority = RADIO_SW_LOW_INTR_PRIO; } - NVIC_SetPriority((IRQn_Type)RADIO_SW_LOW_INTR_NUM, low_isr_priority); } else { /* Nested call detected */ /* No change for SW radio low interrupt priority for the moment */ - if (priority != 0) { /* At the end of current SW radio low ISR, this pending SW * low interrupt will run with RADIO_INTR_PRIO_LOW_Z priority @@ -208,11 +204,23 @@ void LINKLAYER_PLAT_DisableSpecificIRQ(uint8_t isr_type) } } +void LINKLAYER_PLAT_EnableRadioIT(void) +{ + LOG_DBG("Enable RADIO IRQ"); + irq_enable(RADIO_INTR_NUM); +} + +void LINKLAYER_PLAT_DisableRadioIT(void) +{ + LOG_DBG("Disable RADIO IRQ"); + irq_disable(RADIO_INTR_NUM); +} + void LINKLAYER_PLAT_StartRadioEvt(void) { __HAL_RCC_RADIO_CLK_SLEEP_ENABLE(); - NVIC_SetPriority(RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z); + NVIC_SetPriority((IRQn_Type)RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z); scm_notifyradiostate(SCM_RADIO_ACTIVE); } @@ -221,7 +229,7 @@ void LINKLAYER_PLAT_StopRadioEvt(void) { __HAL_RCC_RADIO_CLK_SLEEP_DISABLE(); - NVIC_SetPriority(RADIO_INTR_NUM, RADIO_INTR_PRIO_LOW_Z); + NVIC_SetPriority((IRQn_Type)RADIO_INTR_NUM, RADIO_INTR_PRIO_LOW_Z); scm_notifyradiostate(SCM_RADIO_NOT_ACTIVE); }