Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dts/arm/st/wba/stm32wba.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,15 @@

bt_hci_wba: bt_hci_wba {
compatible = "st,hci-stm32wba";
interrupt-parent = <&nvic>;
interrupt-names = "radio", "radio-sw-low";
status = "okay";
};

ieee802154: ieee802154 {
compatible = "st,stm32wba-ieee802154";
interrupt-parent = <&nvic>;
interrupt-names = "radio", "radio-sw-low";
status = "disabled";
};

Expand Down
10 changes: 10 additions & 0 deletions dts/arm/st/wba/stm32wba23.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#define FLASH_LAYOUT_STM32WBA2X /* see stm32wba.dtsi */
#include <st/wba/stm32wba.dtsi>

#define STM32WBA_WIRELESS_INTERRUPTS <60 0>, <55 14>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid this, it doesn't add much to readability

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose to have this STM32WBA_WIRELESS_INTERRUPTS is to be sure that interrupts for the bt_hci_wba and the ieee802154 are the same


/ {
soc {
compatible = "st,stm32wba23", "st,stm32wba", "simple-bus";
Expand Down Expand Up @@ -71,3 +73,11 @@
};
};
};

&bt_hci_wba {
interrupts = STM32WBA_WIRELESS_INTERRUPTS;
};

&ieee802154 {
interrupts = STM32WBA_WIRELESS_INTERRUPTS;
};
Comment on lines +76 to +83
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with remaining part of the file, can you follow the syntax used above:


	bt_hci_wba: bt_hci_wba {
		interrupts = .....
	};

	ieee802154: ieee802154 {
		interrupts = ....
	};
};

10 changes: 10 additions & 0 deletions dts/arm/st/wba/stm32wba52.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
#include <st/wba/stm32wba.dtsi>

#define STM32WBA_WIRELESS_INTERRUPTS <66 0>, <61 14>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


/ {
soc {
compatible = "st,stm32wba52", "st,stm32wba", "simple-bus";
Expand Down Expand Up @@ -98,3 +100,11 @@
};
};
};

&bt_hci_wba {
interrupts = STM32WBA_WIRELESS_INTERRUPTS;
};

&ieee802154 {
interrupts = STM32WBA_WIRELESS_INTERRUPTS;
};
Comment on lines +103 to +110
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

81 changes: 50 additions & 31 deletions soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/devicetree.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/entropy.h>
#include <zephyr/logging/log.h>
Expand All @@ -16,8 +17,26 @@
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
LOG_MODULE_REGISTER(linklayer_plat_adapt);

#define RADIO_INTR_PRIO_HIGH_Z (RADIO_INTR_PRIO_HIGH + _IRQ_PRIO_OFFSET)
#define RADIO_INTR_PRIO_LOW_Z (RADIO_INTR_PRIO_LOW + _IRQ_PRIO_OFFSET)
#define BT_HCI_WBA_NODE DT_NODELABEL(bt_hci_wba)

#if DT_IRQ_HAS_NAME(BT_HCI_WBA_NODE, radio)
#define STM32WBA_RADIO_IRQ_NUM DT_IRQ_BY_NAME(BT_HCI_WBA_NODE, radio, irq)
#define STM32WBA_RADIO_INTR_PRIO_HIGH DT_IRQ_BY_NAME(BT_HCI_WBA_NODE, radio, priority)
#else
#define STM32WBA_RADIO_IRQ_NUM RADIO_INTR_NUM
#define STM32WBA_RADIO_INTR_PRIO_HIGH RADIO_INTR_PRIO_HIGH
#endif

#if DT_IRQ_HAS_NAME(BT_HCI_WBA_NODE, radio_sw_low)
#define STM32WBA_RADIO_SW_LOW_IRQ_NUM DT_IRQ_BY_NAME(BT_HCI_WBA_NODE, radio_sw_low, irq)
#define STM32WBA_RADIO_SW_LOW_INTR_PRIO DT_IRQ_BY_NAME(BT_HCI_WBA_NODE, radio_sw_low, priority)
#else
#define STM32WBA_RADIO_SW_LOW_IRQ_NUM RADIO_SW_LOW_INTR_NUM
#define STM32WBA_RADIO_SW_LOW_INTR_PRIO RADIO_SW_LOW_INTR_PRIO
#endif

#define STM32WBA_RADIO_INTR_PRIO_HIGH_Z (STM32WBA_RADIO_INTR_PRIO_HIGH + _IRQ_PRIO_OFFSET)
#define STM32WBA_RADIO_INTR_PRIO_LOW_Z (RADIO_INTR_PRIO_LOW + _IRQ_PRIO_OFFSET)

/* 2.4GHz RADIO ISR callbacks */
typedef void (*radio_isr_cb_t) (void);
Expand Down Expand Up @@ -78,18 +97,18 @@ void radio_high_prio_isr(void)

void radio_low_prio_isr(void)
{
irq_disable(RADIO_SW_LOW_INTR_NUM);
irq_disable(STM32WBA_RADIO_SW_LOW_IRQ_NUM);

low_isr_callback();

/* Check if nested SW radio low interrupt has been requested*/
if (radio_sw_low_isr_is_running_high_prio != 0) {
NVIC_SetPriority((IRQn_Type) RADIO_SW_LOW_INTR_NUM, RADIO_INTR_PRIO_LOW);
NVIC_SetPriority((IRQn_Type)STM32WBA_RADIO_SW_LOW_IRQ_NUM, RADIO_INTR_PRIO_LOW);
radio_sw_low_isr_is_running_high_prio = 0;
}

/* Re-enable SW radio low interrupt */
irq_enable(RADIO_SW_LOW_INTR_NUM);
irq_enable(STM32WBA_RADIO_SW_LOW_IRQ_NUM);

ISR_DIRECT_PM();
}
Expand All @@ -104,64 +123,64 @@ void link_layer_register_isr(bool force)
}
is_isr_registered = true;

ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_INTR_NUM, 0, 0, reschedule);
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(STM32WBA_RADIO_IRQ_NUM, 0, 0, reschedule);

/* Ensure the IRQ is disabled before enabling it at run time */
irq_disable(RADIO_INTR_NUM);
irq_disable(STM32WBA_RADIO_IRQ_NUM);

irq_connect_dynamic(RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z,
irq_connect_dynamic(STM32WBA_RADIO_IRQ_NUM, STM32WBA_RADIO_INTR_PRIO_HIGH_Z,
(void (*)(const void *))radio_high_prio_isr, NULL, 0);

irq_enable(RADIO_INTR_NUM);
irq_enable(STM32WBA_RADIO_IRQ_NUM);

ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_SW_LOW_INTR_NUM, 0, 0, reschedule);
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(STM32WBA_RADIO_SW_LOW_IRQ_NUM, 0, 0, reschedule);

/* Ensure the IRQ is disabled before enabling it at run time */
irq_disable(RADIO_SW_LOW_INTR_NUM);
irq_disable(STM32WBA_RADIO_SW_LOW_IRQ_NUM);

irq_connect_dynamic(RADIO_SW_LOW_INTR_NUM, RADIO_SW_LOW_INTR_PRIO,
irq_connect_dynamic(STM32WBA_RADIO_SW_LOW_IRQ_NUM, STM32WBA_RADIO_SW_LOW_INTR_PRIO,
(void (*)(const void *))radio_low_prio_isr, NULL, 0);

irq_enable(RADIO_SW_LOW_INTR_NUM);
irq_enable(STM32WBA_RADIO_SW_LOW_IRQ_NUM);
}

void link_layer_disable_isr(void)
{
irq_disable(RADIO_INTR_NUM);
irq_disable(STM32WBA_RADIO_IRQ_NUM);

irq_disable(RADIO_SW_LOW_INTR_NUM);
irq_disable(STM32WBA_RADIO_SW_LOW_IRQ_NUM);

local_basepri_value = __get_BASEPRI();
__set_BASEPRI_MAX(RADIO_INTR_PRIO_LOW_Z << 4);
__set_BASEPRI_MAX(STM32WBA_RADIO_INTR_PRIO_LOW_Z << 4);
}

void LINKLAYER_PLAT_TriggerSwLowIT(uint8_t priority)
{
uint8_t low_isr_priority = RADIO_INTR_PRIO_LOW_Z;
uint8_t low_isr_priority = STM32WBA_RADIO_INTR_PRIO_LOW_Z;

LOG_DBG("Priority: %d", priority);

/* Check if a SW low interrupt as already been raised.
* Nested call far radio low isr are not supported
**/
if (NVIC_GetActive((IRQn_Type)RADIO_SW_LOW_INTR_NUM) == 0) {
if (NVIC_GetActive((IRQn_Type)STM32WBA_RADIO_SW_LOW_IRQ_NUM) == 0) {
/* No nested SW low ISR, default behavior */
if (priority == 0) {
low_isr_priority = RADIO_SW_LOW_INTR_PRIO;
low_isr_priority = STM32WBA_RADIO_SW_LOW_INTR_PRIO;
}
NVIC_SetPriority((IRQn_Type)RADIO_SW_LOW_INTR_NUM, low_isr_priority);
NVIC_SetPriority((IRQn_Type)STM32WBA_RADIO_SW_LOW_IRQ_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
* low interrupt will run with STM32WBA_RADIO_INTR_PRIO_LOW_Z priority
**/
radio_sw_low_isr_is_running_high_prio = 1;
}
}

NVIC_SetPendingIRQ((IRQn_Type)RADIO_SW_LOW_INTR_NUM);
NVIC_SetPendingIRQ((IRQn_Type)STM32WBA_RADIO_SW_LOW_IRQ_NUM);
}

void LINKLAYER_PLAT_Assert(uint8_t condition)
Expand Down Expand Up @@ -197,14 +216,14 @@ void LINKLAYER_PLAT_EnableSpecificIRQ(uint8_t isr_type)
if ((isr_type & LL_HIGH_ISR_ONLY) != 0) {
prio_high_isr_counter--;
if (prio_high_isr_counter == 0) {
irq_enable(RADIO_INTR_NUM);
irq_enable(STM32WBA_RADIO_IRQ_NUM);
}
}

if ((isr_type & LL_LOW_ISR_ONLY) != 0) {
prio_low_isr_counter--;
if (prio_low_isr_counter == 0) {
irq_enable(RADIO_SW_LOW_INTR_NUM);
irq_enable(STM32WBA_RADIO_SW_LOW_IRQ_NUM);
}
}

Expand All @@ -224,50 +243,50 @@ void LINKLAYER_PLAT_DisableSpecificIRQ(uint8_t isr_type)
if ((isr_type & LL_HIGH_ISR_ONLY) != 0) {
prio_high_isr_counter++;
if (prio_high_isr_counter == 1) {
irq_disable(RADIO_INTR_NUM);
irq_disable(STM32WBA_RADIO_IRQ_NUM);
}
}

if ((isr_type & LL_LOW_ISR_ONLY) != 0) {
prio_low_isr_counter++;
if (prio_low_isr_counter == 1) {
irq_disable(RADIO_SW_LOW_INTR_NUM);
irq_disable(STM32WBA_RADIO_SW_LOW_IRQ_NUM);
}
}

if ((isr_type & SYS_LOW_ISR) != 0) {
prio_sys_isr_counter++;
if (prio_sys_isr_counter == 1) {
local_basepri_value = __get_BASEPRI();
__set_BASEPRI_MAX(RADIO_INTR_PRIO_LOW_Z << 4);
__set_BASEPRI_MAX(STM32WBA_RADIO_INTR_PRIO_LOW_Z << 4);
}
}
}

void LINKLAYER_PLAT_EnableRadioIT(void)
{
LOG_DBG("Enable RADIO IRQ");
irq_enable(RADIO_INTR_NUM);
irq_enable(STM32WBA_RADIO_IRQ_NUM);
}

void LINKLAYER_PLAT_DisableRadioIT(void)
{
LOG_DBG("Disable RADIO IRQ");
irq_disable(RADIO_INTR_NUM);
irq_disable(STM32WBA_RADIO_IRQ_NUM);
}

void LINKLAYER_PLAT_StartRadioEvt(void)
{
__HAL_RCC_RADIO_CLK_SLEEP_ENABLE();

NVIC_SetPriority((IRQn_Type)RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH_Z);
NVIC_SetPriority((IRQn_Type)STM32WBA_RADIO_IRQ_NUM, STM32WBA_RADIO_INTR_PRIO_HIGH_Z);
}

void LINKLAYER_PLAT_StopRadioEvt(void)
{
__HAL_RCC_RADIO_CLK_SLEEP_DISABLE();

NVIC_SetPriority((IRQn_Type)RADIO_INTR_NUM, RADIO_INTR_PRIO_LOW_Z);
NVIC_SetPriority((IRQn_Type)STM32WBA_RADIO_IRQ_NUM, STM32WBA_RADIO_INTR_PRIO_LOW_Z);
}

/* Link Layer notification for RCO calibration start */
Expand Down
Loading