stm32/adc: make v1 async and leave en

This commit is contained in:
xoviat
2023-09-20 16:07:35 -05:00
parent c573959a95
commit d46920dce6
3 changed files with 104 additions and 63 deletions

View File

@ -31,15 +31,15 @@ pub struct Adc<'d, T: Instance> {
}
pub(crate) mod sealed {
#[cfg(adc_f3)]
#[cfg(any(adc_f3, adc_v1))]
use embassy_sync::waitqueue::AtomicWaker;
#[cfg(adc_f3)]
#[cfg(any(adc_f3, adc_v1))]
pub struct State {
pub waker: AtomicWaker,
}
#[cfg(adc_f3)]
#[cfg(any(adc_f3, adc_v1))]
impl State {
pub const fn new() -> Self {
Self {
@ -58,7 +58,7 @@ pub(crate) mod sealed {
fn common_regs() -> crate::pac::adccommon::AdcCommon;
#[cfg(adc_f3)]
fn frequency() -> crate::time::Hertz;
#[cfg(adc_f3)]
#[cfg(any(adc_f3, adc_v1))]
fn state() -> &'static State;
}
@ -96,7 +96,7 @@ foreach_adc!(
unsafe { crate::rcc::get_freqs() }.$clock.unwrap()
}
#[cfg(adc_f3)]
#[cfg(any(adc_f3, adc_v1))]
fn state() -> &'static sealed::State {
static STATE: sealed::State = sealed::State::new();
&STATE