adc: Implement support for f1 ADC block

Add basic support for the STM32F1xx ADC blocks.
This commit is contained in:
Sjoerd Simons
2021-12-30 10:51:49 +01:00
parent a93b1141e9
commit 92f2c6d09c
2 changed files with 242 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#[cfg_attr(adc_v3, path = "v3.rs")]
#[cfg_attr(adc_v2, path = "v2.rs")]
#[cfg_attr(adc_g0, path = "v3.rs")]
#[cfg_attr(adc_f1, path = "f1.rs")]
mod _version;
#[allow(unused)]
@ -13,9 +14,11 @@ use crate::peripherals;
pub(crate) mod sealed {
pub trait Instance {
fn regs() -> &'static crate::pac::adc::Adc;
#[cfg(not(adc_f1))]
fn common_regs() -> &'static crate::pac::adccommon::AdcCommon;
}
#[cfg(not(adc_f1))]
pub trait Common {
fn regs() -> &'static crate::pac::adccommon::AdcCommon;
}
@ -25,7 +28,11 @@ pub(crate) mod sealed {
}
}
#[cfg(not(adc_f1))]
pub trait Instance: sealed::Instance + 'static {}
#[cfg(adc_f1)]
pub trait Instance: sealed::Instance + crate::rcc::RccPeripheral + 'static {}
#[cfg(not(adc_f1))]
pub trait Common: sealed::Common + 'static {}
pub trait AdcPin<T: Instance>: sealed::AdcPin<T> {}
@ -35,6 +42,7 @@ crate::pac::peripherals!(
fn regs() -> &'static crate::pac::adc::Adc {
&crate::pac::$inst
}
#[cfg(not(adc_f1))]
fn common_regs() -> &'static crate::pac::adccommon::AdcCommon {
crate::pac::peripherals!{
(adccommon, $common_inst:ident) => {
@ -48,6 +56,7 @@ crate::pac::peripherals!(
};
);
#[cfg(not(adc_f1))]
crate::pac::peripherals!(
(adccommon, $inst:ident) => {
impl sealed::Common for peripherals::$inst {