Skip to content

Commit 36f228e

Browse files
committed
Use hard tabs.
1 parent 3b4e718 commit 36f228e

4 files changed

Lines changed: 68 additions & 69 deletions

File tree

build.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@ use std::io::Write;
77
use std::path::PathBuf;
88

99
fn main() {
10-
// Put the linker script somewhere the linker can find it
11-
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
12-
File::create(out.join("memory.x"))
13-
.unwrap()
14-
.write_all(include_bytes!("memory.x"))
15-
.unwrap();
16-
println!("cargo:rustc-link-search={}", out.display());
17-
println!("cargo:rerun-if-changed=memory.x");
10+
// Put the linker script somewhere the linker can find it
11+
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
12+
File::create(out.join("memory.x"))
13+
.unwrap()
14+
.write_all(include_bytes!("memory.x"))
15+
.unwrap();
16+
println!("cargo:rustc-link-search={}", out.display());
17+
println!("cargo:rerun-if-changed=memory.x");
1818

19+
let version_output = std::process::Command::new("git")
20+
.current_dir(env::var_os("CARGO_MANIFEST_DIR").unwrap())
21+
.args(&["describe", "--tags", "--all", "--dirty"])
22+
.output()
23+
.expect("running git-describe");
24+
assert!(version_output.status.success());
1925

20-
let version_output = std::process::Command::new("git")
21-
.current_dir(env::var_os("CARGO_MANIFEST_DIR").unwrap())
22-
.args(&["describe", "--tags", "--all", "--dirty"])
23-
.output()
24-
.expect("running git-describe");
25-
assert!(version_output.status.success());
26-
27-
std::fs::write(out.join("version.txt"), version_output.stdout).expect("writing version file");
26+
std::fs::write(out.join("version.txt"), version_output.stdout).expect("writing version file");
2827
}

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
use core::sync::atomic::{AtomicUsize, Ordering};
44

55
use defmt_rtt as _; // global logger
6-
use stm32f0xx_hal as _; // memory layout
7-
use panic_probe as _; // panic handler
6+
use panic_probe as _;
7+
use stm32f0xx_hal as _; // memory layout // panic handler
88

99
// same panicking *behavior* as `panic-probe` but doesn't print a panic message
1010
// this prevents the panic message being printed *twice* when `defmt::panic` is invoked
1111
#[defmt::panic_handler]
1212
fn panic() -> ! {
13-
cortex_m::asm::udf()
13+
cortex_m::asm::udf()
1414
}
1515

1616
static COUNT: AtomicUsize = AtomicUsize::new(0);
1717
defmt::timestamp!("{=usize}", {
18-
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
19-
let n = COUNT.load(Ordering::Relaxed);
20-
COUNT.store(n + 1, Ordering::Relaxed);
21-
n
18+
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
19+
let n = COUNT.load(Ordering::Relaxed);
20+
COUNT.store(n + 1, Ordering::Relaxed);
21+
n
2222
});
2323

2424
/// Terminates the application and makes `probe-run` exit with exit-code = 0
2525
pub fn exit() -> ! {
26-
loop {
27-
cortex_m::asm::bkpt();
28-
}
26+
loop {
27+
cortex_m::asm::bkpt();
28+
}
2929
}

src/main.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,47 @@
33

44
use neotron_bmc as _;
55

6+
use hal::{i2c, pac, prelude::*, serial, spi};
67
use stm32f0xx_hal as hal;
7-
use hal::{prelude::*, pac, spi, i2c, serial};
88

99
static VERSION: &'static str = include_str!(concat!(env!("OUT_DIR"), "/version.txt"));
1010

1111
const MODE_0: spi::Mode = spi::Mode {
12-
polarity: spi::Polarity::IdleLow,
13-
phase: spi::Phase::CaptureOnFirstTransition,
12+
polarity: spi::Polarity::IdleLow,
13+
phase: spi::Phase::CaptureOnFirstTransition,
1414
};
1515

1616
#[cortex_m_rt::entry]
1717
fn main() -> ! {
18-
defmt::info!("Neotron BMC version {:?} booting", VERSION);
19-
20-
let p = pac::Peripherals::take().unwrap();
21-
22-
let mut flash = p.FLASH;
23-
let mut rcc = p.RCC.configure().freeze(&mut flash);
24-
25-
let gpioa = p.GPIOA.split(&mut rcc);
26-
let gpiob = p.GPIOB.split(&mut rcc);
27-
28-
let (sck, miso, mosi, scl, sda, tx, rx) = cortex_m::interrupt::free(move |cs| {
29-
(
30-
// SPI pins
31-
gpioa.pa5.into_alternate_af0(cs),
32-
gpioa.pa6.into_alternate_af0(cs),
33-
gpioa.pa7.into_alternate_af0(cs),
34-
// I²C pins
35-
gpioa.pa9.into_alternate_af4(cs),
36-
gpioa.pa10.into_alternate_af4(cs),
37-
// USART pins
38-
gpiob.pb6.into_alternate_af0(cs),
39-
gpiob.pb7.into_alternate_af0(cs),
40-
)
41-
});
42-
43-
// Configure SPI with 1MHz rate
44-
let spi = spi::Spi::spi1(p.SPI1, (sck, miso, mosi), MODE_0, 1.mhz(), &mut rcc);
45-
let serial = serial::Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc);
46-
let i2c = i2c::I2c::i2c1(p.I2C1, (scl, sda), 100.khz(), &mut rcc);
47-
48-
neotron_bmc::exit()
18+
defmt::info!("Neotron BMC version {:?} booting", VERSION);
19+
20+
let p = pac::Peripherals::take().unwrap();
21+
22+
let mut flash = p.FLASH;
23+
let mut rcc = p.RCC.configure().freeze(&mut flash);
24+
25+
let gpioa = p.GPIOA.split(&mut rcc);
26+
let gpiob = p.GPIOB.split(&mut rcc);
27+
28+
let (sck, miso, mosi, scl, sda, tx, rx) = cortex_m::interrupt::free(move |cs| {
29+
(
30+
// SPI pins
31+
gpioa.pa5.into_alternate_af0(cs),
32+
gpioa.pa6.into_alternate_af0(cs),
33+
gpioa.pa7.into_alternate_af0(cs),
34+
// I²C pins
35+
gpioa.pa9.into_alternate_af4(cs),
36+
gpioa.pa10.into_alternate_af4(cs),
37+
// USART pins
38+
gpiob.pb6.into_alternate_af0(cs),
39+
gpiob.pb7.into_alternate_af0(cs),
40+
)
41+
});
42+
43+
// Configure SPI with 1MHz rate
44+
let spi = spi::Spi::spi1(p.SPI1, (sck, miso, mosi), MODE_0, 1.mhz(), &mut rcc);
45+
let serial = serial::Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc);
46+
let i2c = i2c::I2c::i2c1(p.I2C1, (scl, sda), 100.khz(), &mut rcc);
47+
48+
neotron_bmc::exit()
4949
}

testsuite/tests/test.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use neotron_bmc as _; // memory layout + panic handler
77
// feature)
88
#[defmt_test::tests]
99
mod tests {
10-
use defmt::{assert, assert_eq};
10+
use defmt::{assert, assert_eq};
1111

12-
#[test]
13-
fn assert_true() {
14-
assert!(true)
15-
}
12+
#[test]
13+
fn assert_true() {
14+
assert!(true)
15+
}
1616

17-
#[test]
18-
fn assert_eq() {
19-
assert_eq!(24, 42, "TODO: write actual tests")
20-
}
17+
#[test]
18+
fn assert_eq() {
19+
assert_eq!(24, 42, "TODO: write actual tests")
20+
}
2121
}

0 commit comments

Comments
 (0)