stm32: Add standard crate-wide macros for pin/dma traits, switch all drivers to use them.

This commit is contained in:
Dario Nieuwenhuis
2022-02-10 21:38:03 +01:00
parent 9d682aa1fa
commit b99ab3d5d9
26 changed files with 913 additions and 1781 deletions

View File

@ -1,22 +1,13 @@
use core::marker::PhantomData;
use core::task::Poll;
use crate::gpio::sealed::Pin as __GpioPin;
use crate::gpio::Pin as GpioPin;
use embassy::interrupt::{Interrupt, InterruptExt};
use embassy::util::Unborrow;
use embassy::waitqueue::AtomicWaker;
use embassy_hal_common::unborrow;
use futures::future::poll_fn;
#[macro_export]
macro_rules! configure {
($($name:ident),*) => {
$(
unsafe { $name.unborrow() }.configure();
)*
}
}
use crate::gpio::{sealed::AFType, Speed};
/// The level on the VSync pin when the data is not valid on the parallel interface.
#[derive(Clone, Copy, PartialEq)]
@ -76,7 +67,20 @@ impl Default for Config {
}
}
pub struct Dcmi<'d, T: Instance, Dma: FrameDma> {
macro_rules! config_pins {
($($pin:ident),*) => {
unborrow!($($pin),*);
// NOTE(unsafe) Exclusive access to the registers
critical_section::with(|_| unsafe {
$(
$pin.set_as_af($pin.af_num(), AFType::Input);
$pin.set_speed(Speed::VeryHigh);
)*
})
};
}
pub struct Dcmi<'d, T: Instance, Dma: FrameDma<T>> {
inner: T,
dma: Dma,
phantom: PhantomData<&'d mut T>,
@ -85,53 +89,54 @@ pub struct Dcmi<'d, T: Instance, Dma: FrameDma> {
impl<'d, T, Dma> Dcmi<'d, T, Dma>
where
T: Instance,
Dma: FrameDma,
Dma: FrameDma<T>,
{
pub fn new_8bit(
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin<T>> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7);
configure!(v_sync, h_sync, pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7);
config_pins!(v_sync, h_sync, pixclk);
Self::new_inner(peri, dma, irq, config, false, 0b00)
}
pub fn new_10bit(
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
d8: impl Unborrow<Target = impl D8Pin> + 'd,
d9: impl Unborrow<Target = impl D9Pin> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
d8: impl Unborrow<Target = impl D8Pin<T>> + 'd,
d9: impl Unborrow<Target = impl D9Pin<T>> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin<T>> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9);
configure!(v_sync, h_sync, pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9);
config_pins!(v_sync, h_sync, pixclk);
Self::new_inner(peri, dma, irq, config, false, 0b01)
}
@ -140,55 +145,56 @@ where
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
d8: impl Unborrow<Target = impl D8Pin> + 'd,
d9: impl Unborrow<Target = impl D9Pin> + 'd,
d10: impl Unborrow<Target = impl D10Pin> + 'd,
d11: impl Unborrow<Target = impl D11Pin> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
d8: impl Unborrow<Target = impl D8Pin<T>> + 'd,
d9: impl Unborrow<Target = impl D9Pin<T>> + 'd,
d10: impl Unborrow<Target = impl D10Pin<T>> + 'd,
d11: impl Unborrow<Target = impl D11Pin<T>> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin<T>> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11);
configure!(v_sync, h_sync, pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11);
config_pins!(v_sync, h_sync, pixclk);
Self::new_inner(peri, dma, irq, config, false, 0b10)
}
pub fn new_14bit(
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
d8: impl Unborrow<Target = impl D8Pin> + 'd,
d9: impl Unborrow<Target = impl D9Pin> + 'd,
d10: impl Unborrow<Target = impl D10Pin> + 'd,
d11: impl Unborrow<Target = impl D11Pin> + 'd,
d12: impl Unborrow<Target = impl D12Pin> + 'd,
d13: impl Unborrow<Target = impl D13Pin> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
d8: impl Unborrow<Target = impl D8Pin<T>> + 'd,
d9: impl Unborrow<Target = impl D9Pin<T>> + 'd,
d10: impl Unborrow<Target = impl D10Pin<T>> + 'd,
d11: impl Unborrow<Target = impl D11Pin<T>> + 'd,
d12: impl Unborrow<Target = impl D12Pin<T>> + 'd,
d13: impl Unborrow<Target = impl D13Pin<T>> + 'd,
v_sync: impl Unborrow<Target = impl VSyncPin<T>> + 'd,
h_sync: impl Unborrow<Target = impl HSyncPin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13);
configure!(v_sync, h_sync, pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13);
config_pins!(v_sync, h_sync, pixclk);
Self::new_inner(peri, dma, irq, config, false, 0b11)
}
@ -197,20 +203,20 @@ where
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7);
configure!(pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7);
config_pins!(pixclk);
Self::new_inner(peri, dma, irq, config, true, 0b00)
}
@ -219,22 +225,22 @@ where
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
d8: impl Unborrow<Target = impl D8Pin> + 'd,
d9: impl Unborrow<Target = impl D9Pin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
d8: impl Unborrow<Target = impl D8Pin<T>> + 'd,
d9: impl Unborrow<Target = impl D9Pin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9);
configure!(pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9);
config_pins!(pixclk);
Self::new_inner(peri, dma, irq, config, true, 0b01)
}
@ -243,51 +249,52 @@ where
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
d8: impl Unborrow<Target = impl D8Pin> + 'd,
d9: impl Unborrow<Target = impl D9Pin> + 'd,
d10: impl Unborrow<Target = impl D10Pin> + 'd,
d11: impl Unborrow<Target = impl D11Pin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
d8: impl Unborrow<Target = impl D8Pin<T>> + 'd,
d9: impl Unborrow<Target = impl D9Pin<T>> + 'd,
d10: impl Unborrow<Target = impl D10Pin<T>> + 'd,
d11: impl Unborrow<Target = impl D11Pin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11);
configure!(pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11);
config_pins!(pixclk);
Self::new_inner(peri, dma, irq, config, true, 0b10)
}
pub fn new_es_14bit(
peri: impl Unborrow<Target = T> + 'd,
dma: impl Unborrow<Target = Dma> + 'd,
irq: impl Unborrow<Target = T::Interrupt> + 'd,
d0: impl Unborrow<Target = impl D0Pin> + 'd,
d1: impl Unborrow<Target = impl D1Pin> + 'd,
d2: impl Unborrow<Target = impl D2Pin> + 'd,
d3: impl Unborrow<Target = impl D3Pin> + 'd,
d4: impl Unborrow<Target = impl D4Pin> + 'd,
d5: impl Unborrow<Target = impl D5Pin> + 'd,
d6: impl Unborrow<Target = impl D6Pin> + 'd,
d7: impl Unborrow<Target = impl D7Pin> + 'd,
d8: impl Unborrow<Target = impl D8Pin> + 'd,
d9: impl Unborrow<Target = impl D9Pin> + 'd,
d10: impl Unborrow<Target = impl D10Pin> + 'd,
d11: impl Unborrow<Target = impl D11Pin> + 'd,
d12: impl Unborrow<Target = impl D12Pin> + 'd,
d13: impl Unborrow<Target = impl D13Pin> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin> + 'd,
d0: impl Unborrow<Target = impl D0Pin<T>> + 'd,
d1: impl Unborrow<Target = impl D1Pin<T>> + 'd,
d2: impl Unborrow<Target = impl D2Pin<T>> + 'd,
d3: impl Unborrow<Target = impl D3Pin<T>> + 'd,
d4: impl Unborrow<Target = impl D4Pin<T>> + 'd,
d5: impl Unborrow<Target = impl D5Pin<T>> + 'd,
d6: impl Unborrow<Target = impl D6Pin<T>> + 'd,
d7: impl Unborrow<Target = impl D7Pin<T>> + 'd,
d8: impl Unborrow<Target = impl D8Pin<T>> + 'd,
d9: impl Unborrow<Target = impl D9Pin<T>> + 'd,
d10: impl Unborrow<Target = impl D10Pin<T>> + 'd,
d11: impl Unborrow<Target = impl D11Pin<T>> + 'd,
d12: impl Unborrow<Target = impl D12Pin<T>> + 'd,
d13: impl Unborrow<Target = impl D13Pin<T>> + 'd,
pixclk: impl Unborrow<Target = impl PixClkPin<T>> + 'd,
config: Config,
) -> Self {
unborrow!(peri, dma, irq);
configure!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13);
configure!(pixclk);
config_pins!(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13);
config_pins!(pixclk);
Self::new_inner(peri, dma, irq, config, true, 0b11)
}
@ -424,75 +431,32 @@ where
}
mod sealed {
use super::*;
use crate::rcc::RccPeripheral;
pub trait Instance: RccPeripheral {
pub trait Instance: crate::rcc::RccPeripheral {
fn regs(&self) -> crate::pac::dcmi::Dcmi;
}
pub trait FrameDma {
fn request(&self) -> crate::dma::Request;
}
macro_rules! pin {
($name:ident) => {
pub trait $name: GpioPin {
fn configure(&mut self);
}
};
}
pin!(D0Pin);
pin!(D1Pin);
pin!(D2Pin);
pin!(D3Pin);
pin!(D4Pin);
pin!(D5Pin);
pin!(D6Pin);
pin!(D7Pin);
pin!(D8Pin);
pin!(D9Pin);
pin!(D10Pin);
pin!(D11Pin);
pin!(D12Pin);
pin!(D13Pin);
pin!(HSyncPin);
pin!(VSyncPin);
pin!(PixClkPin);
}
pub trait Instance: sealed::Instance + 'static {
type Interrupt: Interrupt;
}
pub trait FrameDma: sealed::FrameDma + crate::dma::Channel {}
macro_rules! pin {
($name:ident) => {
pub trait $name: sealed::$name + 'static {}
};
}
pin!(D0Pin);
pin!(D1Pin);
pin!(D2Pin);
pin!(D3Pin);
pin!(D4Pin);
pin!(D5Pin);
pin!(D6Pin);
pin!(D7Pin);
pin!(D8Pin);
pin!(D9Pin);
pin!(D10Pin);
pin!(D11Pin);
pin!(D12Pin);
pin!(D13Pin);
pin!(HSyncPin);
pin!(VSyncPin);
pin!(PixClkPin);
pin_trait!(D0Pin, Instance);
pin_trait!(D1Pin, Instance);
pin_trait!(D2Pin, Instance);
pin_trait!(D3Pin, Instance);
pin_trait!(D4Pin, Instance);
pin_trait!(D5Pin, Instance);
pin_trait!(D6Pin, Instance);
pin_trait!(D7Pin, Instance);
pin_trait!(D8Pin, Instance);
pin_trait!(D9Pin, Instance);
pin_trait!(D10Pin, Instance);
pin_trait!(D11Pin, Instance);
pin_trait!(D12Pin, Instance);
pin_trait!(D13Pin, Instance);
pin_trait!(HSyncPin, Instance);
pin_trait!(VSyncPin, Instance);
pin_trait!(PixClkPin, Instance);
// allow unused as U5 sources do not contain interrupt nor dma data
#[allow(unused)]
@ -516,112 +480,67 @@ crate::pac::interrupts! {
};
}
// allow unused as U5 sources do not contain interrupt nor dma data
#[allow(unused)]
macro_rules! impl_dma {
($inst:ident, {dmamux: $dmamux:ident}, $signal:ident, $request:expr) => {
impl<T> sealed::$signal for T
where
T: crate::dma::MuxChannel<Mux = crate::dma::$dmamux>,
{
fn request(&self) -> crate::dma::Request {
$request
}
}
impl<T> $signal for T where T: crate::dma::MuxChannel<Mux = crate::dma::$dmamux> {}
};
($inst:ident, {channel: $channel:ident}, $signal:ident, $request:expr) => {
impl sealed::$signal for crate::peripherals::$channel {
fn request(&self) -> crate::dma::Request {
$request
}
}
impl $signal for crate::peripherals::$channel {}
};
}
dma_trait!(FrameDma, Instance);
crate::pac::peripheral_dma_channels! {
($peri:ident, dcmi, $kind:ident, PSSI, $channel:tt, $request:expr) => {
impl_dma!($peri, $channel, FrameDma, $request);
dma_trait_impl!(FrameDma, $peri, $channel, $request);
};
($peri:ident, dcmi, $kind:ident, DCMI, $channel:tt, $request:expr) => {
impl_dma!($peri, $channel, FrameDma, $request);
};
}
macro_rules! impl_pin {
($pin:ident, $signal:ident, $af:expr) => {
impl sealed::$signal for crate::peripherals::$pin {
fn configure(&mut self) {
// NOTE(unsafe) Exclusive access to the registers
critical_section::with(|_| unsafe {
self.set_as_af($af, crate::gpio::sealed::AFType::Input);
self.block().ospeedr().modify(|w| {
w.set_ospeedr(
self.pin() as usize,
crate::pac::gpio::vals::Ospeedr::VERYHIGHSPEED,
)
});
})
}
}
impl $signal for crate::peripherals::$pin {}
dma_trait_impl!(FrameDma, $peri, $channel, $request);
};
}
crate::pac::peripheral_pins!(
($inst:ident, dcmi, DCMI, $pin:ident, D0, $af:expr) => {
impl_pin!($pin, D0Pin, $af);
pin_trait_impl!(D0Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D1, $af:expr) => {
impl_pin!($pin, D1Pin, $af);
pin_trait_impl!(D1Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D2, $af:expr) => {
impl_pin!($pin, D2Pin, $af);
pin_trait_impl!(D2Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D3, $af:expr) => {
impl_pin!($pin, D3Pin, $af);
pin_trait_impl!(D3Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D4, $af:expr) => {
impl_pin!($pin, D4Pin, $af);
pin_trait_impl!(D4Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D5, $af:expr) => {
impl_pin!($pin, D5Pin, $af);
pin_trait_impl!(D5Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D6, $af:expr) => {
impl_pin!($pin, D6Pin, $af);
pin_trait_impl!(D6Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D7, $af:expr) => {
impl_pin!($pin, D7Pin, $af);
pin_trait_impl!(D7Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D8, $af:expr) => {
impl_pin!($pin, D8Pin, $af);
pin_trait_impl!(D8Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D9, $af:expr) => {
impl_pin!($pin, D9Pin, $af);
pin_trait_impl!(D9Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D10, $af:expr) => {
impl_pin!($pin, D10Pin, $af);
pin_trait_impl!(D10Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D11, $af:expr) => {
impl_pin!($pin, D11Pin, $af);
pin_trait_impl!(D11Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D12, $af:expr) => {
impl_pin!($pin, D12Pin, $af);
pin_trait_impl!(D12Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, D13, $af:expr) => {
impl_pin!($pin, D13Pin, $af);
pin_trait_impl!(D13Pin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, HSYNC, $af:expr) => {
impl_pin!($pin, HSyncPin, $af);
pin_trait_impl!(HSyncPin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, VSYNC, $af:expr) => {
impl_pin!($pin, VSyncPin, $af);
pin_trait_impl!(VSyncPin, $inst, $pin, $af);
};
($inst:ident, dcmi, DCMI, $pin:ident, PIXCLK, $af:expr) => {
impl_pin!($pin, PixClkPin, $af);
pin_trait_impl!(PixClkPin, $inst, $pin, $af);
};
);