stm32/adc: move convert resolution from PAC to version-specific mod.

This commit is contained in:
Dario Nieuwenhuis 2023-12-08 20:07:06 +01:00
parent 35f16c6003
commit 881cb16d28
2 changed files with 6 additions and 17 deletions

View File

@ -175,7 +175,12 @@ impl<'d, T: Instance> Adc<'d, T> {
} }
pub fn resolution(&self) -> Resolution { pub fn resolution(&self) -> Resolution {
T::regs().cr1().read().res().into() match T::regs().cr1().read().res() {
crate::pac::adc::vals::Res::TWELVEBIT => Resolution::TwelveBit,
crate::pac::adc::vals::Res::TENBIT => Resolution::TenBit,
crate::pac::adc::vals::Res::EIGHTBIT => Resolution::EightBit,
crate::pac::adc::vals::Res::SIXBIT => Resolution::SixBit,
}
} }
pub fn enable_vref(&self) -> Vref<T> { pub fn enable_vref(&self) -> Vref<T> {

View File

@ -48,22 +48,6 @@ impl From<Resolution> for crate::pac::adc::vals::Res {
} }
} }
impl From<crate::pac::adc::vals::Res> for Resolution {
fn from(res: crate::pac::adc::vals::Res) -> Resolution {
match res {
#[cfg(adc_v4)]
crate::pac::adc::vals::Res::SIXTEENBIT => Resolution::SixteenBit,
#[cfg(adc_v4)]
crate::pac::adc::vals::Res::FOURTEENBITV => Resolution::FourteenBit,
crate::pac::adc::vals::Res::TWELVEBIT => Resolution::TwelveBit,
crate::pac::adc::vals::Res::TENBIT => Resolution::TenBit,
crate::pac::adc::vals::Res::EIGHTBIT => Resolution::EightBit,
#[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1, adc_f3_v3))]
crate::pac::adc::vals::Res::SIXBIT => Resolution::SixBit,
}
}
}
impl Resolution { impl Resolution {
pub fn to_max_count(&self) -> u32 { pub fn to_max_count(&self) -> u32 {
match self { match self {