3333//! }
3434//! ```
3535
36+ #[ cfg( feature = "device-selected" ) ]
3637use embedded_hal:: adc:: { Channel , OneShot } ;
3738
38- use crate :: stm32;
39-
40- use crate :: gpio:: * ;
39+ #[ cfg( feature = "device-selected" ) ]
40+ use crate :: { stm32, gpio:: * } ;
4141
42+ #[ cfg( feature = "device-selected" ) ]
4243/// Analog to Digital converter interface
4344pub struct Adc {
4445 rb : stm32:: ADC ,
@@ -70,6 +71,7 @@ pub enum AdcSampleTime {
7071 T_239 ,
7172}
7273
74+ #[ cfg( feature = "device-selected" ) ]
7375impl AdcSampleTime {
7476 fn write_bits ( & self , adc : & mut stm32:: ADC ) {
7577 unsafe {
@@ -117,6 +119,7 @@ pub enum AdcAlign {
117119 LeftAsRM ,
118120}
119121
122+ #[ cfg( feature = "device-selected" ) ]
120123impl AdcAlign {
121124 fn write_bits ( & self , adc : & mut stm32:: ADC ) {
122125 adc. cfgr1 . write ( |w| {
@@ -147,6 +150,7 @@ pub enum AdcPrecision {
147150 B_6 ,
148151}
149152
153+ #[ cfg( feature = "device-selected" ) ]
150154impl AdcPrecision {
151155 fn write_bits ( & self , adc : & mut stm32:: ADC ) {
152156 unsafe {
@@ -167,6 +171,7 @@ impl AdcPrecision {
167171 }
168172}
169173
174+ #[ cfg( feature = "device-selected" ) ]
170175macro_rules! adc_pins {
171176 ( $( $pin: ty => $chan: expr) ,+ $( , ) * ) => {
172177 $(
@@ -179,7 +184,7 @@ macro_rules! adc_pins {
179184 } ;
180185}
181186
182- #[ cfg( any ( feature = "stm32f042" , feature = "stm32f030" , feature = "stm32f070" , ) ) ]
187+ #[ cfg( feature = "device-selected" ) ]
183188adc_pins ! (
184189 gpioa:: PA0 <Analog > => 0_u8 ,
185190 gpioa:: PA1 <Analog > => 1_u8 ,
@@ -211,11 +216,13 @@ pub struct VTemp;
211216/// Internal voltage reference (ADC Channel 17)
212217pub struct VRef ;
213218
219+ #[ cfg( feature = "device-selected" ) ]
214220adc_pins ! (
215221 VTemp => 16_u8 ,
216222 VRef => 17_u8 ,
217223) ;
218224
225+ #[ cfg( feature = "device-selected" ) ]
219226impl VTemp {
220227 /// Init a new VTemp
221228 pub fn new ( ) -> Self {
@@ -236,6 +243,7 @@ impl VTemp {
236243 }
237244}
238245
246+ #[ cfg( feature = "device-selected" ) ]
239247impl VRef {
240248 /// Init a new VRef
241249 pub fn new ( ) -> Self {
@@ -253,17 +261,17 @@ impl VRef {
253261 }
254262}
255263
256- #[ cfg( any ( feature = "stm32f042" , ) ) ]
264+ #[ cfg( feature = "stm32f042" ) ]
257265#[ derive( Debug ) ]
258266/// Battery reference voltage (ADC Channel 18)
259267pub struct VBat ;
260268
261- #[ cfg( any ( feature = "stm32f042" , ) ) ]
269+ #[ cfg( feature = "stm32f042" ) ]
262270adc_pins ! (
263271 VBat => 18_u8 ,
264272) ;
265273
266- #[ cfg( any ( feature = "stm32f042" , ) ) ]
274+ #[ cfg( feature = "stm32f042" ) ]
267275impl VBat {
268276 /// Init a new VBat
269277 pub fn new ( ) -> Self {
@@ -282,6 +290,7 @@ impl VBat {
282290 }
283291}
284292
293+ #[ cfg( feature = "device-selected" ) ]
285294impl Adc {
286295 /// Init a new Adc
287296 ///
@@ -381,6 +390,7 @@ impl Adc {
381390 }
382391}
383392
393+ #[ cfg( feature = "device-selected" ) ]
384394impl < WORD , PIN > OneShot < Adc , WORD , PIN > for Adc
385395where
386396 WORD : From < u16 > ,
0 commit comments