Skip to content

Commit b28b91e

Browse files
committed
Rename CkMode to ClockMode
1 parent 59f2917 commit b28b91e

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
112112
example. ([#266])
113113
- Adc's `SampleTime` type has been reworked and is now a consistent wrapper around
114114
the underlying types for `stm32f3`'s `SMP9_A` and `SMP18_A` type. ([#266])
115+
- Rename `CkMode` to `ClockMode` ([#266])
115116

116117
## [v0.7.0] - 2021-06-18
117118

examples/adc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() -> ! {
2626
// correctly.
2727
&mut dp.ADC1_2,
2828
&mut rcc.ahb,
29-
adc::CkMode::default(),
29+
adc::ClockMode::default(),
3030
clocks,
3131
);
3232

src/adc.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Adc<ADC> {
4040
/// ADC Register
4141
pub rb: ADC,
4242
clocks: Clocks,
43-
ckmode: CkMode,
43+
clock_mode: ClockMode,
4444
operation_mode: Option<OperationMode>,
4545
}
4646

@@ -121,10 +121,10 @@ pub enum OperationMode {
121121
}
122122

123123
#[derive(Clone, Copy, PartialEq)]
124-
/// ADC CkMode
125-
// TODO: Add ASYNCHRONOUS mode
124+
/// ADC Clock Mode
125+
// TODO: Add Asynchronous mode
126126
#[non_exhaustive]
127-
pub enum CkMode {
127+
pub enum ClockMode {
128128
// /// Use Kernel Clock adc_ker_ck_input divided by PRESC. Asynchronous to AHB clock
129129
// Asynchronous,
130130
/// Use AHB clock rcc_hclk3. In this case rcc_hclk must equal sys_d1cpre_ck
@@ -135,20 +135,20 @@ pub enum CkMode {
135135
SyncDiv4,
136136
}
137137

138-
impl Default for CkMode {
138+
impl Default for ClockMode {
139139
fn default() -> Self {
140-
CkMode::SyncDiv2
140+
ClockMode::SyncDiv2
141141
}
142142
}
143143

144144
// 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,
152152
}
153153
}
154154
}
@@ -315,13 +315,13 @@ macro_rules! adc_hal {
315315
rb: $ADC,
316316
adc_common : &mut $ADC_COMMON,
317317
ahb: &mut AHB,
318-
ckmode: CkMode,
318+
clock_mode: ClockMode,
319319
clocks: Clocks,
320320
) -> Self {
321321
let mut this_adc = Self {
322322
rb,
323323
clocks,
324-
ckmode,
324+
clock_mode,
325325
operation_mode: None,
326326
};
327327
if !(this_adc.clocks_welldefined(clocks)) {
@@ -347,10 +347,10 @@ macro_rules! adc_hal {
347347
self.rb
348348
}
349349

350-
/// Software can use CkMode::SyncDiv1 only if
350+
/// Software can use ClockMode::SyncDiv1 only if
351351
/// hclk and sysclk are the same. (see reference manual 15.3.3)
352352
fn clocks_welldefined(&self, clocks: Clocks) -> bool {
353-
if (self.ckmode == CkMode::SyncDiv1) {
353+
if (self.clock_mode == ClockMode::SyncDiv1) {
354354
clocks.hclk().0 == clocks.sysclk().0
355355
} else {
356356
true
@@ -441,10 +441,10 @@ macro_rules! adc_hal {
441441
// using a match statement here so compilation will fail once asynchronous clk
442442
// mode is implemented (CKMODE[1:0] = 00b). This will force whoever is working
443443
// 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,
448448
};
449449
asm::delay(adc_per_cpu_cycles * cycles);
450450
}
@@ -542,11 +542,11 @@ macro_rules! adc12_hal {
542542
/// or the clock was already enabled with the same settings
543543
fn enable_clock(&self, ahb: &mut AHB, adc_common: &mut ADC1_2) -> bool {
544544
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());
546546
}
547547
ahb.enr().modify(|_, w| w.adc12en().enabled());
548548
adc_common.ccr.modify(|_, w| w
549-
.ckmode().variant(self.ckmode.into())
549+
.ckmode().variant(self.clock_mode.into())
550550
);
551551
true
552552
}
@@ -572,11 +572,11 @@ macro_rules! adc34_hal {
572572
/// or the clock was already enabled with the same settings
573573
fn enable_clock(&self, ahb: &mut AHB, adc_common: &mut ADC3_4) -> bool {
574574
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());
576576
}
577577
ahb.enr().modify(|_, w| w.adc34en().enabled());
578578
adc_common.ccr.modify(|_, w| w
579-
.ckmode().variant(self.ckmode.into())
579+
.ckmode().variant(self.clock_mode.into())
580580
);
581581
true
582582
}

testsuite/tests/adc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mod tests {
5252
dp.ADC1,
5353
&mut dp.ADC1_2,
5454
&mut rcc.ahb,
55-
adc::CkMode::default(),
55+
adc::ClockMode::default(),
5656
clocks,
5757
)),
5858
analog: pair.0,
@@ -94,7 +94,7 @@ mod tests {
9494
adc1,
9595
&mut state.adc1_2,
9696
&mut state.ahb,
97-
adc::CkMode::default(),
97+
adc::ClockMode::default(),
9898
state.clocks,
9999
);
100100

0 commit comments

Comments
 (0)