DAC v2 basics.

This commit is contained in:
Bob McWhirter
2021-05-28 13:31:40 -04:00
parent 2aa836b068
commit 0c54c1afd1
5 changed files with 344 additions and 1 deletions

View File

@ -0,0 +1,48 @@
#![macro_use]
#[cfg_attr(dac_v2, path = "v2.rs")]
mod _version;
use crate::gpio::NoPin;
pub use _version::*;
pub(crate) mod sealed {
use super::*;
use crate::gpio::{OptionalPin, Pin};
pub trait Instance {
fn regs() -> &'static crate::pac::dac::Dac;
}
pub trait DacPin<T: Instance, const C: u8>: OptionalPin {}
}
pub trait Instance: sealed::Instance + 'static {}
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) => {
impl crate::dac::sealed::Instance for peripherals::$inst {
fn regs() -> &'static crate::pac::dac::Dac {
&crate::pac::$inst
}
}
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 {}
impl crate::dac::sealed::DacPin<peripherals::$inst, $channel> for peripherals::$pin {
//fn af_num(&self) -> u8 {
//$af
//}
}
};
}