diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-12-08 20:07:06 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-12-08 20:07:06 +0100 |
| commit | 881cb16d2809cf84757b7ecabcad44be0d97fa14 (patch) | |
| tree | 7b295dafcd46a1ad094b8a2ae66fbc9230d0a42a | |
| parent | 35f16c6003b4be69ee18d24440560ce8a700169c (diff) | |
stm32/adc: move convert resolution from PAC to version-specific mod.
| -rw-r--r-- | embassy-stm32/src/adc/f3_v1_1.rs | 7 | ||||
| -rw-r--r-- | embassy-stm32/src/adc/resolution.rs | 16 |
2 files changed, 6 insertions, 17 deletions
diff --git a/embassy-stm32/src/adc/f3_v1_1.rs b/embassy-stm32/src/adc/f3_v1_1.rs index 0bbfd3137..6915a8f1c 100644 --- a/embassy-stm32/src/adc/f3_v1_1.rs +++ b/embassy-stm32/src/adc/f3_v1_1.rs | |||
| @@ -175,7 +175,12 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | pub fn resolution(&self) -> Resolution { | 177 | pub fn resolution(&self) -> Resolution { |
| 178 | T::regs().cr1().read().res().into() | 178 | match T::regs().cr1().read().res() { |
| 179 | crate::pac::adc::vals::Res::TWELVEBIT => Resolution::TwelveBit, | ||
| 180 | crate::pac::adc::vals::Res::TENBIT => Resolution::TenBit, | ||
| 181 | crate::pac::adc::vals::Res::EIGHTBIT => Resolution::EightBit, | ||
| 182 | crate::pac::adc::vals::Res::SIXBIT => Resolution::SixBit, | ||
| 183 | } | ||
| 179 | } | 184 | } |
| 180 | 185 | ||
| 181 | pub fn enable_vref(&self) -> Vref<T> { | 186 | pub fn enable_vref(&self) -> Vref<T> { |
diff --git a/embassy-stm32/src/adc/resolution.rs b/embassy-stm32/src/adc/resolution.rs index b1597a821..383980b5a 100644 --- a/embassy-stm32/src/adc/resolution.rs +++ b/embassy-stm32/src/adc/resolution.rs | |||
| @@ -48,22 +48,6 @@ impl From<Resolution> for crate::pac::adc::vals::Res { | |||
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | impl From<crate::pac::adc::vals::Res> for Resolution { | ||
| 52 | fn from(res: crate::pac::adc::vals::Res) -> Resolution { | ||
| 53 | match res { | ||
| 54 | #[cfg(adc_v4)] | ||
| 55 | crate::pac::adc::vals::Res::SIXTEENBIT => Resolution::SixteenBit, | ||
| 56 | #[cfg(adc_v4)] | ||
| 57 | crate::pac::adc::vals::Res::FOURTEENBITV => Resolution::FourteenBit, | ||
| 58 | crate::pac::adc::vals::Res::TWELVEBIT => Resolution::TwelveBit, | ||
| 59 | crate::pac::adc::vals::Res::TENBIT => Resolution::TenBit, | ||
| 60 | crate::pac::adc::vals::Res::EIGHTBIT => Resolution::EightBit, | ||
| 61 | #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1, adc_f3_v3))] | ||
| 62 | crate::pac::adc::vals::Res::SIXBIT => Resolution::SixBit, | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | impl Resolution { | 51 | impl Resolution { |
| 68 | pub fn to_max_count(&self) -> u32 { | 52 | pub fn to_max_count(&self) -> u32 { |
| 69 | match self { | 53 | match self { |
