@@ -40,7 +40,7 @@ pub struct Adc<ADC> {
40
40
/// ADC Register
41
41
pub rb : ADC ,
42
42
clocks : Clocks ,
43
- ckmode : CkMode ,
43
+ clock_mode : ClockMode ,
44
44
operation_mode : Option < OperationMode > ,
45
45
}
46
46
@@ -121,10 +121,10 @@ pub enum OperationMode {
121
121
}
122
122
123
123
#[ derive( Clone , Copy , PartialEq ) ]
124
- /// ADC CkMode
125
- // TODO: Add ASYNCHRONOUS mode
124
+ /// ADC Clock Mode
125
+ // TODO: Add Asynchronous mode
126
126
#[ non_exhaustive]
127
- pub enum CkMode {
127
+ pub enum ClockMode {
128
128
// /// Use Kernel Clock adc_ker_ck_input divided by PRESC. Asynchronous to AHB clock
129
129
// Asynchronous,
130
130
/// Use AHB clock rcc_hclk3. In this case rcc_hclk must equal sys_d1cpre_ck
@@ -135,20 +135,20 @@ pub enum CkMode {
135
135
SyncDiv4 ,
136
136
}
137
137
138
- impl Default for CkMode {
138
+ impl Default for ClockMode {
139
139
fn default ( ) -> Self {
140
- CkMode :: SyncDiv2
140
+ ClockMode :: SyncDiv2
141
141
}
142
142
}
143
143
144
144
// ADC3_2 returns a pointer to a adc1_2 type, so this from is ok for both.
145
- impl From < CkMode > for CKMODE_A {
146
- fn from ( ckmode : CkMode ) -> Self {
147
- match ckmode {
148
- //CkMode ::Asynchronous => CKMODE_A::ASYNCHRONOUS,
149
- CkMode :: SyncDiv1 => CKMODE_A :: SYNCDIV1 ,
150
- CkMode :: SyncDiv2 => CKMODE_A :: SYNCDIV2 ,
151
- CkMode :: SyncDiv4 => CKMODE_A :: SYNCDIV4 ,
145
+ impl From < ClockMode > for CKMODE_A {
146
+ fn from ( clock_mode : ClockMode ) -> Self {
147
+ match clock_mode {
148
+ //ClockMode ::Asynchronous => CKMODE_A::ASYNCHRONOUS,
149
+ ClockMode :: SyncDiv1 => CKMODE_A :: SYNCDIV1 ,
150
+ ClockMode :: SyncDiv2 => CKMODE_A :: SYNCDIV2 ,
151
+ ClockMode :: SyncDiv4 => CKMODE_A :: SYNCDIV4 ,
152
152
}
153
153
}
154
154
}
@@ -315,13 +315,13 @@ macro_rules! adc_hal {
315
315
rb: $ADC,
316
316
adc_common : & mut $ADC_COMMON,
317
317
ahb: & mut AHB ,
318
- ckmode : CkMode ,
318
+ clock_mode : ClockMode ,
319
319
clocks: Clocks ,
320
320
) -> Self {
321
321
let mut this_adc = Self {
322
322
rb,
323
323
clocks,
324
- ckmode ,
324
+ clock_mode ,
325
325
operation_mode: None ,
326
326
} ;
327
327
if !( this_adc. clocks_welldefined( clocks) ) {
@@ -347,10 +347,10 @@ macro_rules! adc_hal {
347
347
self . rb
348
348
}
349
349
350
- /// Software can use CkMode ::SyncDiv1 only if
350
+ /// Software can use ClockMode ::SyncDiv1 only if
351
351
/// hclk and sysclk are the same. (see reference manual 15.3.3)
352
352
fn clocks_welldefined( & self , clocks: Clocks ) -> bool {
353
- if ( self . ckmode == CkMode :: SyncDiv1 ) {
353
+ if ( self . clock_mode == ClockMode :: SyncDiv1 ) {
354
354
clocks. hclk( ) . 0 == clocks. sysclk( ) . 0
355
355
} else {
356
356
true
@@ -441,10 +441,10 @@ macro_rules! adc_hal {
441
441
// using a match statement here so compilation will fail once asynchronous clk
442
442
// mode is implemented (CKMODE[1:0] = 00b). This will force whoever is working
443
443
// on it to rethink what needs to be done here :)
444
- let adc_per_cpu_cycles = match self . ckmode {
445
- CkMode :: SyncDiv1 => 1 ,
446
- CkMode :: SyncDiv2 => 2 ,
447
- CkMode :: SyncDiv4 => 4 ,
444
+ let adc_per_cpu_cycles = match self . clock_mode {
445
+ ClockMode :: SyncDiv1 => 1 ,
446
+ ClockMode :: SyncDiv2 => 2 ,
447
+ ClockMode :: SyncDiv4 => 4 ,
448
448
} ;
449
449
asm:: delay( adc_per_cpu_cycles * cycles) ;
450
450
}
@@ -542,11 +542,11 @@ macro_rules! adc12_hal {
542
542
/// or the clock was already enabled with the same settings
543
543
fn enable_clock( & self , ahb: & mut AHB , adc_common: & mut ADC1_2 ) -> bool {
544
544
if ahb. enr( ) . read( ) . adc12en( ) . is_enabled( ) {
545
- return ( adc_common. ccr. read( ) . ckmode( ) . variant( ) == self . ckmode . into( ) ) ;
545
+ return ( adc_common. ccr. read( ) . ckmode( ) . variant( ) == self . clock_mode . into( ) ) ;
546
546
}
547
547
ahb. enr( ) . modify( |_, w| w. adc12en( ) . enabled( ) ) ;
548
548
adc_common. ccr. modify( |_, w| w
549
- . ckmode( ) . variant( self . ckmode . into( ) )
549
+ . ckmode( ) . variant( self . clock_mode . into( ) )
550
550
) ;
551
551
true
552
552
}
@@ -572,11 +572,11 @@ macro_rules! adc34_hal {
572
572
/// or the clock was already enabled with the same settings
573
573
fn enable_clock( & self , ahb: & mut AHB , adc_common: & mut ADC3_4 ) -> bool {
574
574
if ahb. enr( ) . read( ) . adc34en( ) . is_enabled( ) {
575
- return ( adc_common. ccr. read( ) . ckmode( ) . variant( ) == self . ckmode . into( ) ) ;
575
+ return ( adc_common. ccr. read( ) . ckmode( ) . variant( ) == self . clock_mode . into( ) ) ;
576
576
}
577
577
ahb. enr( ) . modify( |_, w| w. adc34en( ) . enabled( ) ) ;
578
578
adc_common. ccr. modify( |_, w| w
579
- . ckmode( ) . variant( self . ckmode . into( ) )
579
+ . ckmode( ) . variant( self . clock_mode . into( ) )
580
580
) ;
581
581
true
582
582
}
0 commit comments