Skip to content

Commit f55163c

Browse files
committed
Ran rustfmt on the code
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
1 parent 4c81088 commit f55163c

File tree

4 files changed

+45
-34
lines changed

4 files changed

+45
-34
lines changed

examples/adc_values.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ fn main() -> ! {
6363

6464
// Move all components under Mutex supervision
6565
cortex_m::interrupt::free(move |cs| {
66-
*SHARED.borrow(cs).borrow_mut() = Some(Shared {
67-
adc,
68-
tx,
69-
});
66+
*SHARED.borrow(cs).borrow_mut() = Some(Shared { adc, tx });
7067
});
7168
}
7269

@@ -85,7 +82,7 @@ fn SysTick() -> ! {
8582
if let Some(ref mut shared) = SHARED.borrow(cs).borrow_mut().deref_mut() {
8683
// Read temperature data from internal sensor using ADC
8784
let t = hal::adc::VTemp::read(&mut shared.adc, None);
88-
writeln!(shared.tx, "Temperature {}.{}C\r", t/100, t%100).ok();
85+
writeln!(shared.tx, "Temperature {}.{}C\r", t / 100, t % 100).ok();
8986

9087
// Read volatage reference data from internal sensor using ADC
9188
let t = hal::adc::VRef::read_vdda(&mut shared.adc);

src/rcc.rs

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::cmp;
21
use crate::time::Hertz;
32

43
/// Extension trait that constrains the `RCC` peripheral
@@ -112,7 +111,7 @@ impl CFGR {
112111
} else {
113112
src_clk_freq = HSI; // If no clock source is selected use HSI.
114113
}
115-
114+
116115
// Pll check
117116
if sysclk == src_clk_freq {
118117
// Bypass pll if src clk and requested sysclk are the same, to save power.
@@ -121,8 +120,9 @@ impl CFGR {
121120
pllmul_bits = None;
122121
r_sysclk = src_clk_freq;
123122
} else {
124-
let pllmul = (4 * self.sysclk.unwrap_or(src_clk_freq) + src_clk_freq) / src_clk_freq / 2;
125-
let pllmul = cmp::min(cmp::max(pllmul, 2), 16);
123+
let pllmul =
124+
(4 * self.sysclk.unwrap_or(src_clk_freq) + src_clk_freq) / src_clk_freq / 2;
125+
let pllmul = core::cmp::min(core::cmp::max(pllmul, 2), 16);
126126
r_sysclk = pllmul * src_clk_freq / 2;
127127

128128
pllmul_bits = if pllmul == 2 {
@@ -182,17 +182,17 @@ impl CFGR {
182182
let rcc = unsafe { &*crate::stm32::RCC::ptr() };
183183

184184
// Set up rcc based on above calculated configuration.
185-
185+
186186
// Enable requested clock sources
187187
// HSI
188188
if self.enable_hsi {
189189
rcc.cr.write(|w| w.hsion().set_bit());
190-
while rcc.cr.read().hsirdy().bit_is_clear() { }
190+
while rcc.cr.read().hsirdy().bit_is_clear() {}
191191
}
192192
// HSI48
193193
if self.enable_hsi48 {
194194
rcc.cr2.modify(|_, w| w.hsi48on().set_bit());
195-
while rcc.cr2.read().hsi48rdy().bit_is_clear() { }
195+
while rcc.cr2.read().hsi48rdy().bit_is_clear() {}
196196
}
197197

198198
// Enable PLL
@@ -201,15 +201,18 @@ impl CFGR {
201201

202202
// Set PLL source based on configuration.
203203
if self.enable_hsi48 {
204-
rcc.cfgr.modify(|_, w| w.pllsrc().bits(PllSource::HSI48 as u8));
204+
rcc.cfgr
205+
.modify(|_, w| w.pllsrc().bits(PllSource::HSI48 as u8));
205206
} else if self.enable_hsi {
206-
rcc.cfgr.modify(|_, w| w.pllsrc().bits(PllSource::HSI_DIV2 as u8));
207+
rcc.cfgr
208+
.modify(|_, w| w.pllsrc().bits(PllSource::HSI_DIV2 as u8));
207209
} else {
208-
rcc.cfgr.modify(|_, w| w.pllsrc().bits(PllSource::HSI_DIV2 as u8));
210+
rcc.cfgr
211+
.modify(|_, w| w.pllsrc().bits(PllSource::HSI_DIV2 as u8));
209212
}
210213

211214
rcc.cr.write(|w| w.pllon().set_bit());
212-
while rcc.cr.read().pllrdy().bit_is_clear() { }
215+
while rcc.cr.read().pllrdy().bit_is_clear() {}
213216

214217
rcc.cfgr.modify(|_, w| unsafe {
215218
w.ppre()
@@ -219,30 +222,40 @@ impl CFGR {
219222
.sw()
220223
.bits(SysClkSource::PLL as u8)
221224
});
222-
223-
} else { // No PLL required.
225+
} else {
226+
// No PLL required.
224227
// Setup requested clocks.
225228
if self.enable_hsi48 {
226-
rcc.cfgr.modify(|_, w| unsafe {
227-
w.ppre().bits(ppre_bits)
228-
.hpre().bits(hpre_bits)
229-
.sw().bits(SysClkSource::HSI48 as u8)
229+
rcc.cfgr.modify(|_, w| unsafe {
230+
w.ppre()
231+
.bits(ppre_bits)
232+
.hpre()
233+
.bits(hpre_bits)
234+
.sw()
235+
.bits(SysClkSource::HSI48 as u8)
230236
});
231237
} else if self.enable_hsi {
232-
rcc.cfgr.modify(|_, w| unsafe {
233-
w.ppre().bits(ppre_bits)
234-
.hpre().bits(hpre_bits)
235-
.sw().bits(SysClkSource::HSI as u8)
238+
rcc.cfgr.modify(|_, w| unsafe {
239+
w.ppre()
240+
.bits(ppre_bits)
241+
.hpre()
242+
.bits(hpre_bits)
243+
.sw()
244+
.bits(SysClkSource::HSI as u8)
236245
});
237-
} else { // Default to HSI
246+
} else {
247+
// Default to HSI
238248
rcc.cfgr.modify(|_, w| unsafe {
239-
w.ppre().bits(ppre_bits)
240-
.hpre().bits(hpre_bits)
241-
.sw().bits(SysClkSource::HSI as u8)
249+
w.ppre()
250+
.bits(ppre_bits)
251+
.hpre()
252+
.bits(hpre_bits)
253+
.sw()
254+
.bits(SysClkSource::HSI as u8)
242255
});
243256
}
244257
}
245-
258+
246259
Clocks {
247260
hclk: Hertz(hclk),
248261
pclk: Hertz(pclk),

src/serial.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use embedded_hal::prelude::*;
3636
#[allow(unused)]
3737
use crate::{gpio::*, rcc::Clocks, time::Bps};
3838

39-
4039
/// Serial error
4140
#[derive(Debug)]
4241
pub enum Error {

src/spi.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,13 @@ impl<SPI, SCKPIN, MISOPIN, MOSIPIN> ::embedded_hal::blocking::spi::transfer::Def
281281
for Spi<SPI, SCKPIN, MISOPIN, MOSIPIN>
282282
where
283283
SPI: Deref<Target = SpiRegisterBlock>,
284-
{}
284+
{
285+
}
285286

286287
#[cfg(feature = "device-selected")]
287288
impl<SPI, SCKPIN, MISOPIN, MOSIPIN> ::embedded_hal::blocking::spi::write::Default<u8>
288289
for Spi<SPI, SCKPIN, MISOPIN, MOSIPIN>
289290
where
290291
SPI: Deref<Target = SpiRegisterBlock>,
291-
{}
292+
{
293+
}

0 commit comments

Comments
 (0)