2022-02-10 20:38:03 +00:00
|
|
|
#![macro_use]
|
|
|
|
|
|
|
|
macro_rules! pin_trait {
|
|
|
|
($signal:ident, $instance:path) => {
|
|
|
|
pub trait $signal<T: $instance>: crate::gpio::Pin {
|
|
|
|
fn af_num(&self) -> u8;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! pin_trait_impl {
|
2022-02-23 18:43:32 +00:00
|
|
|
(crate::$mod:ident::$trait:ident, $instance:ident, $pin:ident, $af:expr) => {
|
|
|
|
impl crate::$mod::$trait<crate::peripherals::$instance> for crate::peripherals::$pin {
|
2022-02-10 20:38:03 +00:00
|
|
|
fn af_num(&self) -> u8 {
|
|
|
|
$af
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// ====================
|
|
|
|
|
|
|
|
macro_rules! dma_trait {
|
|
|
|
($signal:ident, $instance:path) => {
|
|
|
|
pub trait $signal<T: $instance>: crate::dma::Channel {
|
|
|
|
fn request(&self) -> crate::dma::Request;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(unused)]
|
|
|
|
macro_rules! dma_trait_impl {
|
|
|
|
// DMAMUX
|
2022-02-23 17:55:16 +00:00
|
|
|
(crate::$mod:ident::$trait:ident, $instance:ident, {dmamux: $dmamux:ident}, $request:expr) => {
|
|
|
|
impl<T> crate::$mod::$trait<crate::peripherals::$instance> for T
|
2022-02-10 20:38:03 +00:00
|
|
|
where
|
|
|
|
T: crate::dma::MuxChannel<Mux = crate::dma::$dmamux>,
|
|
|
|
{
|
|
|
|
fn request(&self) -> crate::dma::Request {
|
|
|
|
$request
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-26 21:57:26 +00:00
|
|
|
// DMAMUX
|
|
|
|
(crate::$mod:ident::$trait:ident, $instance:ident, {dma: $dma:ident}, $request:expr) => {
|
|
|
|
impl<T> crate::$mod::$trait<crate::peripherals::$instance> for T
|
|
|
|
where
|
|
|
|
T: crate::dma::Channel,
|
|
|
|
{
|
|
|
|
fn request(&self) -> crate::dma::Request {
|
|
|
|
$request
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// DMA/GPDMA, without DMAMUX
|
2022-02-23 17:55:16 +00:00
|
|
|
(crate::$mod:ident::$trait:ident, $instance:ident, {channel: $channel:ident}, $request:expr) => {
|
|
|
|
impl crate::$mod::$trait<crate::peripherals::$instance> for crate::peripherals::$channel {
|
2022-02-10 20:38:03 +00:00
|
|
|
fn request(&self) -> crate::dma::Request {
|
|
|
|
$request
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|