aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Miller <[email protected]>2023-04-05 16:11:21 -0500
committerGrant Miller <[email protected]>2023-04-05 16:11:21 -0500
commit20e7b5e2965f718aa1a0ece6009356ba50d2d780 (patch)
tree6a9b97f075c8e5d1bea088170cd367b4d79ebb83
parent37d8f2e51256403cc4839c3b45e5c2253e3a09f1 (diff)
InternalChannel
-rw-r--r--embassy-stm32/src/adc/v1.rs23
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 @@
1use embassy_hal_common::into_ref; 1use embassy_hal_common::into_ref;
2use embedded_hal_02::blocking::delay::DelayUs; 2use embedded_hal_02::blocking::delay::DelayUs;
3 3
4use crate::adc::{Adc, AdcPin, Instance, Resolution, SampleTime}; 4use crate::adc::{Adc, AdcPin, Instance, InternalChannel, Resolution, SampleTime};
5use crate::Peripheral; 5use crate::Peripheral;
6use crate::peripherals::ADC1;
6 7
7pub const VDDA_CALIB_MV: u32 = 3300; 8pub const VDDA_CALIB_MV: u32 = 3300;
8pub const VREF_INT: u32 = 1230; 9pub const VREF_INT: u32 = 1230;
9 10
10pub trait InternalChannel<T>: sealed::InternalChannel<T> {}
11
12mod sealed {
13 pub trait InternalChannel<T> {
14 fn channel(&self) -> u8;
15 }
16}
17
18pub struct Vbat; 11pub struct Vbat;
19impl<T: Instance> InternalChannel<T> for Vbat {} 12impl InternalChannel<ADC1> for Vbat {}
20impl<T: Instance> sealed::InternalChannel<T> for Vbat { 13impl 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
26pub struct Vref; 19pub struct Vref;
27impl<T: Instance> InternalChannel<T> for Vref {} 20impl InternalChannel<ADC1> for Vref {}
28impl<T: Instance> sealed::InternalChannel<T> for Vref { 21impl 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
34pub struct Temperature; 27pub struct Temperature;
35impl<T: Instance> InternalChannel<T> for Temperature {} 28impl InternalChannel<ADC1> for Temperature {}
36impl<T: Instance> sealed::InternalChannel<T> for Temperature { 29impl super::sealed::InternalChannel<ADC1> for Temperature {
37 fn channel(&self) -> u8 { 30 fn channel(&self) -> u8 {
38 16 31 16
39 } 32 }