stm32: Remove OptionalPin
The idea behind OptionalPin has a few problems: - you need to impl the signal traits for NoPin which is a bit weird https://github.com/embassy-rs/embassy/blob/master/embassy-stm32/src/dcmi.rs#L413-L416 - you can pass any combination of set/unset pins, which needs checking at runtime https://github.com/embassy-rs/embassy/blob/master/embassy-stm32/src/dcmi.rs#L130 The replacement is to do multiple `new` constructors for each combination of pins you want to take.
This commit is contained in:
@@ -3,27 +3,21 @@
|
||||
#[cfg_attr(dac_v1, path = "v1.rs")]
|
||||
#[cfg_attr(dac_v2, path = "v2.rs")]
|
||||
mod _version;
|
||||
use crate::gpio::NoPin;
|
||||
use crate::peripherals;
|
||||
pub use _version::*;
|
||||
|
||||
pub(crate) mod sealed {
|
||||
use crate::gpio::OptionalPin;
|
||||
|
||||
pub trait Instance {
|
||||
fn regs() -> &'static crate::pac::dac::Dac;
|
||||
}
|
||||
|
||||
pub trait DacPin<T: Instance, const C: u8>: OptionalPin {}
|
||||
pub trait DacPin<T: Instance, const C: u8>: crate::gpio::Pin {}
|
||||
}
|
||||
|
||||
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 {}
|
||||
|
||||
crate::pac::peripherals!(
|
||||
(dac, $inst:ident) => {
|
||||
impl crate::dac::sealed::Instance for peripherals::$inst {
|
||||
|
Reference in New Issue
Block a user