stm32: replace peripheral_rcc!
macrotable with build.rs
This commit is contained in:
@ -9,7 +9,6 @@ use embassy::waitqueue::AtomicWaker;
|
||||
use crate::dma::Request;
|
||||
use crate::pac;
|
||||
use crate::pac::bdma::vals;
|
||||
use crate::rcc::sealed::RccPeripheral;
|
||||
|
||||
use super::{Word, WordSize};
|
||||
|
||||
@ -77,11 +76,7 @@ pub(crate) unsafe fn init() {
|
||||
crate::interrupt::$irq::steal().enable();
|
||||
};
|
||||
}
|
||||
pac::peripherals! {
|
||||
(bdma, $peri:ident) => {
|
||||
crate::peripherals::$peri::enable();
|
||||
};
|
||||
}
|
||||
crate::generated::init_bdma();
|
||||
}
|
||||
|
||||
pac::dma_channels! {
|
||||
|
@ -7,7 +7,6 @@ use embassy::waitqueue::AtomicWaker;
|
||||
use crate::interrupt;
|
||||
use crate::pac;
|
||||
use crate::pac::dma::{regs, vals};
|
||||
use crate::rcc::sealed::RccPeripheral;
|
||||
|
||||
use super::{Request, Word, WordSize};
|
||||
|
||||
@ -74,11 +73,7 @@ pub(crate) unsafe fn init() {
|
||||
interrupt::$irq::steal().enable();
|
||||
};
|
||||
}
|
||||
pac::peripherals! {
|
||||
(dma, $peri:ident) => {
|
||||
crate::peripherals::$peri::enable();
|
||||
};
|
||||
}
|
||||
crate::generated::init_dma();
|
||||
}
|
||||
|
||||
pac::dma_channels! {
|
||||
|
@ -49,11 +49,5 @@ pac::dma_channels! {
|
||||
|
||||
/// safety: must be called only once
|
||||
pub(crate) unsafe fn init() {
|
||||
crate::pac::peripheral_rcc! {
|
||||
($name:ident, dmamux, DMAMUX, $clock:ident, ($reg:ident, $field:ident, $set_field:ident), $rst:tt) => {
|
||||
crate::pac::RCC.$reg().modify(|reg| {
|
||||
reg.$set_field(true);
|
||||
});
|
||||
};
|
||||
}
|
||||
crate::generated::init_dmamux();
|
||||
}
|
||||
|
@ -608,13 +608,7 @@ crate::pac::pins!(
|
||||
);
|
||||
|
||||
pub(crate) unsafe fn init() {
|
||||
crate::pac::peripheral_rcc! {
|
||||
($name:ident, gpio, GPIO, $clock:ident, ($reg:ident, $field:ident, $set_field:ident), $rst:tt) => {
|
||||
crate::pac::RCC.$reg().modify(|reg| {
|
||||
reg.$set_field(true);
|
||||
});
|
||||
};
|
||||
}
|
||||
crate::generated::init_gpio();
|
||||
}
|
||||
|
||||
mod eh02 {
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![macro_use]
|
||||
|
||||
use crate::peripherals;
|
||||
use crate::time::Hertz;
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
@ -104,66 +103,3 @@ pub(crate) mod sealed {
|
||||
}
|
||||
|
||||
pub trait RccPeripheral: sealed::RccPeripheral + 'static {}
|
||||
|
||||
crate::pac::peripheral_rcc!(
|
||||
($inst:ident, gpio, GPIO, $clk:ident, $en:tt, $rst:tt) => {};
|
||||
($inst:ident, $module:ident, $block:ident, $clk:ident, ($en_reg:ident, $en_field:ident, $en_set_field:ident), ($rst_reg:ident, $rst_field:ident, $rst_set_field:ident)) => {
|
||||
impl sealed::RccPeripheral for peripherals::$inst {
|
||||
fn frequency() -> crate::time::Hertz {
|
||||
critical_section::with(|_| {
|
||||
unsafe { get_freqs().$clk }
|
||||
})
|
||||
}
|
||||
fn enable() {
|
||||
critical_section::with(|_| {
|
||||
unsafe {
|
||||
crate::pac::RCC.$en_reg().modify(|w| w.$en_set_field(true));
|
||||
}
|
||||
})
|
||||
}
|
||||
fn disable() {
|
||||
critical_section::with(|_| {
|
||||
unsafe {
|
||||
crate::pac::RCC.$en_reg().modify(|w| w.$en_set_field(false));
|
||||
}
|
||||
})
|
||||
}
|
||||
fn reset() {
|
||||
critical_section::with(|_| {
|
||||
unsafe {
|
||||
crate::pac::RCC.$rst_reg().modify(|w| w.$rst_set_field(true));
|
||||
crate::pac::RCC.$rst_reg().modify(|w| w.$rst_set_field(false));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl RccPeripheral for peripherals::$inst {}
|
||||
};
|
||||
($inst:ident, $module:ident, $block:ident, $clk:ident, ($en_reg:ident, $en_field:ident, $en_set_field:ident), _) => {
|
||||
impl sealed::RccPeripheral for peripherals::$inst {
|
||||
fn frequency() -> crate::time::Hertz {
|
||||
critical_section::with(|_| {
|
||||
unsafe { get_freqs().$clk }
|
||||
})
|
||||
}
|
||||
fn enable() {
|
||||
critical_section::with(|_| {
|
||||
unsafe {
|
||||
crate::pac::RCC.$en_reg().modify(|w| w.$en_set_field(true));
|
||||
}
|
||||
})
|
||||
}
|
||||
fn disable() {
|
||||
critical_section::with(|_| {
|
||||
unsafe {
|
||||
crate::pac::RCC.$en_reg().modify(|w| w.$en_set_field(false));
|
||||
}
|
||||
})
|
||||
}
|
||||
fn reset() {}
|
||||
}
|
||||
|
||||
impl RccPeripheral for peripherals::$inst {}
|
||||
};
|
||||
);
|
||||
|
Reference in New Issue
Block a user