3
3
use core:: {
4
4
convert:: Infallible ,
5
5
marker:: PhantomData ,
6
- ops:: DerefMut ,
7
- sync:: atomic:: { self , Ordering } ,
6
+ // ops::DerefMut,
7
+ // sync::atomic::{self, Ordering},
8
8
} ;
9
-
9
+ # [ cfg ( feature = "dma" ) ]
10
10
use stable_deref_trait:: StableDeref ;
11
11
12
+ #[ cfg( feature = "dma" ) ]
12
13
use crate :: {
13
14
dma:: { dma1, Event as DMAEvent , RxDma , Transfer , TransferPayload , W } ,
14
15
dmamux:: { DmaInput , DmaMux } ,
16
+ } ;
17
+ use crate :: {
15
18
gpio:: { self , Analog } ,
16
19
hal:: {
17
20
adc:: { Channel as EmbeddedHalChannel , OneShot } ,
@@ -279,6 +282,7 @@ where
279
282
}
280
283
}
281
284
285
+ #[ cfg( feature = "dma" ) ]
282
286
impl TransferPayload for RxDma < Adc < ADC1 > , dma1:: C1 > {
283
287
fn start ( & mut self ) {
284
288
self . channel . start ( ) ;
@@ -289,13 +293,15 @@ impl TransferPayload for RxDma<Adc<ADC1>, dma1::C1> {
289
293
}
290
294
}
291
295
296
+ #[ cfg( feature = "dma" ) ]
292
297
impl RxDma < Adc < ADC1 > , dma1:: C1 > {
293
298
pub fn split ( mut self ) -> ( Adc < ADC1 > , dma1:: C1 ) {
294
299
self . stop ( ) ;
295
300
( self . payload , self . channel )
296
301
}
297
302
}
298
303
304
+ #[ cfg( feature = "dma" ) ]
299
305
impl < BUFFER , const N : usize > Transfer < W , BUFFER , RxDma < Adc < ADC1 > , dma1:: C1 > >
300
306
where
301
307
BUFFER : Sized + StableDeref < Target = [ u16 ; N ] > + DerefMut + ' static ,
@@ -675,15 +681,7 @@ macro_rules! adc {
675
681
delay: & mut impl DelayUs <u32 >,
676
682
) -> Self {
677
683
// Select system clock as ADC clock source
678
- ccipr. ccipr( ) . modify( |_, w| {
679
- // This is sound, as `0b11` is a valid value for this field.
680
- unsafe {
681
- // TODO: Switch to enum once https://github.com/stm32-rs/stm32-rs/pull/720 is released.
682
- w. adcsel( ) . bits( 0b11 ) ;
683
- }
684
-
685
- w
686
- } ) ;
684
+ ccipr. ccipr( ) . modify( |_, w| w. adcsel( ) . sysclk( ) ) ;
687
685
688
686
// Initialize the ADC, according to the STM32L4xx Reference Manual,
689
687
// section 16.4.6.
0 commit comments