Skip to content

Commit a484539

Browse files
authored
Merge pull request #178 from burrbull/counter
BusClock + &Clock
2 parents 4a55dd4 + f566a4f commit a484539

23 files changed

+217
-155
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313

1414
### Changed
1515

16-
- Usw `fugit`-based time types instead of `embedded-time`
16+
- split `GetBusFreq` on `BusClock` & `BusTimerClock`, use `&Clock` everywhere
17+
- Use `fugit`-based time types instead of `embedded-time`
1718
- Update gpios: add `DynamicPin`, add default modes, reexport pins, resort generics, etc.
1819
- Improved RCC infrastructure.
1920
- RTC support has been rewritten.

examples/blinky_delay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() -> ! {
2525
let clocks = rcc.cfgr.sysclk(216.MHz()).freeze();
2626

2727
// Get delay provider
28-
let mut delay = Delay::new(cp.SYST, clocks);
28+
let mut delay = Delay::new(cp.SYST, &clocks);
2929

3030
loop {
3131
led.set_high();

examples/fmc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn main() -> ! {
4444

4545
// Get the delay provider.
4646
let clocks = dp.RCC.constrain().cfgr.sysclk(216_000_000.Hz()).freeze();
47-
let mut delay = Delay::new(cp.SYST, clocks);
47+
let mut delay = Delay::new(cp.SYST, &clocks);
4848

4949
// IO
5050
let gpioc = dp.GPIOC.split();

examples/i2c_scanner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() -> ! {
3131
dp.I2C1,
3232
(scl, sda),
3333
hal::i2c::Mode::fast(100_000.Hz()),
34-
clocks,
34+
&clocks,
3535
&mut rcc.apb1,
3636
50_000,
3737
);

examples/serial_delay.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() -> ! {
2727
let rcc = p.RCC.constrain();
2828
let clocks = rcc.cfgr.sysclk(216_000_000.Hz()).freeze();
2929

30-
let mut delay = Delay::new(cp.SYST, clocks);
30+
let mut delay = Delay::new(cp.SYST, &clocks);
3131

3232
let gpioa = p.GPIOA.split();
3333
let gpiob = p.GPIOB.split();
@@ -38,11 +38,12 @@ fn main() -> ! {
3838
let serial = Serial::new(
3939
p.USART1,
4040
(tx, rx),
41-
clocks,
41+
&clocks,
4242
serial::Config {
4343
baud_rate: 115_200.bps(),
4444
oversampling: serial::Oversampling::By16,
4545
character_match: None,
46+
sysclock: false,
4647
},
4748
);
4849
let (mut tx, _) = serial.split();

examples/serial_dma.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ fn main() -> ! {
4545
let serial = Serial::new(
4646
p.USART3,
4747
(tx, rx),
48-
clocks,
48+
&clocks,
4949
serial::Config {
5050
baud_rate: 115_200.bps(),
5151
oversampling: serial::Oversampling::By16,
5252
character_match: None,
53+
sysclock: false,
5354
},
5455
);
5556
let (mut tx, mut rx) = serial.split();

examples/serial_echo.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ fn main() -> ! {
3434
let serial = Serial::new(
3535
p.USART1,
3636
(tx, rx),
37-
clocks,
37+
&clocks,
3838
serial::Config {
3939
baud_rate: 115_200.bps(),
4040
oversampling: serial::Oversampling::By16,
4141
character_match: None,
42+
sysclock: false,
4243
},
4344
);
4445

examples/spi.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn main() -> ! {
1515
let p = pac::Peripherals::take().unwrap();
1616

1717
let mut rcc = p.RCC.constrain();
18+
let clocks = rcc.cfgr.freeze();
1819

1920
let gpiob = p.GPIOB.split();
2021
let gpioc = p.GPIOC.split();
@@ -35,12 +36,13 @@ fn main() -> ! {
3536

3637
// Initialize SPI
3738
let mut spi = Spi::new(p.SPI3, (sck, miso, mosi)).enable::<u8>(
38-
&mut rcc.apb1,
39-
spi::ClockDivider::DIV32,
4039
spi::Mode {
4140
polarity: spi::Polarity::IdleHigh,
4241
phase: spi::Phase::CaptureOnSecondTransition,
4342
},
43+
250.kHz(),
44+
&clocks,
45+
&mut rcc.apb1,
4446
);
4547

4648
loop {

examples/spi_16.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn main() -> ! {
1515
let p = pac::Peripherals::take().unwrap();
1616

1717
let mut rcc = p.RCC.constrain();
18+
let clocks = rcc.cfgr.freeze();
1819

1920
let gpioa = p.GPIOA.split();
2021
let gpioc = p.GPIOC.split();
@@ -34,9 +35,10 @@ fn main() -> ! {
3435

3536
// Initialize SPI
3637
let mut spi = Spi::new(p.SPI1, (sck, spi::NoMiso, mosi)).enable::<u16>(
37-
&mut rcc.apb2,
38-
spi::ClockDivider::DIV32,
3938
embedded_hal::spi::MODE_0,
39+
250.kHz(),
40+
&clocks,
41+
&mut rcc.apb2,
4042
);
4143

4244
// Use a button to control output via the Maxim Integrated MAX5214 DAC.

examples/spi_dma.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fn main() -> ! {
1919
let p = pac::Peripherals::take().unwrap();
2020

2121
let mut rcc = p.RCC.constrain();
22+
let clocks = rcc.cfgr.freeze();
2223

2324
let dma = DMA::new(p.DMA1);
2425
let gpiob = p.GPIOB.split();
@@ -46,12 +47,13 @@ fn main() -> ! {
4647

4748
// Initialize SPI
4849
let mut spi = Spi::new(p.SPI3, (sck, miso, mosi)).enable(
49-
&mut rcc.apb1,
50-
spi::ClockDivider::DIV32,
5150
spi::Mode {
5251
polarity: spi::Polarity::IdleHigh,
5352
phase: spi::Phase::CaptureOnSecondTransition,
5453
},
54+
250.kHz(),
55+
&clocks,
56+
&mut rcc.apb1,
5557
);
5658

5759
// Create the buffer we're going to use for DMA. This is safe, as this

0 commit comments

Comments
 (0)