33use core:: {
44 convert:: Infallible ,
55 marker:: PhantomData ,
6- ops:: DerefMut ,
7- sync:: atomic:: { self , Ordering } ,
6+ // ops::DerefMut,
7+ // sync::atomic::{self, Ordering},
88} ;
9-
9+ # [ cfg ( feature = "dma" ) ]
1010use stable_deref_trait:: StableDeref ;
1111
12+ #[ cfg( feature = "dma" ) ]
1213use crate :: {
1314 dma:: { dma1, Event as DMAEvent , RxDma , Transfer , TransferPayload , W } ,
1415 dmamux:: { DmaInput , DmaMux } ,
16+ } ;
17+ use crate :: {
1518 gpio:: { self , Analog } ,
1619 hal:: {
1720 adc:: { Channel as EmbeddedHalChannel , OneShot } ,
@@ -279,6 +282,7 @@ where
279282 }
280283}
281284
285+ #[ cfg( feature = "dma" ) ]
282286impl TransferPayload for RxDma < Adc < ADC1 > , dma1:: C1 > {
283287 fn start ( & mut self ) {
284288 self . channel . start ( ) ;
@@ -289,13 +293,15 @@ impl TransferPayload for RxDma<Adc<ADC1>, dma1::C1> {
289293 }
290294}
291295
296+ #[ cfg( feature = "dma" ) ]
292297impl RxDma < Adc < ADC1 > , dma1:: C1 > {
293298 pub fn split ( mut self ) -> ( Adc < ADC1 > , dma1:: C1 ) {
294299 self . stop ( ) ;
295300 ( self . payload , self . channel )
296301 }
297302}
298303
304+ #[ cfg( feature = "dma" ) ]
299305impl < BUFFER , const N : usize > Transfer < W , BUFFER , RxDma < Adc < ADC1 > , dma1:: C1 > >
300306where
301307 BUFFER : Sized + StableDeref < Target = [ u16 ; N ] > + DerefMut + ' static ,
@@ -675,15 +681,7 @@ macro_rules! adc {
675681 delay: & mut impl DelayUs <u32 >,
676682 ) -> Self {
677683 // 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( ) ) ;
687685
688686 // Initialize the ADC, according to the STM32L4xx Reference Manual,
689687 // section 16.4.6.
0 commit comments