Add rt feature to HALs, cfg out interrupt handling when not set.

This commit is contained in:
Dario Nieuwenhuis 2023-06-08 18:00:19 +02:00
parent f498c689e7
commit 8c93805ab5
17 changed files with 35 additions and 4 deletions

View file

@ -9,12 +9,13 @@ use cortex_m::peripheral::NVIC;
#[macro_export]
macro_rules! interrupt_mod {
($($irqs:ident),* $(,)?) => {
#[cfg(feature = "rt")]
pub use cortex_m_rt::interrupt;
/// Interrupt definitions.
pub mod interrupt {
pub use embassy_cortex_m::interrupt::{InterruptExt, Priority};
pub use crate::pac::interrupt::*;
pub use crate::pac::Interrupt::*;
pub use crate::pac::Interrupt;
/// Type-level interrupt infrastructure.

View file

@ -16,7 +16,8 @@ flavors = [
]
[features]
default = [
default = ["rt"]
rt = [
"nrf52805-pac?/rt",
"nrf52810-pac?/rt",
"nrf52811-pac?/rt",

View file

@ -91,18 +91,21 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
}
#[cfg(any(feature = "nrf5340-app-s", feature = "nrf9160-s"))]
#[cfg(feature = "rt")]
#[interrupt]
fn GPIOTE0() {
unsafe { handle_gpiote_interrupt() };
}
#[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))]
#[cfg(feature = "rt")]
#[interrupt]
fn GPIOTE1() {
unsafe { handle_gpiote_interrupt() };
}
#[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))]
#[cfg(feature = "rt")]
#[interrupt]
fn GPIOTE() {
unsafe { handle_gpiote_interrupt() };

View file

@ -295,6 +295,7 @@ impl Driver for RtcDriver {
}
}
#[cfg(feature = "rt")]
#[interrupt]
fn RTC1() {
DRIVER.on_interrupt()

View file

@ -13,7 +13,8 @@ flavors = [
]
[features]
default = [ "rp-pac/rt" ]
default = [ "rt" ]
rt = [ "rp-pac/rt" ]
defmt = ["dep:defmt", "embassy-usb-driver?/defmt", "embassy-hal-common/defmt"]

View file

@ -12,6 +12,7 @@ use crate::interrupt::InterruptExt;
use crate::pac::dma::vals;
use crate::{interrupt, pac, peripherals};
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn DMA_IRQ_0() {
let ints0 = pac::DMA.ints0().read().ints0();

View file

@ -142,6 +142,7 @@ pub(crate) unsafe fn init() {
interrupt::IO_IRQ_BANK0.enable();
}
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn IO_IRQ_BANK0() {
let cpu = SIO.cpuid().read() as usize;

View file

@ -43,6 +43,7 @@ pub use rp_pac as pac;
#[cfg(not(feature = "unstable-pac"))]
pub(crate) use rp_pac as pac;
#[cfg(feature = "rt")]
pub use crate::pac::NVIC_PRIO_BITS;
embassy_cortex_m::interrupt_mod!(

View file

@ -106,6 +106,7 @@ impl<const SIZE: usize> Stack<SIZE> {
}
}
#[cfg(feature = "rt")]
#[interrupt]
#[link_section = ".data.ram_func"]
unsafe fn SIO_IRQ_PROC1() {
@ -297,6 +298,7 @@ fn fifo_read() -> u32 {
// Pop a value from inter-core FIFO, `wfe` until available
#[inline(always)]
#[allow(unused)]
fn fifo_read_wfe() -> u32 {
unsafe {
let sio = pac::SIO;

View file

@ -85,6 +85,7 @@ const RXNEMPTY_MASK: u32 = 1 << 0;
const TXNFULL_MASK: u32 = 1 << 4;
const SMIRQ_MASK: u32 = 1 << 8;
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn PIO0_IRQ_0() {
use crate::pac;
@ -97,6 +98,7 @@ unsafe fn PIO0_IRQ_0() {
pac::PIO0.irqs(0).inte().write_clear(|m| m.0 = ints);
}
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn PIO1_IRQ_0() {
use crate::pac;

View file

@ -151,21 +151,25 @@ pub unsafe fn init() {
interrupt::TIMER_IRQ_3.enable();
}
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn TIMER_IRQ_0() {
DRIVER.check_alarm(0)
}
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn TIMER_IRQ_1() {
DRIVER.check_alarm(1)
}
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn TIMER_IRQ_2() {
DRIVER.check_alarm(2)
}
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn TIMER_IRQ_3() {
DRIVER.check_alarm(3)

View file

@ -79,7 +79,9 @@ quote = "1.0.15"
stm32-metapac = { version = "9", default-features = false, features = ["metadata"]}
[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"]
memory-x = ["stm32-metapac/memory-x"]
exti = []

View file

@ -295,6 +295,7 @@ fn main() {
let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch));
g.extend(quote! {
#[cfg(feature = "rt")]
#[crate::interrupt]
unsafe fn #irq () {
#(

View file

@ -291,6 +291,7 @@ macro_rules! foreach_exti_irq {
macro_rules! impl_irq {
($e:ident) => {
#[cfg(feature = "rt")]
#[interrupt]
unsafe fn $e() {
on_irq()

View file

@ -111,6 +111,7 @@ pub use stm32_metapac as pac;
#[cfg(not(feature = "unstable-pac"))]
pub(crate) use stm32_metapac as pac;
#[cfg(feature = "rt")]
pub use crate::pac::NVIC_PRIO_BITS;
#[non_exhaustive]

View file

@ -149,6 +149,7 @@ foreach_peripheral!(
};
);
#[cfg(feature = "rt")]
macro_rules! irq {
($irq:ident) => {
mod rng_irq {
@ -166,6 +167,7 @@ macro_rules! irq {
};
}
#[cfg(feature = "rt")]
foreach_interrupt!(
(RNG) => {
irq!(RNG);

View file

@ -40,6 +40,7 @@ type T = peripherals::TIM15;
foreach_interrupt! {
(TIM2, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim2)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()
@ -47,6 +48,7 @@ foreach_interrupt! {
};
(TIM3, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim3)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()
@ -54,6 +56,7 @@ foreach_interrupt! {
};
(TIM4, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim4)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()
@ -61,6 +64,7 @@ foreach_interrupt! {
};
(TIM5, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim5)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()
@ -68,6 +72,7 @@ foreach_interrupt! {
};
(TIM12, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim12)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()
@ -75,6 +80,7 @@ foreach_interrupt! {
};
(TIM15, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim15)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()