fix merge conflict
This commit is contained in:
@ -32,11 +32,9 @@ flavors = [
|
||||
|
||||
[dependencies]
|
||||
embassy-sync = { version = "0.2.0", path = "../embassy-sync" }
|
||||
embassy-executor = { version = "0.2.0", path = "../embassy-executor" }
|
||||
embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true }
|
||||
embassy-futures = { version = "0.1.0", path = "../embassy-futures" }
|
||||
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]}
|
||||
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
||||
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common", features = ["cortex-m", "prio-bits-4"] }
|
||||
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
|
||||
embassy-net-driver = { version = "0.1.0", path = "../embassy-net-driver" }
|
||||
embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true }
|
||||
@ -79,8 +77,10 @@ quote = "1.0.15"
|
||||
stm32-metapac = { version = "9", default-features = false, features = ["metadata"]}
|
||||
|
||||
[features]
|
||||
default = ["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"]
|
||||
default = ["rt"]
|
||||
rt = ["stm32-metapac/rt"]
|
||||
|
||||
defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/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 = []
|
||||
|
||||
@ -99,7 +99,7 @@ time-driver-tim12 = ["_time-driver"]
|
||||
time-driver-tim15 = ["_time-driver"]
|
||||
|
||||
# Enable nightly-only features
|
||||
nightly = ["embassy-executor/nightly", "embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io", "dep:embassy-usb-driver", "embassy-embedded-hal/nightly"]
|
||||
nightly = ["embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io", "dep:embassy-usb-driver", "embassy-embedded-hal/nightly"]
|
||||
|
||||
# Reexport stm32-metapac at `embassy_stm32::pac`.
|
||||
# This is unstable because semver-minor (non-breaking) releases of embassy-stm32 may major-bump (breaking) the stm32-metapac version.
|
||||
|
@ -160,13 +160,11 @@ fn main() {
|
||||
}
|
||||
|
||||
g.extend(quote! {
|
||||
pub mod interrupt {
|
||||
use crate::pac::Interrupt as InterruptEnum;
|
||||
use embassy_cortex_m::interrupt::_export::declare;
|
||||
embassy_hal_common::interrupt_mod!(
|
||||
#(
|
||||
declare!(#irqs);
|
||||
#irqs,
|
||||
)*
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// ========
|
||||
@ -297,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 () {
|
||||
#(
|
||||
|
@ -8,7 +8,7 @@ use embassy_sync::waitqueue::AtomicWaker;
|
||||
use crate::dma::Transfer;
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::gpio::Speed;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::{interrupt, Peripheral};
|
||||
|
||||
/// Interrupt handler.
|
||||
@ -16,7 +16,7 @@ pub struct InterruptHandler<T: Instance> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {
|
||||
let ris = crate::pac::DCMI.ris().read();
|
||||
if ris.err_ris() {
|
||||
@ -119,7 +119,7 @@ where
|
||||
pub fn new_8bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -143,7 +143,7 @@ where
|
||||
pub fn new_10bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -169,7 +169,7 @@ where
|
||||
pub fn new_12bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -197,7 +197,7 @@ where
|
||||
pub fn new_14bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -227,7 +227,7 @@ where
|
||||
pub fn new_es_8bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -249,7 +249,7 @@ where
|
||||
pub fn new_es_10bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -273,7 +273,7 @@ where
|
||||
pub fn new_es_12bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -299,7 +299,7 @@ where
|
||||
pub fn new_es_14bit(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
@ -570,7 +570,7 @@ mod sealed {
|
||||
}
|
||||
|
||||
pub trait Instance: sealed::Instance + 'static {
|
||||
type Interrupt: Interrupt;
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
pin_trait!(D0Pin, Instance);
|
||||
@ -602,7 +602,7 @@ macro_rules! impl_peripheral {
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use core::sync::atomic::{fence, Ordering};
|
||||
use core::task::{Context, Poll, Waker};
|
||||
|
||||
use atomic_polyfill::AtomicUsize;
|
||||
use embassy_cortex_m::interrupt::Priority;
|
||||
use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
@ -14,7 +13,8 @@ use super::ringbuffer::{DmaCtrl, DmaRingBuffer, OverrunError};
|
||||
use super::word::{Word, WordSize};
|
||||
use super::Dir;
|
||||
use crate::_generated::BDMA_CHANNEL_COUNT;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::interrupt::Priority;
|
||||
use crate::pac;
|
||||
use crate::pac::bdma::{regs, vals};
|
||||
|
||||
@ -70,8 +70,8 @@ static STATE: State = State::new();
|
||||
pub(crate) unsafe fn init(irq_priority: Priority) {
|
||||
foreach_interrupt! {
|
||||
($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => {
|
||||
crate::interrupt::$irq::set_priority(irq_priority);
|
||||
crate::interrupt::$irq::enable();
|
||||
crate::interrupt::typelevel::$irq::set_priority(irq_priority);
|
||||
crate::interrupt::typelevel::$irq::enable();
|
||||
};
|
||||
}
|
||||
crate::_generated::init_bdma();
|
||||
|
@ -5,7 +5,6 @@ use core::sync::atomic::{fence, Ordering};
|
||||
use core::task::{Context, Poll, Waker};
|
||||
|
||||
use atomic_polyfill::AtomicUsize;
|
||||
use embassy_cortex_m::interrupt::Priority;
|
||||
use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
@ -13,7 +12,8 @@ use super::ringbuffer::{DmaCtrl, DmaRingBuffer, OverrunError};
|
||||
use super::word::{Word, WordSize};
|
||||
use super::Dir;
|
||||
use crate::_generated::DMA_CHANNEL_COUNT;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::interrupt::Priority;
|
||||
use crate::pac::dma::{regs, vals};
|
||||
use crate::{interrupt, pac};
|
||||
|
||||
@ -149,8 +149,8 @@ static STATE: State = State::new();
|
||||
pub(crate) unsafe fn init(irq_priority: Priority) {
|
||||
foreach_interrupt! {
|
||||
($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => {
|
||||
interrupt::$irq::set_priority(irq_priority);
|
||||
interrupt::$irq::enable();
|
||||
interrupt::typelevel::$irq::set_priority(irq_priority);
|
||||
interrupt::typelevel::$irq::enable();
|
||||
};
|
||||
}
|
||||
crate::_generated::init_dma();
|
||||
|
@ -5,14 +5,14 @@ use core::pin::Pin;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
use core::task::{Context, Poll};
|
||||
|
||||
use embassy_cortex_m::interrupt::Priority;
|
||||
use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
use super::word::{Word, WordSize};
|
||||
use super::Dir;
|
||||
use crate::_generated::GPDMA_CHANNEL_COUNT;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::interrupt::Priority;
|
||||
use crate::pac;
|
||||
use crate::pac::gpdma::vals;
|
||||
|
||||
@ -56,8 +56,8 @@ static STATE: State = State::new();
|
||||
pub(crate) unsafe fn init(irq_priority: Priority) {
|
||||
foreach_interrupt! {
|
||||
($peri:ident, gpdma, $block:ident, $signal_name:ident, $irq:ident) => {
|
||||
crate::interrupt::$irq::set_priority(irq_priority);
|
||||
crate::interrupt::$irq::enable();
|
||||
crate::interrupt::typelevel::$irq::set_priority(irq_priority);
|
||||
crate::interrupt::typelevel::$irq::enable();
|
||||
};
|
||||
}
|
||||
crate::_generated::init_gpdma();
|
||||
|
@ -26,11 +26,11 @@ pub mod word;
|
||||
|
||||
use core::mem;
|
||||
|
||||
use embassy_cortex_m::interrupt::Priority;
|
||||
use embassy_hal_common::impl_peripheral;
|
||||
|
||||
#[cfg(dmamux)]
|
||||
pub use self::dmamux::*;
|
||||
use crate::interrupt::Priority;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
|
@ -5,7 +5,6 @@ mod tx_desc;
|
||||
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
use stm32_metapac::eth::vals::{Apcs, Cr, Dm, DmaomrSr, Fes, Ftf, Ifg, MbProgress, Mw, Pbl, Rsf, St, Tsf};
|
||||
|
||||
@ -14,6 +13,7 @@ pub(crate) use self::tx_desc::{TDes, TDesRing};
|
||||
use super::*;
|
||||
use crate::gpio::sealed::{AFType, Pin as __GpioPin};
|
||||
use crate::gpio::AnyPin;
|
||||
use crate::interrupt::InterruptExt;
|
||||
#[cfg(eth_v1a)]
|
||||
use crate::pac::AFIO;
|
||||
#[cfg(any(eth_v1b, eth_v1c))]
|
||||
@ -24,7 +24,7 @@ use crate::{interrupt, Peripheral};
|
||||
/// Interrupt handler.
|
||||
pub struct InterruptHandler {}
|
||||
|
||||
impl interrupt::Handler<interrupt::ETH> for InterruptHandler {
|
||||
impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandler {
|
||||
unsafe fn on_interrupt() {
|
||||
WAKER.wake();
|
||||
|
||||
@ -100,7 +100,7 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> {
|
||||
pub fn new<const TX: usize, const RX: usize>(
|
||||
queue: &'d mut PacketQueue<TX, RX>,
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<interrupt::ETH, InterruptHandler> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<interrupt::typelevel::ETH, InterruptHandler> + 'd,
|
||||
ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd,
|
||||
mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd,
|
||||
mdc: impl Peripheral<P = impl MDCPin<T>> + 'd,
|
||||
@ -267,8 +267,8 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> {
|
||||
P::phy_reset(&mut this);
|
||||
P::phy_init(&mut this);
|
||||
|
||||
interrupt::ETH::unpend();
|
||||
interrupt::ETH::enable();
|
||||
interrupt::ETH.unpend();
|
||||
interrupt::ETH.enable();
|
||||
|
||||
this
|
||||
}
|
||||
|
@ -2,20 +2,20 @@ mod descriptors;
|
||||
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
|
||||
pub(crate) use self::descriptors::{RDes, RDesRing, TDes, TDesRing};
|
||||
use super::*;
|
||||
use crate::gpio::sealed::{AFType, Pin as _};
|
||||
use crate::gpio::{AnyPin, Speed};
|
||||
use crate::interrupt::InterruptExt;
|
||||
use crate::pac::ETH;
|
||||
use crate::{interrupt, Peripheral};
|
||||
|
||||
/// Interrupt handler.
|
||||
pub struct InterruptHandler {}
|
||||
|
||||
impl interrupt::Handler<interrupt::ETH> for InterruptHandler {
|
||||
impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandler {
|
||||
unsafe fn on_interrupt() {
|
||||
WAKER.wake();
|
||||
|
||||
@ -64,7 +64,7 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> {
|
||||
pub fn new<const TX: usize, const RX: usize>(
|
||||
queue: &'d mut PacketQueue<TX, RX>,
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<interrupt::ETH, InterruptHandler> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<interrupt::typelevel::ETH, InterruptHandler> + 'd,
|
||||
ref_clk: impl Peripheral<P = impl RefClkPin<T>> + 'd,
|
||||
mdio: impl Peripheral<P = impl MDIOPin<T>> + 'd,
|
||||
mdc: impl Peripheral<P = impl MDCPin<T>> + 'd,
|
||||
@ -238,8 +238,8 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> {
|
||||
P::phy_reset(&mut this);
|
||||
P::phy_init(&mut this);
|
||||
|
||||
interrupt::ETH::unpend();
|
||||
interrupt::ETH::enable();
|
||||
interrupt::ETH.unpend();
|
||||
interrupt::ETH.enable();
|
||||
|
||||
this
|
||||
}
|
||||
|
@ -291,6 +291,7 @@ macro_rules! foreach_exti_irq {
|
||||
|
||||
macro_rules! impl_irq {
|
||||
($e:ident) => {
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
unsafe fn $e() {
|
||||
on_irq()
|
||||
@ -354,13 +355,13 @@ impl_exti!(EXTI15, 15);
|
||||
|
||||
macro_rules! enable_irq {
|
||||
($e:ident) => {
|
||||
crate::interrupt::$e::enable();
|
||||
crate::interrupt::typelevel::$e::enable();
|
||||
};
|
||||
}
|
||||
|
||||
/// safety: must be called only once
|
||||
pub(crate) unsafe fn init() {
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
|
||||
foreach_exti_irq!(enable_irq);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use atomic_polyfill::{fence, Ordering};
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
use embassy_hal_common::drop::OnDrop;
|
||||
use embassy_hal_common::into_ref;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
@ -11,6 +10,7 @@ use super::{
|
||||
blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE,
|
||||
WRITE_SIZE,
|
||||
};
|
||||
use crate::interrupt::InterruptExt;
|
||||
use crate::peripherals::FLASH;
|
||||
use crate::{interrupt, Peripheral};
|
||||
|
||||
@ -19,12 +19,12 @@ pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new
|
||||
impl<'d> Flash<'d, Async> {
|
||||
pub fn new(
|
||||
p: impl Peripheral<P = FLASH> + 'd,
|
||||
_irq: impl interrupt::Binding<crate::interrupt::FLASH, InterruptHandler> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<crate::interrupt::typelevel::FLASH, InterruptHandler> + 'd,
|
||||
) -> Self {
|
||||
into_ref!(p);
|
||||
|
||||
crate::interrupt::FLASH::unpend();
|
||||
unsafe { crate::interrupt::FLASH::enable() };
|
||||
crate::interrupt::FLASH.unpend();
|
||||
unsafe { crate::interrupt::FLASH.enable() };
|
||||
|
||||
Self {
|
||||
inner: p,
|
||||
@ -49,7 +49,7 @@ impl<'d> Flash<'d, Async> {
|
||||
/// Interrupt handler
|
||||
pub struct InterruptHandler;
|
||||
|
||||
impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler {
|
||||
impl interrupt::typelevel::Handler<crate::interrupt::typelevel::FLASH> for InterruptHandler {
|
||||
unsafe fn on_interrupt() {
|
||||
family::on_interrupt();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![macro_use]
|
||||
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt;
|
||||
|
||||
#[cfg_attr(i2c_v1, path = "v1.rs")]
|
||||
#[cfg_attr(i2c_v2, path = "v2.rs")]
|
||||
@ -35,7 +35,7 @@ pub(crate) mod sealed {
|
||||
}
|
||||
|
||||
pub trait Instance: sealed::Instance + 'static {
|
||||
type Interrupt: Interrupt;
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
pin_trait!(SclPin, Instance);
|
||||
@ -57,7 +57,7 @@ foreach_interrupt!(
|
||||
}
|
||||
|
||||
impl Instance for peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
);
|
||||
|
@ -16,7 +16,7 @@ pub struct InterruptHandler<T: Instance> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||
_peri: impl Peripheral<P = T> + 'd,
|
||||
scl: impl Peripheral<P = impl SclPin<T>> + 'd,
|
||||
sda: impl Peripheral<P = impl SdaPin<T>> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
tx_dma: impl Peripheral<P = TXDMA> + 'd,
|
||||
rx_dma: impl Peripheral<P = RXDMA> + 'd,
|
||||
freq: Hertz,
|
||||
|
@ -3,7 +3,6 @@ use core::future::poll_fn;
|
||||
use core::marker::PhantomData;
|
||||
use core::task::Poll;
|
||||
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
use embassy_embedded_hal::SetConfig;
|
||||
use embassy_hal_common::drop::OnDrop;
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
@ -13,6 +12,7 @@ use crate::dma::{NoDma, Transfer};
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::gpio::Pull;
|
||||
use crate::i2c::{Error, Instance, SclPin, SdaPin};
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::pac::i2c;
|
||||
use crate::time::Hertz;
|
||||
use crate::{interrupt, Peripheral};
|
||||
@ -22,7 +22,7 @@ pub struct InterruptHandler<T: Instance> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {
|
||||
let regs = T::regs();
|
||||
let isr = regs.isr().read();
|
||||
@ -78,7 +78,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
scl: impl Peripheral<P = impl SclPin<T>> + 'd,
|
||||
sda: impl Peripheral<P = impl SdaPin<T>> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
tx_dma: impl Peripheral<P = TXDMA> + 'd,
|
||||
rx_dma: impl Peripheral<P = RXDMA> + 'd,
|
||||
freq: Hertz,
|
||||
|
@ -72,52 +72,47 @@ pub(crate) mod _generated {
|
||||
include!(concat!(env!("OUT_DIR"), "/_generated.rs"));
|
||||
}
|
||||
|
||||
pub mod interrupt {
|
||||
//! Interrupt definitions and macros to bind them.
|
||||
pub use cortex_m::interrupt::{CriticalSection, Mutex};
|
||||
pub use embassy_cortex_m::interrupt::{Binding, Handler, Interrupt, Priority};
|
||||
pub use crate::_generated::interrupt;
|
||||
|
||||
pub use crate::_generated::interrupt::*;
|
||||
/// Macro to bind interrupts to handlers.
|
||||
///
|
||||
/// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`)
|
||||
/// and implements the right [`Binding`]s for it. You can pass this struct to drivers to
|
||||
/// prove at compile-time that the right interrupts have been bound.
|
||||
// developer note: this macro can't be in `embassy-hal-common` due to the use of `$crate`.
|
||||
#[macro_export]
|
||||
macro_rules! bind_interrupts {
|
||||
($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => {
|
||||
$vis struct $name;
|
||||
|
||||
/// Macro to bind interrupts to handlers.
|
||||
///
|
||||
/// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`)
|
||||
/// and implements the right [`Binding`]s for it. You can pass this struct to drivers to
|
||||
/// prove at compile-time that the right interrupts have been bound.
|
||||
// developer note: this macro can't be in `embassy-cortex-m` due to the use of `$crate`.
|
||||
#[macro_export]
|
||||
macro_rules! bind_interrupts {
|
||||
($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => {
|
||||
$vis struct $name;
|
||||
$(
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn $irq() {
|
||||
$(
|
||||
<$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt();
|
||||
)*
|
||||
}
|
||||
|
||||
$(
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn $irq() {
|
||||
$(
|
||||
<$handler as $crate::interrupt::Handler<$crate::interrupt::$irq>>::on_interrupt();
|
||||
)*
|
||||
}
|
||||
|
||||
$(
|
||||
unsafe impl $crate::interrupt::Binding<$crate::interrupt::$irq, $handler> for $name {}
|
||||
)*
|
||||
unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {}
|
||||
)*
|
||||
};
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
// Reexports
|
||||
pub use _generated::{peripherals, Peripherals};
|
||||
pub use embassy_cortex_m::executor;
|
||||
use embassy_cortex_m::interrupt::Priority;
|
||||
pub use embassy_cortex_m::interrupt::_export::interrupt;
|
||||
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||
#[cfg(feature = "unstable-pac")]
|
||||
pub use stm32_metapac as pac;
|
||||
#[cfg(not(feature = "unstable-pac"))]
|
||||
pub(crate) use stm32_metapac as pac;
|
||||
|
||||
use crate::interrupt::Priority;
|
||||
#[cfg(feature = "rt")]
|
||||
pub use crate::pac::NVIC_PRIO_BITS;
|
||||
|
||||
#[non_exhaustive]
|
||||
pub struct Config {
|
||||
pub rcc: rcc::Config,
|
||||
|
@ -1,4 +1,6 @@
|
||||
use stm32_metapac::rcc::vals::{Hpre, Ppre, Sw};
|
||||
use stm32_metapac::flash::vals::Latency;
|
||||
use stm32_metapac::rcc::vals::{Hpre, Pllsrc, Ppre, Sw};
|
||||
use stm32_metapac::FLASH;
|
||||
|
||||
use crate::pac::{PWR, RCC};
|
||||
use crate::rcc::{set_freqs, Clocks};
|
||||
@ -15,6 +17,7 @@ pub const LSI_FREQ: Hertz = Hertz(32_000);
|
||||
pub enum ClockSrc {
|
||||
HSE(Hertz),
|
||||
HSI16,
|
||||
PLLCLK(PllSrc, PllM, PllN, PllR),
|
||||
}
|
||||
|
||||
/// AHB prescaler
|
||||
@ -41,6 +44,128 @@ pub enum APBPrescaler {
|
||||
Div16,
|
||||
}
|
||||
|
||||
/// PLL clock input source
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum PllSrc {
|
||||
HSI16,
|
||||
HSE(Hertz),
|
||||
}
|
||||
|
||||
impl Into<Pllsrc> for PllSrc {
|
||||
fn into(self) -> Pllsrc {
|
||||
match self {
|
||||
PllSrc::HSE(..) => Pllsrc::HSE,
|
||||
PllSrc::HSI16 => Pllsrc::HSI16,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum PllR {
|
||||
Div2,
|
||||
Div4,
|
||||
Div6,
|
||||
Div8,
|
||||
}
|
||||
|
||||
impl PllR {
|
||||
pub fn to_div(self) -> u32 {
|
||||
let val: u8 = self.into();
|
||||
(val as u32 + 1) * 2
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PllR> for u8 {
|
||||
fn from(val: PllR) -> u8 {
|
||||
match val {
|
||||
PllR::Div2 => 0b00,
|
||||
PllR::Div4 => 0b01,
|
||||
PllR::Div6 => 0b10,
|
||||
PllR::Div8 => 0b11,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
seq_macro::seq!(N in 8..=127 {
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum PllN {
|
||||
#(
|
||||
Mul~N,
|
||||
)*
|
||||
}
|
||||
|
||||
impl From<PllN> for u8 {
|
||||
fn from(val: PllN) -> u8 {
|
||||
match val {
|
||||
#(
|
||||
PllN::Mul~N => N,
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PllN {
|
||||
pub fn to_mul(self) -> u32 {
|
||||
match self {
|
||||
#(
|
||||
PllN::Mul~N => N,
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Pre-division
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum PllM {
|
||||
Div1,
|
||||
Div2,
|
||||
Div3,
|
||||
Div4,
|
||||
Div5,
|
||||
Div6,
|
||||
Div7,
|
||||
Div8,
|
||||
Div9,
|
||||
Div10,
|
||||
Div11,
|
||||
Div12,
|
||||
Div13,
|
||||
Div14,
|
||||
Div15,
|
||||
Div16,
|
||||
}
|
||||
|
||||
impl PllM {
|
||||
pub fn to_div(self) -> u32 {
|
||||
let val: u8 = self.into();
|
||||
val as u32 + 1
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PllM> for u8 {
|
||||
fn from(val: PllM) -> u8 {
|
||||
match val {
|
||||
PllM::Div1 => 0b0000,
|
||||
PllM::Div2 => 0b0001,
|
||||
PllM::Div3 => 0b0010,
|
||||
PllM::Div4 => 0b0011,
|
||||
PllM::Div5 => 0b0100,
|
||||
PllM::Div6 => 0b0101,
|
||||
PllM::Div7 => 0b0110,
|
||||
PllM::Div8 => 0b0111,
|
||||
PllM::Div9 => 0b1000,
|
||||
PllM::Div10 => 0b1001,
|
||||
PllM::Div11 => 0b1010,
|
||||
PllM::Div12 => 0b1011,
|
||||
PllM::Div13 => 0b1100,
|
||||
PllM::Div14 => 0b1101,
|
||||
PllM::Div15 => 0b1110,
|
||||
PllM::Div16 => 0b1111,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AHBPrescaler {
|
||||
const fn div(self) -> u32 {
|
||||
match self {
|
||||
@ -135,6 +260,76 @@ pub(crate) unsafe fn init(config: Config) {
|
||||
|
||||
(freq.0, Sw::HSE)
|
||||
}
|
||||
ClockSrc::PLLCLK(src, prediv, mul, div) => {
|
||||
let src_freq = match src {
|
||||
PllSrc::HSI16 => {
|
||||
// Enable HSI16 as clock source for PLL
|
||||
RCC.cr().write(|w| w.set_hsion(true));
|
||||
while !RCC.cr().read().hsirdy() {}
|
||||
|
||||
HSI_FREQ.0
|
||||
}
|
||||
PllSrc::HSE(freq) => {
|
||||
// Enable HSE as clock source for PLL
|
||||
RCC.cr().write(|w| w.set_hseon(true));
|
||||
while !RCC.cr().read().hserdy() {}
|
||||
|
||||
freq.0
|
||||
}
|
||||
};
|
||||
|
||||
// Make sure PLL is disabled while we configure it
|
||||
RCC.cr().modify(|w| w.set_pllon(false));
|
||||
while RCC.cr().read().pllrdy() {}
|
||||
|
||||
let freq = src_freq / prediv.to_div() * mul.to_mul() / div.to_div();
|
||||
assert!(freq <= 170_000_000);
|
||||
|
||||
if freq >= 150_000_000 {
|
||||
// Enable Core Boost mode on freq >= 150Mhz ([RM0440] p234)
|
||||
PWR.cr5().modify(|w| w.set_r1mode(false));
|
||||
// Set flash wait state in boost mode based on frequency ([RM0440] p191)
|
||||
if freq <= 36_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS0));
|
||||
} else if freq <= 68_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS1));
|
||||
} else if freq <= 102_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS2));
|
||||
} else if freq <= 136_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS3));
|
||||
} else {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS4));
|
||||
}
|
||||
} else {
|
||||
PWR.cr5().modify(|w| w.set_r1mode(true));
|
||||
// Set flash wait state in normal mode based on frequency ([RM0440] p191)
|
||||
if freq <= 30_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS0));
|
||||
} else if freq <= 60_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS1));
|
||||
} else if freq <= 80_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS2));
|
||||
} else if freq <= 120_000_000 {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS3));
|
||||
} else {
|
||||
FLASH.acr().modify(|w| w.set_latency(Latency::WS4));
|
||||
}
|
||||
}
|
||||
|
||||
RCC.pllcfgr().write(move |w| {
|
||||
w.set_plln(mul.into());
|
||||
w.set_pllm(prediv.into());
|
||||
w.set_pllr(div.into());
|
||||
w.set_pllsrc(src.into());
|
||||
});
|
||||
|
||||
// Enable PLL
|
||||
RCC.cr().modify(|w| w.set_pllon(true));
|
||||
while !RCC.cr().read().pllrdy() {}
|
||||
RCC.pllcfgr().modify(|w| w.set_pllren(true));
|
||||
|
||||
(freq, Sw::PLLRCLK)
|
||||
}
|
||||
};
|
||||
|
||||
RCC.cfgr().modify(|w| {
|
||||
|
@ -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);
|
||||
|
@ -14,7 +14,7 @@ use sdio_host::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CID,
|
||||
use crate::dma::NoDma;
|
||||
use crate::gpio::sealed::{AFType, Pin};
|
||||
use crate::gpio::{AnyPin, Pull, Speed};
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::pac::sdmmc::Sdmmc as RegBlock;
|
||||
use crate::rcc::RccPeripheral;
|
||||
use crate::time::Hertz;
|
||||
@ -42,7 +42,7 @@ impl<T: Instance> InterruptHandler<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {
|
||||
Self::data_interrupts(false);
|
||||
T::state().wake();
|
||||
@ -276,7 +276,7 @@ pub struct Sdmmc<'d, T: Instance, Dma: SdmmcDma<T> = NoDma> {
|
||||
impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> {
|
||||
pub fn new_1bit(
|
||||
sdmmc: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
clk: impl Peripheral<P = impl CkPin<T>> + 'd,
|
||||
cmd: impl Peripheral<P = impl CmdPin<T>> + 'd,
|
||||
@ -310,7 +310,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> {
|
||||
|
||||
pub fn new_4bit(
|
||||
sdmmc: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
clk: impl Peripheral<P = impl CkPin<T>> + 'd,
|
||||
cmd: impl Peripheral<P = impl CmdPin<T>> + 'd,
|
||||
@ -356,7 +356,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T>> Sdmmc<'d, T, Dma> {
|
||||
impl<'d, T: Instance> Sdmmc<'d, T, NoDma> {
|
||||
pub fn new_1bit(
|
||||
sdmmc: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
clk: impl Peripheral<P = impl CkPin<T>> + 'd,
|
||||
cmd: impl Peripheral<P = impl CmdPin<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
@ -389,7 +389,7 @@ impl<'d, T: Instance> Sdmmc<'d, T, NoDma> {
|
||||
|
||||
pub fn new_4bit(
|
||||
sdmmc: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
clk: impl Peripheral<P = impl CkPin<T>> + 'd,
|
||||
cmd: impl Peripheral<P = impl CmdPin<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
@ -1401,7 +1401,7 @@ pub(crate) mod sealed {
|
||||
use super::*;
|
||||
|
||||
pub trait Instance {
|
||||
type Interrupt: Interrupt;
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
|
||||
fn regs() -> RegBlock;
|
||||
fn state() -> &'static AtomicWaker;
|
||||
@ -1490,7 +1490,7 @@ cfg_if::cfg_if! {
|
||||
foreach_peripheral!(
|
||||
(sdmmc, $inst:ident) => {
|
||||
impl sealed::Instance for peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::$inst;
|
||||
type Interrupt = crate::interrupt::typelevel::$inst;
|
||||
|
||||
fn regs() -> RegBlock {
|
||||
crate::pac::$inst
|
||||
|
@ -11,7 +11,7 @@ use embassy_time::driver::{AlarmHandle, Driver};
|
||||
use embassy_time::TICK_HZ;
|
||||
use stm32_metapac::timer::regs;
|
||||
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::pac::timer::vals;
|
||||
use crate::rcc::sealed::RccPeripheral;
|
||||
use crate::timer::sealed::{Basic16bitInstance as BasicInstance, GeneralPurpose16bitInstance as Instance};
|
||||
@ -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()
|
||||
|
@ -1,6 +1,6 @@
|
||||
use stm32_metapac::timer::vals;
|
||||
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt;
|
||||
use crate::rcc::sealed::RccPeripheral as __RccPeri;
|
||||
use crate::rcc::RccPeripheral;
|
||||
use crate::time::Hertz;
|
||||
@ -13,7 +13,7 @@ pub mod low_level {
|
||||
pub(crate) mod sealed {
|
||||
use super::*;
|
||||
pub trait Basic16bitInstance: RccPeripheral {
|
||||
type Interrupt: Interrupt;
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
|
||||
fn regs() -> crate::pac::timer::TimBasic;
|
||||
|
||||
@ -57,7 +57,7 @@ pub trait Basic16bitInstance: sealed::Basic16bitInstance + 'static {}
|
||||
macro_rules! impl_basic_16bit_timer {
|
||||
($inst:ident, $irq:ident) => {
|
||||
impl sealed::Basic16bitInstance for crate::peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
|
||||
fn regs() -> crate::pac::timer::TimBasic {
|
||||
crate::pac::timer::TimBasic(crate::pac::$inst.0)
|
||||
|
@ -2,18 +2,18 @@ use core::future::poll_fn;
|
||||
use core::slice;
|
||||
use core::task::Poll;
|
||||
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
use embassy_hal_common::atomic_ring_buffer::RingBuffer;
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
use super::*;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
|
||||
/// Interrupt handler.
|
||||
pub struct InterruptHandler<T: BasicInstance> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: BasicInstance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {
|
||||
let r = T::regs();
|
||||
let state = T::buffered_state();
|
||||
@ -115,7 +115,7 @@ pub struct BufferedUartRx<'d, T: BasicInstance> {
|
||||
impl<'d, T: BasicInstance> BufferedUart<'d, T> {
|
||||
pub fn new(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
|
||||
tx_buffer: &'d mut [u8],
|
||||
@ -130,7 +130,7 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
|
||||
|
||||
pub fn new_with_rtscts(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
|
||||
rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
|
||||
@ -159,7 +159,7 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
|
||||
#[cfg(not(any(usart_v1, usart_v2)))]
|
||||
pub fn new_with_de(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
|
||||
de: impl Peripheral<P = impl DePin<T>> + 'd,
|
||||
|
@ -5,13 +5,13 @@ use core::marker::PhantomData;
|
||||
use core::sync::atomic::{compiler_fence, Ordering};
|
||||
use core::task::Poll;
|
||||
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
use embassy_hal_common::drop::OnDrop;
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
use futures::future::{select, Either};
|
||||
|
||||
use crate::dma::{NoDma, Transfer};
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
#[cfg(not(any(usart_v1, usart_v2)))]
|
||||
#[allow(unused_imports)]
|
||||
use crate::pac::usart::regs::Isr as Sr;
|
||||
@ -31,7 +31,7 @@ pub struct InterruptHandler<T: BasicInstance> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: BasicInstance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {
|
||||
let r = T::regs();
|
||||
let s = T::state();
|
||||
@ -281,7 +281,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> {
|
||||
/// Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power.
|
||||
pub fn new(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
rx_dma: impl Peripheral<P = RxDma> + 'd,
|
||||
config: Config,
|
||||
@ -294,7 +294,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> {
|
||||
|
||||
pub fn new_with_rts(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
|
||||
rx_dma: impl Peripheral<P = RxDma> + 'd,
|
||||
@ -650,7 +650,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
tx_dma: impl Peripheral<P = TxDma> + 'd,
|
||||
rx_dma: impl Peripheral<P = RxDma> + 'd,
|
||||
config: Config,
|
||||
@ -665,7 +665,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
|
||||
cts: impl Peripheral<P = impl CtsPin<T>> + 'd,
|
||||
tx_dma: impl Peripheral<P = TxDma> + 'd,
|
||||
@ -693,7 +693,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
de: impl Peripheral<P = impl DePin<T>> + 'd,
|
||||
tx_dma: impl Peripheral<P = TxDma> + 'd,
|
||||
rx_dma: impl Peripheral<P = RxDma> + 'd,
|
||||
@ -1179,7 +1179,7 @@ pub(crate) mod sealed {
|
||||
|
||||
pub trait BasicInstance: crate::rcc::RccPeripheral {
|
||||
const KIND: Kind;
|
||||
type Interrupt: crate::interrupt::Interrupt;
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
|
||||
fn regs() -> Regs;
|
||||
fn state() -> &'static State;
|
||||
@ -1211,7 +1211,7 @@ macro_rules! impl_usart {
|
||||
($inst:ident, $irq:ident, $kind:expr) => {
|
||||
impl sealed::BasicInstance for crate::peripherals::$inst {
|
||||
const KIND: Kind = $kind;
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
|
||||
fn regs() -> Regs {
|
||||
Regs(crate::pac::$inst.0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt;
|
||||
use crate::rcc::RccPeripheral;
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
@ -13,7 +13,7 @@ pub(crate) mod sealed {
|
||||
}
|
||||
|
||||
pub trait Instance: sealed::Instance + RccPeripheral + 'static {
|
||||
type Interrupt: Interrupt;
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
// Internal PHY pins
|
||||
@ -29,7 +29,7 @@ foreach_interrupt!(
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
);
|
||||
|
@ -14,7 +14,7 @@ use embassy_usb_driver::{
|
||||
|
||||
use super::{DmPin, DpPin, Instance};
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::pac::usb::regs;
|
||||
use crate::pac::usb::vals::{EpType, Stat};
|
||||
use crate::pac::USBRAM;
|
||||
@ -26,7 +26,7 @@ pub struct InterruptHandler<T: Instance> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {
|
||||
unsafe {
|
||||
let regs = T::regs();
|
||||
@ -255,7 +255,7 @@ pub struct Driver<'d, T: Instance> {
|
||||
impl<'d, T: Instance> Driver<'d, T> {
|
||||
pub fn new(
|
||||
_usb: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
dp: impl Peripheral<P = impl DpPin<T>> + 'd,
|
||||
dm: impl Peripheral<P = impl DmPin<T>> + 'd,
|
||||
) -> Self {
|
||||
|
@ -1,7 +1,5 @@
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
|
||||
use crate::peripherals;
|
||||
use crate::rcc::RccPeripheral;
|
||||
use crate::{interrupt, peripherals};
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
mod usb;
|
||||
@ -25,7 +23,7 @@ pub(crate) mod sealed {
|
||||
}
|
||||
|
||||
pub trait Instance: sealed::Instance + RccPeripheral {
|
||||
type Interrupt: Interrupt;
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
// Internal PHY pins
|
||||
@ -109,7 +107,7 @@ foreach_interrupt!(
|
||||
}
|
||||
|
||||
impl Instance for peripherals::USB_OTG_FS {
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
|
||||
@ -161,7 +159,7 @@ foreach_interrupt!(
|
||||
}
|
||||
|
||||
impl Instance for peripherals::USB_OTG_HS {
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
);
|
||||
|
@ -3,7 +3,6 @@ use core::marker::PhantomData;
|
||||
use core::task::Poll;
|
||||
|
||||
use atomic_polyfill::{AtomicBool, AtomicU16, Ordering};
|
||||
use embassy_cortex_m::interrupt::Interrupt;
|
||||
use embassy_hal_common::{into_ref, Peripheral};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
use embassy_usb_driver::{
|
||||
@ -15,6 +14,7 @@ use futures::future::poll_fn;
|
||||
use super::*;
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::pac::otg::{regs, vals};
|
||||
use crate::rcc::sealed::RccPeripheral;
|
||||
use crate::time::Hertz;
|
||||
@ -24,7 +24,7 @@ pub struct InterruptHandler<T: Instance> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
|
||||
unsafe fn on_interrupt() {
|
||||
trace!("irq");
|
||||
let r = T::regs();
|
||||
@ -291,7 +291,7 @@ impl<'d, T: Instance> Driver<'d, T> {
|
||||
/// Endpoint allocation will fail if it is too small.
|
||||
pub fn new_fs(
|
||||
_peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
dp: impl Peripheral<P = impl DpPin<T>> + 'd,
|
||||
dm: impl Peripheral<P = impl DmPin<T>> + 'd,
|
||||
ep_out_buffer: &'d mut [u8],
|
||||
@ -322,7 +322,7 @@ impl<'d, T: Instance> Driver<'d, T> {
|
||||
/// Endpoint allocation will fail if it is too small.
|
||||
pub fn new_hs_ulpi(
|
||||
_peri: impl Peripheral<P = T> + 'd,
|
||||
_irq: impl interrupt::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||
ulpi_clk: impl Peripheral<P = impl UlpiClkPin<T>> + 'd,
|
||||
ulpi_dir: impl Peripheral<P = impl UlpiDirPin<T>> + 'd,
|
||||
ulpi_nxt: impl Peripheral<P = impl UlpiNxtPin<T>> + 'd,
|
||||
|
Reference in New Issue
Block a user