Add rt
feature to HALs, cfg out interrupt handling when not set.
This commit is contained in:
parent
f498c689e7
commit
8c93805ab5
@ -9,12 +9,13 @@ use cortex_m::peripheral::NVIC;
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! interrupt_mod {
|
macro_rules! interrupt_mod {
|
||||||
($($irqs:ident),* $(,)?) => {
|
($($irqs:ident),* $(,)?) => {
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
pub use cortex_m_rt::interrupt;
|
pub use cortex_m_rt::interrupt;
|
||||||
|
|
||||||
/// Interrupt definitions.
|
/// Interrupt definitions.
|
||||||
pub mod interrupt {
|
pub mod interrupt {
|
||||||
pub use embassy_cortex_m::interrupt::{InterruptExt, Priority};
|
pub use embassy_cortex_m::interrupt::{InterruptExt, Priority};
|
||||||
pub use crate::pac::interrupt::*;
|
pub use crate::pac::Interrupt::*;
|
||||||
pub use crate::pac::Interrupt;
|
pub use crate::pac::Interrupt;
|
||||||
|
|
||||||
/// Type-level interrupt infrastructure.
|
/// Type-level interrupt infrastructure.
|
||||||
|
@ -16,7 +16,8 @@ flavors = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [
|
default = ["rt"]
|
||||||
|
rt = [
|
||||||
"nrf52805-pac?/rt",
|
"nrf52805-pac?/rt",
|
||||||
"nrf52810-pac?/rt",
|
"nrf52810-pac?/rt",
|
||||||
"nrf52811-pac?/rt",
|
"nrf52811-pac?/rt",
|
||||||
|
@ -91,18 +91,21 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))]
|
#[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn GPIOTE0() {
|
fn GPIOTE0() {
|
||||||
unsafe { handle_gpiote_interrupt() };
|
unsafe { handle_gpiote_interrupt() };
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))]
|
#[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn GPIOTE1() {
|
fn GPIOTE1() {
|
||||||
unsafe { handle_gpiote_interrupt() };
|
unsafe { handle_gpiote_interrupt() };
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))]
|
#[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn GPIOTE() {
|
fn GPIOTE() {
|
||||||
unsafe { handle_gpiote_interrupt() };
|
unsafe { handle_gpiote_interrupt() };
|
||||||
|
@ -295,6 +295,7 @@ impl Driver for RtcDriver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn RTC1() {
|
fn RTC1() {
|
||||||
DRIVER.on_interrupt()
|
DRIVER.on_interrupt()
|
||||||
|
@ -13,7 +13,8 @@ flavors = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "rp-pac/rt" ]
|
default = [ "rt" ]
|
||||||
|
rt = [ "rp-pac/rt" ]
|
||||||
|
|
||||||
defmt = ["dep:defmt", "embassy-usb-driver?/defmt", "embassy-hal-common/defmt"]
|
defmt = ["dep:defmt", "embassy-usb-driver?/defmt", "embassy-hal-common/defmt"]
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ use crate::interrupt::InterruptExt;
|
|||||||
use crate::pac::dma::vals;
|
use crate::pac::dma::vals;
|
||||||
use crate::{interrupt, pac, peripherals};
|
use crate::{interrupt, pac, peripherals};
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn DMA_IRQ_0() {
|
unsafe fn DMA_IRQ_0() {
|
||||||
let ints0 = pac::DMA.ints0().read().ints0();
|
let ints0 = pac::DMA.ints0().read().ints0();
|
||||||
|
@ -142,6 +142,7 @@ pub(crate) unsafe fn init() {
|
|||||||
interrupt::IO_IRQ_BANK0.enable();
|
interrupt::IO_IRQ_BANK0.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn IO_IRQ_BANK0() {
|
unsafe fn IO_IRQ_BANK0() {
|
||||||
let cpu = SIO.cpuid().read() as usize;
|
let cpu = SIO.cpuid().read() as usize;
|
||||||
|
@ -43,6 +43,7 @@ pub use rp_pac as pac;
|
|||||||
#[cfg(not(feature = "unstable-pac"))]
|
#[cfg(not(feature = "unstable-pac"))]
|
||||||
pub(crate) use rp_pac as pac;
|
pub(crate) use rp_pac as pac;
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
pub use crate::pac::NVIC_PRIO_BITS;
|
pub use crate::pac::NVIC_PRIO_BITS;
|
||||||
|
|
||||||
embassy_cortex_m::interrupt_mod!(
|
embassy_cortex_m::interrupt_mod!(
|
||||||
|
@ -106,6 +106,7 @@ impl<const SIZE: usize> Stack<SIZE> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
#[link_section = ".data.ram_func"]
|
#[link_section = ".data.ram_func"]
|
||||||
unsafe fn SIO_IRQ_PROC1() {
|
unsafe fn SIO_IRQ_PROC1() {
|
||||||
@ -297,6 +298,7 @@ fn fifo_read() -> u32 {
|
|||||||
|
|
||||||
// Pop a value from inter-core FIFO, `wfe` until available
|
// Pop a value from inter-core FIFO, `wfe` until available
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
#[allow(unused)]
|
||||||
fn fifo_read_wfe() -> u32 {
|
fn fifo_read_wfe() -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let sio = pac::SIO;
|
let sio = pac::SIO;
|
||||||
|
@ -85,6 +85,7 @@ const RXNEMPTY_MASK: u32 = 1 << 0;
|
|||||||
const TXNFULL_MASK: u32 = 1 << 4;
|
const TXNFULL_MASK: u32 = 1 << 4;
|
||||||
const SMIRQ_MASK: u32 = 1 << 8;
|
const SMIRQ_MASK: u32 = 1 << 8;
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn PIO0_IRQ_0() {
|
unsafe fn PIO0_IRQ_0() {
|
||||||
use crate::pac;
|
use crate::pac;
|
||||||
@ -97,6 +98,7 @@ unsafe fn PIO0_IRQ_0() {
|
|||||||
pac::PIO0.irqs(0).inte().write_clear(|m| m.0 = ints);
|
pac::PIO0.irqs(0).inte().write_clear(|m| m.0 = ints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn PIO1_IRQ_0() {
|
unsafe fn PIO1_IRQ_0() {
|
||||||
use crate::pac;
|
use crate::pac;
|
||||||
|
@ -151,21 +151,25 @@ pub unsafe fn init() {
|
|||||||
interrupt::TIMER_IRQ_3.enable();
|
interrupt::TIMER_IRQ_3.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn TIMER_IRQ_0() {
|
unsafe fn TIMER_IRQ_0() {
|
||||||
DRIVER.check_alarm(0)
|
DRIVER.check_alarm(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn TIMER_IRQ_1() {
|
unsafe fn TIMER_IRQ_1() {
|
||||||
DRIVER.check_alarm(1)
|
DRIVER.check_alarm(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn TIMER_IRQ_2() {
|
unsafe fn TIMER_IRQ_2() {
|
||||||
DRIVER.check_alarm(2)
|
DRIVER.check_alarm(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn TIMER_IRQ_3() {
|
unsafe fn TIMER_IRQ_3() {
|
||||||
DRIVER.check_alarm(3)
|
DRIVER.check_alarm(3)
|
||||||
|
@ -79,7 +79,9 @@ quote = "1.0.15"
|
|||||||
stm32-metapac = { version = "9", default-features = false, features = ["metadata"]}
|
stm32-metapac = { version = "9", default-features = false, features = ["metadata"]}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["stm32-metapac/rt"]
|
default = ["rt"]
|
||||||
|
rt = ["stm32-metapac/rt"]
|
||||||
|
|
||||||
defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-executor/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt", "embedded-io?/defmt", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt"]
|
defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-executor/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt", "embedded-io?/defmt", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt"]
|
||||||
memory-x = ["stm32-metapac/memory-x"]
|
memory-x = ["stm32-metapac/memory-x"]
|
||||||
exti = []
|
exti = []
|
||||||
|
@ -295,6 +295,7 @@ fn main() {
|
|||||||
let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch));
|
let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch));
|
||||||
|
|
||||||
g.extend(quote! {
|
g.extend(quote! {
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[crate::interrupt]
|
#[crate::interrupt]
|
||||||
unsafe fn #irq () {
|
unsafe fn #irq () {
|
||||||
#(
|
#(
|
||||||
|
@ -291,6 +291,7 @@ macro_rules! foreach_exti_irq {
|
|||||||
|
|
||||||
macro_rules! impl_irq {
|
macro_rules! impl_irq {
|
||||||
($e:ident) => {
|
($e:ident) => {
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
unsafe fn $e() {
|
unsafe fn $e() {
|
||||||
on_irq()
|
on_irq()
|
||||||
|
@ -111,6 +111,7 @@ pub use stm32_metapac as pac;
|
|||||||
#[cfg(not(feature = "unstable-pac"))]
|
#[cfg(not(feature = "unstable-pac"))]
|
||||||
pub(crate) use stm32_metapac as pac;
|
pub(crate) use stm32_metapac as pac;
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
pub use crate::pac::NVIC_PRIO_BITS;
|
pub use crate::pac::NVIC_PRIO_BITS;
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
|
@ -149,6 +149,7 @@ foreach_peripheral!(
|
|||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
macro_rules! irq {
|
macro_rules! irq {
|
||||||
($irq:ident) => {
|
($irq:ident) => {
|
||||||
mod rng_irq {
|
mod rng_irq {
|
||||||
@ -166,6 +167,7 @@ macro_rules! irq {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
foreach_interrupt!(
|
foreach_interrupt!(
|
||||||
(RNG) => {
|
(RNG) => {
|
||||||
irq!(RNG);
|
irq!(RNG);
|
||||||
|
@ -40,6 +40,7 @@ type T = peripherals::TIM15;
|
|||||||
foreach_interrupt! {
|
foreach_interrupt! {
|
||||||
(TIM2, timer, $block:ident, UP, $irq:ident) => {
|
(TIM2, timer, $block:ident, UP, $irq:ident) => {
|
||||||
#[cfg(time_driver_tim2)]
|
#[cfg(time_driver_tim2)]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn $irq() {
|
fn $irq() {
|
||||||
DRIVER.on_interrupt()
|
DRIVER.on_interrupt()
|
||||||
@ -47,6 +48,7 @@ foreach_interrupt! {
|
|||||||
};
|
};
|
||||||
(TIM3, timer, $block:ident, UP, $irq:ident) => {
|
(TIM3, timer, $block:ident, UP, $irq:ident) => {
|
||||||
#[cfg(time_driver_tim3)]
|
#[cfg(time_driver_tim3)]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn $irq() {
|
fn $irq() {
|
||||||
DRIVER.on_interrupt()
|
DRIVER.on_interrupt()
|
||||||
@ -54,6 +56,7 @@ foreach_interrupt! {
|
|||||||
};
|
};
|
||||||
(TIM4, timer, $block:ident, UP, $irq:ident) => {
|
(TIM4, timer, $block:ident, UP, $irq:ident) => {
|
||||||
#[cfg(time_driver_tim4)]
|
#[cfg(time_driver_tim4)]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn $irq() {
|
fn $irq() {
|
||||||
DRIVER.on_interrupt()
|
DRIVER.on_interrupt()
|
||||||
@ -61,6 +64,7 @@ foreach_interrupt! {
|
|||||||
};
|
};
|
||||||
(TIM5, timer, $block:ident, UP, $irq:ident) => {
|
(TIM5, timer, $block:ident, UP, $irq:ident) => {
|
||||||
#[cfg(time_driver_tim5)]
|
#[cfg(time_driver_tim5)]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn $irq() {
|
fn $irq() {
|
||||||
DRIVER.on_interrupt()
|
DRIVER.on_interrupt()
|
||||||
@ -68,6 +72,7 @@ foreach_interrupt! {
|
|||||||
};
|
};
|
||||||
(TIM12, timer, $block:ident, UP, $irq:ident) => {
|
(TIM12, timer, $block:ident, UP, $irq:ident) => {
|
||||||
#[cfg(time_driver_tim12)]
|
#[cfg(time_driver_tim12)]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn $irq() {
|
fn $irq() {
|
||||||
DRIVER.on_interrupt()
|
DRIVER.on_interrupt()
|
||||||
@ -75,6 +80,7 @@ foreach_interrupt! {
|
|||||||
};
|
};
|
||||||
(TIM15, timer, $block:ident, UP, $irq:ident) => {
|
(TIM15, timer, $block:ident, UP, $irq:ident) => {
|
||||||
#[cfg(time_driver_tim15)]
|
#[cfg(time_driver_tim15)]
|
||||||
|
#[cfg(feature = "rt")]
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn $irq() {
|
fn $irq() {
|
||||||
DRIVER.on_interrupt()
|
DRIVER.on_interrupt()
|
||||||
|
Loading…
Reference in New Issue
Block a user