Move DAC, I2C, SPI and RNG to macro-tables.

This commit is contained in:
Bob McWhirter
2021-06-03 11:09:29 -04:00
parent d4d914ea50
commit 6958091b50
6 changed files with 162 additions and 62 deletions

View File

@ -3,6 +3,7 @@
#[cfg_attr(dac_v2, path = "v2.rs")]
mod _version;
use crate::gpio::NoPin;
use crate::peripherals;
pub use _version::*;
pub(crate) mod sealed {
@ -23,8 +24,8 @@ pub trait DacPin<T: Instance, const C: u8>: sealed::DacPin<T, C> + 'static {}
impl<T: Instance, const C: u8> DacPin<T, C> for NoPin {}
impl<T: Instance, const C: u8> sealed::DacPin<T, C> for NoPin {}
macro_rules! impl_dac {
($inst:ident) => {
crate::pac::peripherals!(
(dac, $inst:ident) => {
impl crate::dac::sealed::Instance for peripherals::$inst {
fn regs() -> &'static crate::pac::dac::Dac {
&crate::pac::$inst
@ -33,16 +34,21 @@ macro_rules! impl_dac {
impl crate::dac::Instance for peripherals::$inst {}
};
}
);
macro_rules! impl_dac_pin {
($inst:ident, $channel:expr, $pin:ident ) => {
impl crate::dac::DacPin<peripherals::$inst, $channel> for peripherals::$pin {}
crate::pac::peripheral_pins!(
($inst:ident, dac, DAC, $pin:ident, OUT1) => {
impl DacPin<peripherals::$inst, 1> for peripherals::$pin {}
impl crate::dac::sealed::DacPin<peripherals::$inst, $channel> for peripherals::$pin {
//fn af_num(&self) -> u8 {
//$af
//}
impl sealed::DacPin<peripherals::$inst, 1> for peripherals::$pin {
}
};
($inst:ident, dac, DAC, $pin:ident, OUT2) => {
impl DacPin<peripherals::$inst, 2> for peripherals::$pin {}
impl sealed::DacPin<peripherals::$inst, 2> for peripherals::$pin {
}
};
}
);