Skip to content

Commit 2a75825

Browse files
committed
fix: fixed formatting issues
1 parent e693107 commit 2a75825

File tree

2 files changed

+50
-51
lines changed

2 files changed

+50
-51
lines changed

neotron-bmc-nucleo/src/main.rs

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use cortex_m::interrupt::free as disable_interrupts;
1212
use heapless::spsc::{Consumer, Producer, Queue};
1313
use rtic::app;
1414
use stm32f4xx_hal::{
15-
gpio::gpioc::{PC13, PC0, PC1, PC2, PC3, PC5},
1615
// Those pins are not used atm:
1716
// PC3: IRQ_nHOST
1817
// PA4: SPI1_NSS
@@ -25,8 +24,9 @@ use stm32f4xx_hal::{
2524
// PB7: I2C1_SDA
2625
// PB13: MON_3V3
2726
// PB13: MON_5V
28-
gpio::gpioa::{PA4, PA5, PA6, PA7, PA9, PA10, PA11, PA12, PA13, PA14},
29-
gpio::gpiob::{PB0, PB12, PB1, PB2, PB6, PB7, PB13, PB14, PB15},
27+
gpio::gpioa::{PA10, PA11, PA12, PA13, PA14, PA4, PA5, PA6, PA7, PA9},
28+
gpio::gpiob::{PB0, PB1, PB12, PB13, PB14, PB15, PB2, PB6, PB7},
29+
gpio::gpioc::{PC0, PC1, PC13, PC2, PC3, PC5},
3030
gpio::{Alternate, Edge, Floating, Input, Output, PullUp, PushPull},
3131
pac,
3232
prelude::*,
@@ -86,28 +86,31 @@ mod app {
8686
use fugit::ExtU32;
8787

8888
#[shared]
89-
struct Shared {
90-
/// The power LED CN6, pin 5
89+
struct Shared {
90+
/// The power LED CN6, pin 5
9191
#[lock_free]
9292
led_power: PC1<Output<PushPull>>,
93-
/// The status LED CN7, pin 35
93+
/// The status LED CN7, pin 35
9494
#[lock_free]
9595
led_status: PC2<Output<PushPull>>,
96-
/// The FTDI UART header (J105) PA9: CN10, pin 21 and PA10: CN10, pin 33
96+
/// The FTDI UART header (J105) PA9: CN10, pin 21 and PA10: CN10, pin 33
9797
#[lock_free]
98-
serial: serial::Serial<pac::USART1, (PA9<Alternate<PushPull, 7>>, PA10<Alternate<PushPull,7>>)>,
99-
/// The Clear-To-Send line on the FTDI UART header
100-
/// (which the serial object can't handle) CN10, pin 14
98+
serial: serial::Serial<
99+
pac::USART1,
100+
(PA9<Alternate<PushPull, 7>>, PA10<Alternate<PushPull, 7>>),
101+
>,
102+
/// The Clear-To-Send line on the FTDI UART header
103+
/// (which the serial object can't handle) CN10, pin 14
101104
#[lock_free]
102-
pin_uart_cts: PA11<Alternate<PushPull,7>>,
103-
/// The Ready-To-Receive line on the FTDI UART header
104-
/// (which the serial object can't handle) CN10, pin 12
105+
pin_uart_cts: PA11<Alternate<PushPull, 7>>,
106+
/// The Ready-To-Receive line on the FTDI UART header
107+
/// (which the serial object can't handle) CN10, pin 12
105108
#[lock_free]
106-
pin_uart_rts: PA12<Alternate<PushPull,7>>,
107-
/// The power button, CN7, pin 23
109+
pin_uart_rts: PA12<Alternate<PushPull, 7>>,
110+
/// The power button, CN7, pin 23
108111
#[lock_free]
109112
button_power: PC13<Input<PullUp>>,
110-
/// The reset button, CN10, pin 16
113+
/// The reset button, CN10, pin 16
111114
#[lock_free]
112115
button_reset: PB12<Input<PullUp>>,
113116
/// Tracks DC power state
@@ -117,19 +120,19 @@ mod app {
117120
#[lock_free]
118121
pin_dc_on: PC0<Output<PushPull>>,
119122
/// Controls the Reset signal across the main board, putting all the
120-
/// chips (except this BMC!) in reset when pulled low. CN10, pin 26
123+
/// chips (except this BMC!) in reset when pulled low. CN10, pin 26
121124
#[lock_free]
122125
pin_sys_reset: PB15<Output<PushPull>>,
123-
/// Clock pin for PS/2 Keyboard port, CN10, pin 6
126+
/// Clock pin for PS/2 Keyboard port, CN10, pin 6
124127
#[lock_free]
125128
ps2_clk0: PC5<Input<Floating>>,
126-
/// Clock pin for PS/2 Mouse port, CN8, pin 4
129+
/// Clock pin for PS/2 Mouse port, CN8, pin 4
127130
#[lock_free]
128131
ps2_clk1: PB0<Input<Floating>>,
129-
/// Data pin for PS/2 Keyboard port, CN10, pin 24
132+
/// Data pin for PS/2 Keyboard port, CN10, pin 24
130133
#[lock_free]
131134
ps2_dat0: PB1<Input<Floating>>,
132-
/// Data pin for PS/2 Mouse port, CN10, port 22
135+
/// Data pin for PS/2 Mouse port, CN10, port 22
133136
#[lock_free]
134137
ps2_dat1: PB2<Input<Floating>>,
135138
/// The external interrupt peripheral
@@ -138,7 +141,7 @@ mod app {
138141
/// Our register state
139142
#[lock_free]
140143
register_state: RegisterState,
141-
144+
142145
/// Mouse PS/2 decoder
143146
ms_decoder: Ps2Decoder,
144147
/// Keyboard bytes sink
@@ -147,27 +150,25 @@ mod app {
147150
/// Keyboard bytes source
148151
#[lock_free]
149152
kb_q_in: Producer<'static, u16, 8>,
150-
}
153+
}
151154

152155
#[local]
153-
struct Local {
154-
/// Tracks power button state for short presses.
156+
struct Local {
157+
/// Tracks power button state for short presses.
155158
/// 75ms x 2 = 150ms is a short press : DOES THE COMMENT MATCH?
156-
press_button_power_short: debouncr::Debouncer<u8, debouncr::Repeat2>,
157-
/// Tracks power button state for long presses.
159+
press_button_power_short: debouncr::Debouncer<u8, debouncr::Repeat2>,
160+
/// Tracks power button state for long presses.
158161
/// 75ms x 16 = 1200ms is a long press
159162
press_button_power_long: debouncr::Debouncer<u16, debouncr::Repeat16>,
160163
/// Tracks reset button state for long presses. 75ms x 16 = 1200ms is a long press
161164
press_button_reset_long: debouncr::Debouncer<u16, debouncr::Repeat16>,
162165
/// Keyboard PS/2 decoder
163166
kb_decoder: Ps2Decoder,
164-
}
167+
}
165168

166169
#[monotonic(binds = TIM2, default = true)]
167170
type MyMono = MonoTimer<pac::TIM2, 1_000_000>;
168171

169-
170-
171172
/// The entry point to our application.
172173
///
173174
/// Sets up the hardware and spawns the regular tasks.
@@ -196,7 +197,7 @@ mod app {
196197

197198
defmt::info!("Configuring TIM2...");
198199
let mono = MyMono::new(dp.TIM2, &clocks);
199-
200+
200201
defmt::info!("Creating pins...");
201202
let gpioa = dp.GPIOA.split();
202203
let gpiob = dp.GPIOB.split();
@@ -236,7 +237,7 @@ mod app {
236237
gpiob.pb15.into_push_pull_output(),
237238
//PS2_CLK0
238239
gpioc.pc5.into_floating_input(),
239-
//PS2_CLK1
240+
//PS2_CLK1
240241
gpiob.pb0.into_floating_input(),
241242
//PS2_DAT0
242243
gpiob.pb1.into_floating_input(),
@@ -256,12 +257,12 @@ mod app {
256257
// source : https://github.com/jamesmunns/pretty-hal-machine/blob/7f2f50c8c841c6d936a7147a092ec67bbb2602fa/firmware/blackpill-phm/src/main.rs#L103
257258

258259
let mut serial = serial::Serial::new(
259-
dp.USART1,
260-
(uart_tx, uart_rx),
261-
serial::config::Config::default().baudrate(115_200.bps()),
262-
&clocks,
263-
)
264-
.unwrap();
260+
dp.USART1,
261+
(uart_tx, uart_rx),
262+
serial::config::Config::default().baudrate(115_200.bps()),
263+
&clocks,
264+
)
265+
.unwrap();
265266
serial.listen(serial::Event::Rxne);
266267

267268
// no result
@@ -274,7 +275,7 @@ mod app {
274275
let mut sys_cfg = dp.SYSCFG.constrain();
275276
ps2_clk0.make_interrupt_source(&mut sys_cfg);
276277
ps2_clk0.enable_interrupt(&mut dp.EXTI);
277-
ps2_clk0.trigger_on_edge(&mut dp.EXTI, Edge::Falling);
278+
ps2_clk0.trigger_on_edge(&mut dp.EXTI, Edge::Falling);
278279
//dp.SYSCFG.exticr4.write(|w| w.exti15().pa15());
279280

280281
// Enable EXTI15 interrupt as external falling edge
@@ -314,15 +315,15 @@ mod app {
314315
// SEEMS GONE:
315316
ms_decoder: Ps2Decoder::new(),
316317
};
317-
318+
318319
let local_resources = Local {
319320
press_button_power_short: debouncr::debounce_2(false),
320321
press_button_power_long: debouncr::debounce_16(false),
321322
press_button_reset_long: debouncr::debounce_16(false),
322323
kb_decoder: Ps2Decoder::new(),
323324
};
324325
let init = init::Monotonics(mono);
325-
326+
326327
(shared_resources, local_resources, init)
327328
}
328329

@@ -395,7 +396,6 @@ mod app {
395396
local = [led_state:bool = false]
396397
)]
397398
fn led_power_blink(ctx: led_power_blink::Context) {
398-
399399
if *ctx.shared.state_dc_power_enabled == DcPowerState::Off {
400400
//TODO: Shall that be local?
401401
//defmt::trace!("blink time {}", ctx.scheduled.counts());
@@ -406,7 +406,7 @@ mod app {
406406
ctx.shared.led_power.set_high();
407407
*ctx.local.led_state = true;
408408
}
409-
409+
410410
led_power_blink::spawn_after(LED_PERIOD_MS.millis()).unwrap();
411411
}
412412
}
@@ -429,9 +429,9 @@ mod app {
429429

430430
// Dispatch event
431431
match (
432-
pwr_long_edge,
433-
pwr_short_edge,
434-
*ctx.shared.state_dc_power_enabled
432+
pwr_long_edge,
433+
pwr_short_edge,
434+
*ctx.shared.state_dc_power_enabled,
435435
) {
436436
(None, Some(debouncr::Edge::Rising), DcPowerState::Off) => {
437437
defmt::info!("Power button pressed whilst off.");
@@ -476,7 +476,6 @@ mod app {
476476
}
477477
// Re-schedule the timer interrupt
478478
button_poll::spawn_after(DEBOUNCE_POLL_INTERVAL_MS.millis()).unwrap();
479-
480479
}
481480
}
482481

neotron-bmc-nucleo/src/monotonic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use stm32f4xx_hal::rcc::Clocks;
77
pub struct MonoTimer<T, const FREQ: u32>(T);
88

99

10-
impl <const FREQ: u32> MonoTimer<pac::TIM2, FREQ> {
10+
impl<const FREQ: u32> MonoTimer<pac::TIM2, FREQ> {
1111
/// Initialize the timer instance.
12-
pub fn new(timer: pac::TIM2, clocks: &Clocks) -> Self{
12+
pub fn new(timer: pac::TIM2, clocks: &Clocks) -> Self {
1313
// Enable and reset TIM2 in RCC
1414
//
1515
// Correctness: Since we only modify TIM2 related registers in the RCC
@@ -25,7 +25,7 @@ impl <const FREQ: u32> MonoTimer<pac::TIM2, FREQ> {
2525
rcc.apb1rstr.modify(|_, w| w.tim2rst().clear_bit());
2626
}
2727

28-
let prescaler = (clocks.pclk1().0 /FREQ) -1;
28+
let prescaler = (clocks.pclk1().0 /FREQ) - 1;
2929
// Set up prescaler
3030
timer.psc.write(|w| w.psc().bits(prescaler as u16));
3131

@@ -43,7 +43,7 @@ impl<const FREQ: u32> Monotonic for MonoTimer<pac::TIM2, FREQ> {
4343
type Instant = fugit::TimerInstantU32<FREQ>;
4444
type Duration = fugit::TimerDurationU32<FREQ>;
4545

46-
unsafe fn reset(&mut self){
46+
unsafe fn reset(&mut self) {
4747
self.0.dier.modify(|_, w| w.cc1ie().set_bit());
4848
}
4949

0 commit comments

Comments
 (0)