Skip to content

Commit 25881c9

Browse files
sosthene-nitrokeynickray
authored andcommitted
Run cargo fmt
1 parent 402fb4f commit 25881c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3135
-2477
lines changed

build.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
fn main() {
2-
}
1+
fn main() {}

examples/adc.rs

+58-59
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,44 @@
11
#![no_main]
22
#![no_std]
33

4-
extern crate panic_semihosting; // 4004 bytes
5-
// extern crate panic_halt; // 672 bytes
4+
extern crate panic_semihosting; // 4004 bytes
5+
// extern crate panic_halt; // 672 bytes
66

77
use cortex_m_rt::entry;
88
use cortex_m_semihosting::dbg;
99
use cortex_m_semihosting::heprintln;
1010

11-
use lpc55_hal as hal;
1211
use hal::prelude::*;
12+
use lpc55_hal as hal;
1313

14-
fn autocal (adc: & hal::raw::ADC0) {
14+
fn autocal(adc: &hal::raw::ADC0) {
1515
// Calibration + offset trimming
16-
adc.ofstrim.write(|w| unsafe {
17-
w.ofstrim_a().bits(10)
18-
.ofstrim_b().bits(10)
19-
});
16+
adc.ofstrim
17+
.write(|w| unsafe { w.ofstrim_a().bits(10).ofstrim_b().bits(10) });
2018

2119
// Request calibration
22-
adc.ctrl.modify(|_,w| {w.cal_req().set_bit()});
20+
adc.ctrl.modify(|_, w| w.cal_req().set_bit());
2321

2422
// wait for auto-cal to be ready.
25-
while (!adc.gcc[0].read().rdy().bits()) || (!adc.gcc[1].read().rdy().bits()) {
26-
}
23+
while (!adc.gcc[0].read().rdy().bits()) || (!adc.gcc[1].read().rdy().bits()) {}
2724

2825
let gain_a = adc.gcc[0].read().gain_cal().bits();
2926
let gain_b = adc.gcc[1].read().gain_cal().bits();
3027

31-
let gcr_a = (((gain_a as u32) << 16) / (0x1FFFFu32 - gain_a as u32 )) as u16;
32-
let gcr_b = (((gain_b as u32) << 16) / (0x1FFFFu32 - gain_b as u32 )) as u16;
28+
let gcr_a = (((gain_a as u32) << 16) / (0x1FFFFu32 - gain_a as u32)) as u16;
29+
let gcr_b = (((gain_b as u32) << 16) / (0x1FFFFu32 - gain_b as u32)) as u16;
3330

34-
adc.gcr[0].write(|w| unsafe {w.gcalr().bits(gcr_a)});
35-
adc.gcr[1].write(|w| unsafe {w.gcalr().bits(gcr_b)});
31+
adc.gcr[0].write(|w| unsafe { w.gcalr().bits(gcr_a) });
32+
adc.gcr[1].write(|w| unsafe { w.gcalr().bits(gcr_b) });
3633

37-
adc.gcr[0].write(|w| {w.rdy().set_bit()});
38-
adc.gcr[1].write(|w| {w.rdy().set_bit()});
34+
adc.gcr[0].write(|w| w.rdy().set_bit());
35+
adc.gcr[1].write(|w| w.rdy().set_bit());
3936

40-
while !adc.stat.read().cal_rdy().bits() {
41-
}
37+
while !adc.stat.read().cal_rdy().bits() {}
4238
}
4339

4440
#[entry]
4541
fn main() -> ! {
46-
4742
heprintln!("Hello ADC").unwrap();
4843

4944
// Get pointer to all device peripherals.
@@ -60,59 +55,67 @@ fn main() -> ! {
6055

6156
let adc = adc.release();
6257

63-
adc.ctrl.write(|w| {
64-
w.dozen().set_bit()
65-
.cal_avgs().cal_avgs_7()
66-
});
58+
adc.ctrl
59+
.write(|w| w.dozen().set_bit().cal_avgs().cal_avgs_7());
6760

6861
adc.cfg.write(|w| unsafe {
69-
w.pwren().set_bit()
70-
.pudly().bits(0x80)
71-
.refsel().refsel_1()
72-
.pwrsel().pwrsel_1()
73-
.tprictrl().bits(0)
62+
w.pwren()
63+
.set_bit()
64+
.pudly()
65+
.bits(0x80)
66+
.refsel()
67+
.refsel_1()
68+
.pwrsel()
69+
.pwrsel_1()
70+
.tprictrl()
71+
.bits(0)
7472
});
7573

76-
7774
// No pause for now, but could be interesting
78-
adc.pause.write(|w| unsafe {w.bits(0)});
75+
adc.pause.write(|w| unsafe { w.bits(0) });
7976

8077
// Set 0 for watermark
81-
adc.fctrl[0].write(|w| unsafe{w.fwmark().bits(0)});
82-
adc.fctrl[1].write(|w| unsafe{w.fwmark().bits(0)});
83-
78+
adc.fctrl[0].write(|w| unsafe { w.fwmark().bits(0) });
79+
adc.fctrl[1].write(|w| unsafe { w.fwmark().bits(0) });
8480

8581
// turn on!
86-
adc.ctrl.modify(|_, w| {w.adcen().set_bit()});
82+
adc.ctrl.modify(|_, w| w.adcen().set_bit());
8783

8884
heprintln!("Auto calibrating..").unwrap();
89-
autocal(& adc);
85+
autocal(&adc);
9086

9187
// channel 13 (1V ref), single ended A, high res
92-
adc.cmdl1.write(|w| unsafe { w.adch().bits(13)
93-
.ctype().ctype_0()
94-
.mode().mode_1()
95-
} );
96-
97-
adc.cmdh1.write(|w| unsafe { w.avgs().avgs_5() // average 2^5 samples
98-
.cmpen().bits(0) // disable compare
99-
.loop_().bits(0) // no loop
100-
.next().bits(0) // no next command
101-
} );
88+
adc.cmdl1
89+
.write(|w| unsafe { w.adch().bits(13).ctype().ctype_0().mode().mode_1() });
90+
91+
adc.cmdh1.write(|w| unsafe {
92+
w.avgs()
93+
.avgs_5() // average 2^5 samples
94+
.cmpen()
95+
.bits(0) // disable compare
96+
.loop_()
97+
.bits(0) // no loop
98+
.next()
99+
.bits(0) // no next command
100+
});
102101

103102
adc.tctrl[0].write(|w| unsafe {
104-
w.hten().set_bit()
105-
.fifo_sel_a().fifo_sel_a_0()
106-
.fifo_sel_b().fifo_sel_b_0()
107-
.tcmd().bits(1)
103+
w.hten()
104+
.set_bit()
105+
.fifo_sel_a()
106+
.fifo_sel_a_0()
107+
.fifo_sel_b()
108+
.fifo_sel_b_0()
109+
.tcmd()
110+
.bits(1)
108111
});
109112

110113
heprintln!("ADC CTRL. {:02X}", adc.ctrl.read().bits()).unwrap();
111114
heprintln!("ADC CFG. {:02X}", adc.cfg.read().bits()).unwrap();
112115
heprintln!("ADC stat: {:02X}", adc.stat.read().bits()).unwrap();
113116

114117
// SW trigger the trigger event 0
115-
adc.swtrig.write(|w| unsafe {w.bits(1)});
118+
adc.swtrig.write(|w| unsafe { w.bits(1) });
116119

117120
dbg!("triggered");
118121

@@ -131,18 +134,14 @@ fn main() -> ! {
131134
}
132135

133136
for i in 0..10 {
134-
135-
adc.swtrig.write(|w| unsafe {w.bits(1)});
136-
while adc.fctrl[0].read().fcount().bits() == 0 {
137-
}
137+
adc.swtrig.write(|w| unsafe { w.bits(1) });
138+
while adc.fctrl[0].read().fcount().bits() == 0 {}
138139
let result = adc.resfifo[0].read().bits();
139-
assert!( (result & 0x80000000) != 0 );
140+
assert!((result & 0x80000000) != 0);
140141
let sample = (result & 0xffff) as u16;
141142
heprintln!("sample{} = {:02x}", i, sample).unwrap();
142143
}
143144

144145
heprintln!("looping").unwrap();
145-
loop {
146-
147-
}
146+
loop {}
148147
}

examples/aes.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ fn main() -> ! {
8585
// check hw decrypt⚬encrypt = id
8686
assert_eq!(hw_block, block);
8787

88-
8988
// // Finally, PUF key
9089
// let cipher = hashcrypt.puf_aes();
9190
// dbg!(hw_block);
@@ -94,5 +93,7 @@ fn main() -> ! {
9493

9594
// DONE
9695
dbg!("all done");
97-
loop { continue; }
96+
loop {
97+
continue;
98+
}
9899
}

examples/ctimer.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
#![no_main]
22
#![no_std]
33

4-
extern crate panic_semihosting; // 4004 bytes
5-
// extern crate panic_halt; // 672 bytes
4+
extern crate panic_semihosting; // 4004 bytes
5+
// extern crate panic_halt; // 672 bytes
66

77
use cortex_m_rt::entry;
88
use cortex_m_semihosting::dbg;
99
use cortex_m_semihosting::heprintln;
1010

11-
use lpc55_hal as hal;
1211
use hal::prelude::*;
12+
use lpc55_hal as hal;
1313

1414
use hal::drivers::timer::Elapsed;
1515

1616
#[macro_use(block)]
1717
extern crate nb;
1818

19-
use hal::drivers::{
20-
Timer,
21-
};
19+
use hal::drivers::Timer;
2220

2321
#[entry]
2422
fn main() -> ! {
25-
2623
heprintln!("Hello ctimer").unwrap();
2724

2825
// Get pointer to all device peripherals.
@@ -33,7 +30,10 @@ fn main() -> ! {
3330
.configure(&mut hal.anactrl, &mut hal.pmc, &mut hal.syscon)
3431
.unwrap();
3532

36-
let ctimer = hal.ctimer.1.enabled(&mut hal.syscon, clocks.support_1mhz_fro_token().unwrap());
33+
let ctimer = hal
34+
.ctimer
35+
.1
36+
.enabled(&mut hal.syscon, clocks.support_1mhz_fro_token().unwrap());
3737
let mut cdriver = Timer::new(ctimer);
3838

3939
heprintln!("looping 1 Hz").unwrap();

examples/external_interrupts.rs

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
#![no_main]
22
#![no_std]
33

4-
use panic_semihosting as _; // 4004 bytes
5-
// extern crate panic_halt; // 672 bytes
4+
use panic_semihosting as _; // 4004 bytes
5+
// extern crate panic_halt; // 672 bytes
66

77
// #[macro_use(block)]
88
// extern crate nb;
99

1010
use cortex_m_rt::entry;
1111
use cortex_m_semihosting::heprintln;
1212

13-
use lpc55_hal as hal;
1413
use hal::prelude::*;
1514
use hal::{
16-
drivers::{
17-
Pins,
18-
},
19-
peripherals::{
20-
pint::{
21-
Mode,
22-
Slot,
23-
},
24-
},
15+
drivers::Pins,
16+
peripherals::pint::{Mode, Slot},
2517
};
26-
27-
18+
use lpc55_hal as hal;
2819

2920
#[entry]
3021
fn main() -> ! {
31-
3222
heprintln!("External interrupts").unwrap();
3323

3424
let mut hal = hal::new();
@@ -43,11 +33,14 @@ fn main() -> ! {
4333
let pins = Pins::take().unwrap();
4434

4535
// // NFC IRQ pin for Solo-bee
46-
let input = pins.pio0_0.into_gpio_pin(&mut iocon, &mut gpio).into_input();
36+
let input = pins
37+
.pio0_0
38+
.into_gpio_pin(&mut iocon, &mut gpio)
39+
.into_input();
4740

4841
// Add pullup for Pio0_0
4942
let iocon = iocon.release();
50-
iocon.pio0_0.modify(|_,w| { w.mode().pull_up() } );
43+
iocon.pio0_0.modify(|_, w| w.mode().pull_up());
5144

5245
let mut mux = hal.inputmux.enabled(&mut hal.syscon);
5346
let mut pint = hal.pint.enabled(&mut hal.syscon);
@@ -63,7 +56,6 @@ fn main() -> ! {
6356
pint.fall.write(|w| unsafe { w.bits(1) });
6457

6558
loop {
66-
6759
if (pint.rise.read().bits() & 1) != 0 {
6860
pint.rise.write(|w| unsafe { w.bits(1) });
6961
heprintln!("Rising edge detected").unwrap();
@@ -73,6 +65,5 @@ fn main() -> ! {
7365
pint.fall.write(|w| unsafe { w.bits(1) });
7466
heprintln!("Falling edge detected").unwrap();
7567
}
76-
7768
}
7869
}

examples/flash.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ extern crate panic_semihosting;
55
use cortex_m_rt::entry;
66
use cortex_m_semihosting::{dbg, hprintln};
77

8-
use lpc55_hal as hal;
98
use hal::prelude::*;
9+
use lpc55_hal as hal;
1010

1111
#[repr(C)]
1212
#[allow(dead_code)]
@@ -22,12 +22,11 @@ enum FlashCommands {
2222
Write = 0x8,
2323
WriteProg = 0xA,
2424
Program = 0xC,
25-
ReportEcc= 0xD,
25+
ReportEcc = 0xD,
2626
}
2727

2828
#[entry]
2929
fn main() -> ! {
30-
3130
let hal = hal::new();
3231

3332
// dbg!(hal.FLASH_CMPA.boot_cfg.read().bits());
@@ -133,7 +132,6 @@ fn main() -> ! {
133132
// debug_assert!(flash.int_status.read().err().bit_is_clear());
134133
// debug_assert!(flash.int_status.read().fail().bit_is_clear());
135134

136-
137135
// let x: u8 = unsafe { core::ptr::read_volatile(0x0004_0000 as *const u8) } ;
138136
// hprintln!("{:x}", x).ok();
139137
// let x: u32 = unsafe { core::ptr::read_volatile(0x0004_0004 as *const u32) } ;
@@ -162,7 +160,6 @@ fn main() -> ! {
162160
hprintln!("{:#034x}", flash.read_u128(0x4_0010)).ok();
163161
hprintln!("{:#034x}", flash.read_u128(0x4_0020)).ok();
164162

165-
166163
let mut read_buf = [0u8; 16];
167164
flash.read(WHERE, &mut read_buf);
168165
// dbg!(read_buf);
@@ -177,10 +174,14 @@ fn main() -> ! {
177174
let mut buf = [0u8; 512];
178175
buf[..4].copy_from_slice(&data);
179176

180-
flash.write_native(WHERE, &generic_array::GenericArray::from_slice(&buf)).unwrap();
177+
flash
178+
.write_native(WHERE, &generic_array::GenericArray::from_slice(&buf))
179+
.unwrap();
181180
buf[0] = 37;
182181
// // buf[3] = 37;
183-
flash.write_native(WHERE, &generic_array::GenericArray::from_slice(&buf)).unwrap();
182+
flash
183+
.write_native(WHERE, &generic_array::GenericArray::from_slice(&buf))
184+
.unwrap();
184185
flash.write_u8(0x4_000F, 69).ok();
185186
flash.read(WHERE, &mut read_buf);
186187
// dbg!(read_buf);
@@ -216,10 +217,8 @@ fn main() -> ! {
216217
hprintln!("{:#034x}", flash.read_u128(0x4_0210)).ok();
217218
hprintln!("{:#034x}", flash.read_u128(0x4_0220)).ok();
218219

219-
220220
hprintln!("loop-continue").ok();
221221
loop {
222222
continue;
223223
}
224-
225224
}

0 commit comments

Comments
 (0)