diff options
| author | Grant Miller <[email protected]> | 2023-04-05 16:11:21 -0500 |
|---|---|---|
| committer | Grant Miller <[email protected]> | 2023-04-05 16:11:21 -0500 |
| commit | 20e7b5e2965f718aa1a0ece6009356ba50d2d780 (patch) | |
| tree | 6a9b97f075c8e5d1bea088170cd367b4d79ebb83 | |
| parent | 37d8f2e51256403cc4839c3b45e5c2253e3a09f1 (diff) | |
InternalChannel
| -rw-r--r-- | embassy-stm32/src/adc/v1.rs | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/embassy-stm32/src/adc/v1.rs b/embassy-stm32/src/adc/v1.rs index a699d8f74..5f0f8c141 100644 --- a/embassy-stm32/src/adc/v1.rs +++ b/embassy-stm32/src/adc/v1.rs | |||
| @@ -1,39 +1,32 @@ | |||
| 1 | use embassy_hal_common::into_ref; | 1 | use embassy_hal_common::into_ref; |
| 2 | use embedded_hal_02::blocking::delay::DelayUs; | 2 | use embedded_hal_02::blocking::delay::DelayUs; |
| 3 | 3 | ||
| 4 | use crate::adc::{Adc, AdcPin, Instance, Resolution, SampleTime}; | 4 | use crate::adc::{Adc, AdcPin, Instance, InternalChannel, Resolution, SampleTime}; |
| 5 | use crate::Peripheral; | 5 | use crate::Peripheral; |
| 6 | use crate::peripherals::ADC1; | ||
| 6 | 7 | ||
| 7 | pub const VDDA_CALIB_MV: u32 = 3300; | 8 | pub const VDDA_CALIB_MV: u32 = 3300; |
| 8 | pub const VREF_INT: u32 = 1230; | 9 | pub const VREF_INT: u32 = 1230; |
| 9 | 10 | ||
| 10 | pub trait InternalChannel<T>: sealed::InternalChannel<T> {} | ||
| 11 | |||
| 12 | mod sealed { | ||
| 13 | pub trait InternalChannel<T> { | ||
| 14 | fn channel(&self) -> u8; | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | pub struct Vbat; | 11 | pub struct Vbat; |
| 19 | impl<T: Instance> InternalChannel<T> for Vbat {} | 12 | impl InternalChannel<ADC1> for Vbat {} |
| 20 | impl<T: Instance> sealed::InternalChannel<T> for Vbat { | 13 | impl super::sealed::InternalChannel<ADC1> for Vbat { |
| 21 | fn channel(&self) -> u8 { | 14 | fn channel(&self) -> u8 { |
| 22 | 18 | 15 | 18 |
| 23 | } | 16 | } |
| 24 | } | 17 | } |
| 25 | 18 | ||
| 26 | pub struct Vref; | 19 | pub struct Vref; |
| 27 | impl<T: Instance> InternalChannel<T> for Vref {} | 20 | impl InternalChannel<ADC1> for Vref {} |
| 28 | impl<T: Instance> sealed::InternalChannel<T> for Vref { | 21 | impl super::sealed::::InternalChannel<ADC1> for Vref { |
| 29 | fn channel(&self) -> u8 { | 22 | fn channel(&self) -> u8 { |
| 30 | 17 | 23 | 17 |
| 31 | } | 24 | } |
| 32 | } | 25 | } |
| 33 | 26 | ||
| 34 | pub struct Temperature; | 27 | pub struct Temperature; |
| 35 | impl<T: Instance> InternalChannel<T> for Temperature {} | 28 | impl InternalChannel<ADC1> for Temperature {} |
| 36 | impl<T: Instance> sealed::InternalChannel<T> for Temperature { | 29 | impl super::sealed::InternalChannel<ADC1> for Temperature { |
| 37 | fn channel(&self) -> u8 { | 30 | fn channel(&self) -> u8 { |
| 38 | 16 | 31 | 16 |
| 39 | } | 32 | } |
