Skip to content

Commit 03a5e35

Browse files
committed
soc: st: stm32wba: hci_if: allow forcing ISR registration
Add parameter to the link_layer_register_isr() to force or not the link layer isr registration in case of multiple function calls Update Bluetooth hci_stm32wba.c driver and IEEE 802.15.4 ieee802154_stm32wba.c driver accordingly. Signed-off-by: Vincent Tardy <[email protected]>
1 parent 1a49b41 commit 03a5e35

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

drivers/bluetooth/hci/hci_stm32wba.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static int bt_hci_stm32wba_open(const struct device *dev, bt_hci_recv_t recv)
452452
struct hci_data *data = dev->data;
453453
int ret = 0;
454454

455-
link_layer_register_isr();
455+
link_layer_register_isr(false);
456456

457457
ret = bt_ble_ctlr_init();
458458
if (ret == 0) {
@@ -563,7 +563,7 @@ static int radio_pm_action(const struct device *dev, enum pm_device_action actio
563563
#if defined(CONFIG_PM_S2RAM)
564564
if (LL_PWR_IsActiveFlag_SB() == 1U) {
565565
/* Put the radio in active state */
566-
link_layer_register_isr();
566+
link_layer_register_isr(true);
567567
}
568568
#endif /* CONFIG_PM_S2RAM */
569569
LINKLAYER_PLAT_NotifyWFIExit();

drivers/ieee802154/ieee802154_stm32wba.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ static void stm32wba_802154_iface_init(struct net_if *iface)
686686
.stm32wba_802154_ral_cbk_tx_ack_started = stm32wba_802154_tx_ack_started,
687687
};
688688

689-
link_layer_register_isr();
689+
link_layer_register_isr(false);
690690

691691
#if !defined(CONFIG_NET_L2_CUSTOM_IEEE802154_STM32WBA)
692692
ll_sys_thread_init();
@@ -995,7 +995,7 @@ static int radio_pm_action(const struct device *dev, enum pm_device_action actio
995995
if (LL_PWR_IsActiveFlag_SB() == 1U) {
996996
/* Put the radio in active state */
997997
LL_AHB5_GRP1_EnableClock(LL_AHB5_GRP1_PERIPH_RADIO);
998-
link_layer_register_isr();
998+
link_layer_register_isr(true);
999999
}
10001000
LINKLAYER_PLAT_NotifyWFIExit();
10011001
ll_sys_dp_slp_exit();

soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ static uint32_t primask_bit;
3838
/* Radio SW low ISR global variable */
3939
volatile uint8_t radio_sw_low_isr_is_running_high_prio;
4040

41+
/* ISR registration state variable */
42+
static bool is_isr_registered;
4143

4244
void LINKLAYER_PLAT_DelayUs(uint32_t delay)
4345
{
@@ -96,27 +98,33 @@ void radio_low_prio_isr(void)
9698
}
9799

98100

99-
void link_layer_register_isr(void)
101+
void link_layer_register_isr(bool force)
100102
{
101-
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_INTR_NUM, 0, 0, reschedule);
102103

103-
/* Ensure the IRQ is disabled before enabling it at run time */
104-
irq_disable(RADIO_INTR_NUM);
104+
if (force || !is_isr_registered) {
105105

106-
irq_connect_dynamic(RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z,
107-
(void (*)(const void *))radio_high_prio_isr, NULL, 0);
106+
is_isr_registered = true;
108107

109-
irq_enable(RADIO_INTR_NUM);
108+
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_INTR_NUM, 0, 0, reschedule);
110109

111-
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_SW_LOW_INTR_NUM, 0, 0, reschedule);
110+
/* Ensure the IRQ is disabled before enabling it at run time */
111+
irq_disable(RADIO_INTR_NUM);
112112

113-
/* Ensure the IRQ is disabled before enabling it at run time */
114-
irq_disable(RADIO_SW_LOW_INTR_NUM);
113+
irq_connect_dynamic(RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z,
114+
(void (*)(const void *))radio_high_prio_isr, NULL, 0);
115115

116-
irq_connect_dynamic(RADIO_SW_LOW_INTR_NUM, RADIO_SW_LOW_INTR_PRIO,
117-
(void (*)(const void *))radio_low_prio_isr, NULL, 0);
116+
irq_enable(RADIO_INTR_NUM);
118117

119-
irq_enable(RADIO_SW_LOW_INTR_NUM);
118+
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_SW_LOW_INTR_NUM, 0, 0, reschedule);
119+
120+
/* Ensure the IRQ is disabled before enabling it at run time */
121+
irq_disable(RADIO_SW_LOW_INTR_NUM);
122+
123+
irq_connect_dynamic(RADIO_SW_LOW_INTR_NUM, RADIO_SW_LOW_INTR_PRIO,
124+
(void (*)(const void *))radio_low_prio_isr, NULL, 0);
125+
126+
irq_enable(RADIO_SW_LOW_INTR_NUM);
127+
}
120128
}
121129

122130

soc/st/stm32/stm32wbax/hci_if/linklayer_plat_local.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#ifndef _STM32WBA_LINK_LAYER_PLAT_LOCAL_H_
99
#define _STM32WBA_LINK_LAYER_PLAT_LOCAL_H_
1010

11-
void link_layer_register_isr(void);
11+
/*
12+
* @brief Link Layer ISR registration
13+
* @param force: force ISR registration even if already done before
14+
* @retval None
15+
*/
16+
void link_layer_register_isr(bool force);
1217

1318
#endif /* _STM32WBA_LINK_LAYER_PLAT_LOCAL_H_ */

0 commit comments

Comments
 (0)