Skip to content

Commit 127e51e

Browse files
authored
fugit units (#291)
* fugit units * Into<serial::Config>
1 parent 573c566 commit 127e51e

Some content is hidden

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

41 files changed

+161
-320
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77

88
## Changed
99

10+
- Use `fugit` duration nd rate units instead of custom
1011
- Use const-generics for GPIO (require Rust 1.51)
1112

1213
## [v0.6.0] - 2020-12-11

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ nb = "0.1.1"
2626
stm32l4 = "0.14.0"
2727
embedded-dma = "0.1"
2828
bxcan = ">=0.4, <0.7"
29+
fugit = "0.3.5"
2930

3031
[dependencies.rand_core]
3132
version = "0.6.2"

examples/adc_dma.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use stm32l4xx_hal::{
88
delay::DelayCM,
99
dma::{dma1, RxDma, Transfer, W},
1010
prelude::*,
11-
time::Hertz,
1211
};
1312

1413
use rtic::app;
@@ -51,10 +50,7 @@ const APP: () = {
5150
//
5251
// Initialize the clocks
5352
//
54-
let clocks = rcc
55-
.cfgr
56-
.sysclk(Hertz(80_000_000))
57-
.freeze(&mut flash.acr, &mut pwr);
53+
let clocks = rcc.cfgr.sysclk(80.MHz()).freeze(&mut flash.acr, &mut pwr);
5854

5955
let mut delay = DelayCM::new(clocks);
6056

examples/blinky.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ fn main() -> ! {
3434
let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1);
3535

3636
// Try a different clock configuration
37-
let clocks = rcc.cfgr.hclk(8.mhz()).freeze(&mut flash.acr, &mut pwr);
37+
let clocks = rcc.cfgr.hclk(8.MHz()).freeze(&mut flash.acr, &mut pwr);
3838
// let clocks = rcc.cfgr
39-
// .sysclk(64.mhz())
40-
// .pclk1(32.mhz())
39+
// .sysclk(64.MHz())
40+
// .pclk1(32.MHz())
4141
// .freeze(&mut flash.acr);
4242

4343
// let mut gpioc = dp.GPIOC.split(&mut rcc.ahb2);

examples/can-loopback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const APP: () = {
2828
let mut gpioa = dp.GPIOA.split(&mut rcc.ahb2);
2929

3030
// Set the clocks to 80 MHz
31-
let _clocks = rcc.cfgr.sysclk(80.mhz()).freeze(&mut flash.acr, &mut pwr);
31+
let _clocks = rcc.cfgr.sysclk(80.MHz()).freeze(&mut flash.acr, &mut pwr);
3232

3333
rprintln!(" - CAN init");
3434

examples/i2c_write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn main() -> ! {
5252
let mut i2c = I2c::i2c1(
5353
dp.I2C1,
5454
(scl, sda),
55-
i2c::Config::new(100.khz(), clocks),
55+
i2c::Config::new(100.kHz(), clocks),
5656
&mut rcc.apb1r1,
5757
);
5858

examples/irq_button.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ fn main() -> ! {
3333
let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1);
3434

3535
rcc.cfgr
36-
.hclk(48.mhz())
37-
.sysclk(80.mhz())
38-
.pclk1(24.mhz())
39-
.pclk2(24.mhz())
36+
.hclk(48.MHz())
37+
.sysclk(80.MHz())
38+
.pclk1(24.MHz())
39+
.pclk2(24.MHz())
4040
.freeze(&mut flash.acr, &mut pwr);
4141

4242
// Create a button input with an interrupt

examples/lptim_rtic.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use stm32l4xx_hal::{
1515
prelude::*,
1616
pwr::Pwr,
1717
rcc::{ClockSecuritySystem, Clocks, CrystalBypass, RccExt, CFGR},
18-
time::U32Ext,
1918
};
2019

2120
// this is the LD4 on Nucleo-L452-P
@@ -24,7 +23,7 @@ type Timer = LowPowerTimer<LPTIM1>;
2423

2524
pub fn configure_clock_tree(cfgr: CFGR, acr: &mut ACR, pwr: &mut Pwr) -> Clocks {
2625
cfgr.lse(CrystalBypass::Disable, ClockSecuritySystem::Disable)
27-
.sysclk(80.mhz())
26+
.sysclk(80.MHz())
2827
.freeze(acr, pwr)
2928
}
3029

examples/otg_fs_serial.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,22 @@ unsafe fn main() -> ! {
111111
rcc.cfgr
112112
.msi(MsiFreq::RANGE48M) // Set the MSI (multi-speed internal) clock to 48 MHz
113113
.pll_source(PllSource::MSI)
114-
.sysclk_with_pll(80.mhz(), pll_cfg)
115-
.pclk1(24.mhz())
116-
.pclk2(24.mhz())
114+
.sysclk_with_pll(80.MHz(), pll_cfg)
115+
.pclk1(24.MHz())
116+
.pclk2(24.MHz())
117117
.freeze(&mut flash.acr, &mut pwr)
118118
} else {
119119
// Note: If program needs low-speed clocks, adjust this.
120120
// Tested using a 16 MHz resonator.
121121
rcc.cfgr
122122
.msi(MsiFreq::RANGE48M)
123123
.hse(
124-
16.mhz(),
124+
16.MHz(),
125125
CrystalBypass::Disable, // Bypass enabled when clock signals instead of crystals/resonators are used.
126126
ClockSecuritySystem::Disable, // We have not set up interrupt routines handling clock drifts/errors.
127127
)
128128
.pll_source(PllSource::HSE)
129-
.sysclk(80.mhz())
129+
.sysclk(80.MHz())
130130
.freeze(&mut flash.acr, &mut pwr)
131131
}
132132
};

examples/pll_config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ fn main() -> ! {
3636
// TRY this alternate clock configuration (clocks run at nearly the maximum frequency)
3737
let clocks = rcc
3838
.cfgr
39-
.sysclk(80.mhz())
40-
.pclk1(80.mhz())
41-
.pclk2(80.mhz())
39+
.sysclk(80.MHz())
40+
.pclk1(80.MHz())
41+
.pclk2(80.MHz())
4242
.freeze(&mut flash.acr, &mut pwr);
4343

4444
// The Serial API is highly generic

0 commit comments

Comments
 (0)