Move DAC, I2C, SPI and RNG to macro-tables.
This commit is contained in:
@ -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 {
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user