Skip to content

Commit 73a7587

Browse files
authored
Upgrade stm32l0 to v0.15.1 (#215)
* Upgrade stm32l0 crate * Fix variant names from stm32-l0 upgrade * Remove unnecessary unsafe blocks from stm32-rs upgrade * Upgrade other outdated dependencies * Upgrade dev dependencies, fix examples * Remove usage of 'cross' in CI * Reduce dependency version churn * Changelog entry * Format changelog with VSCode prettier format-on-save
1 parent 5e0d194 commit 73a7587

File tree

14 files changed

+161
-154
lines changed

14 files changed

+161
-154
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
target: thumbv6m-none-eabi
3535
- uses: actions-rs/cargo@v1
3636
with:
37-
use-cross: true
3837
command: clippy
3938
# dummy feature to satisfy build.rs
4039
args: --features mcu-STM32L083VZTx -- -D warnings
@@ -50,7 +49,6 @@ jobs:
5049
target: thumbv6m-none-eabi
5150
- uses: actions-rs/cargo@v1
5251
with:
53-
use-cross: true
5452
command: package
5553
args: --no-verify
5654
build_and_test:
@@ -80,6 +78,5 @@ jobs:
8078
env:
8179
RUSTFLAGS: "-D warnings"
8280
with:
83-
use-cross: true
8481
command: build
8582
args: --release --examples --features "${{ matrix.features }}"

CHANGELOG.md

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7-
8-
97
## [Unreleased]
108

119
<!-- When making a PR, please update this section. Note: This document should
@@ -17,14 +15,34 @@ forget to update the links at the bottom of the changelog as well.-->
1715

1816
### Breaking Changes
1917

18+
- Upgrade `stm32l0` to latest version, and other dependency updates ([#215]):
19+
20+
`dependencies`
21+
22+
| crate | from | to |
23+
| ----------- | ------ | ------ |
24+
| cast | 0.2.2 | 0.3.0 |
25+
| cortex-m-rt | 0.6.8 | 0.7.0 |
26+
| rtcc | 0.2 | 0.3.0 |
27+
| stm32l0 | 0.13.0 | 0.15.1 |
28+
29+
`dev-dependencies`
30+
31+
| crate | from | to |
32+
| -------------------- | ----- | ----- |
33+
| aligned | 0.3.1 | 0.4.1 |
34+
| cortex-m-rtic | 0.5.6 | 1.1.3 |
35+
| cortex-m-semihosting | 0.3.2 | 0.5.0 |
36+
| panic-semihosting | 0.5.1 | 0.6.0 |
37+
2038
### Non-Breaking Changes
2139

2240
### Fixes
41+
2342
- Add other possible pins for SPI1 for L0x1 family
2443

2544
### Documentation
2645

27-
2846
## [v0.9.0] - 2021-12-11
2947

3048
### Additions
@@ -45,61 +63,57 @@ forget to update the links at the bottom of the changelog as well.-->
4563

4664
- Fix Cargo features used by docs.rs ([#203])
4765

48-
4966
## [v0.8.0] - 2021-11-04
5067

5168
### Additions
5269

5370
- Add `Timer::new` to create timer without starting. ([#152])
54-
- Add (untested) example `temperature` ([#161]) which uses `adc` to read the
55-
internal temperature and also an externally connected TMP36 analog sensor.
56-
- Add `Pwm::set_frequency` to allow dynamically changing the underlying PWM timer's
57-
frequency. This was previously impossible without resorting to `unsafe` because the
58-
channels where moved out of the timer struct and Rust's ownership rules forbade us
59-
to borrow the timer to call `set_frequency`. ([#174])
60-
- Add Cargo features for flash and RAM sizes allowing to pass the correct sizes to
61-
the linker instead of having a default for the whole sub-family. ([#173])
71+
- Add (untested) example `temperature` ([#161]) which uses `adc` to read the internal temperature
72+
and also an externally connected TMP36 analog sensor.
73+
- Add `Pwm::set_frequency` to allow dynamically changing the underlying PWM timer's frequency. This
74+
was previously impossible without resorting to `unsafe` because the channels where moved out of
75+
the timer struct and Rust's ownership rules forbade us to borrow the timer to call
76+
`set_frequency`. ([#174])
77+
- Add Cargo features for flash and RAM sizes allowing to pass the correct sizes to the linker
78+
instead of having a default for the whole sub-family. ([#173])
6279

6380
### Breaking Changes
6481

65-
- Migrate from custom `Hertz` implementation to [`embedded-time`](https://crates.io/crates/embedded-time) ([#183])
82+
- Migrate from custom `Hertz` implementation to
83+
[`embedded-time`](https://crates.io/crates/embedded-time) ([#183])
6684
- Add `enable` to `GeneralPurposeTimer`
6785
- `Instance::clock_frequency` is now an associated function and doesn't take `&self` anymore.
6886
- Build script requires that exactly one `flash-*` and one `ram-*` feature is enabled. They are
69-
enabled automatically when using an `mcu-*` feature, but if you manually selected the other features
70-
before this will break the build because of the missing features.
71-
- The `rtc::RTC` struct has been renamed to `rtc::Rtc` and includes a big
72-
refactoring and a few API changes. It now implements the traits from the
73-
[rtcc crate](https://docs.rs/rtcc/) and uses date/time types from Chrono.
74-
- When downgrading GPIO pins, not only the pin number but also the port
75-
identifier is erased. To update your code, replace
76-
`PA`/`PB`/`PC`/`PD`/`PE`/`PH` with `Pin`. ([#190])
87+
enabled automatically when using an `mcu-*` feature, but if you manually selected the other
88+
features before this will break the build because of the missing features.
89+
- The `rtc::RTC` struct has been renamed to `rtc::Rtc` and includes a big refactoring and a few API
90+
changes. It now implements the traits from the [rtcc crate](https://docs.rs/rtcc/) and uses
91+
date/time types from Chrono.
92+
- When downgrading GPIO pins, not only the pin number but also the port identifier is erased. To
93+
update your code, replace `PA`/`PB`/`PC`/`PD`/`PE`/`PH` with `Pin`. ([#190])
7794

7895
### Non-Breaking Changes
7996

80-
- The crate now has an optional `rtc` feature (enabled by default). The `rtc`
81-
module is only available if that feature is enabled. Enabling the feature
82-
also pulls in the `rtcc` and `chrono` dependencies, in oder to support a
83-
richer calendar / clock API.
97+
- The crate now has an optional `rtc` feature (enabled by default). The `rtc` module is only
98+
available if that feature is enabled. Enabling the feature also pulls in the `rtcc` and `chrono`
99+
dependencies, in oder to support a richer calendar / clock API.
84100

85101
### Fixes
86102

87103
- Fixed potential race condition when flushing the tx serial buffer.
88-
- Fixed RTC year handling. Previously, the implementation incorrectly assumed
89-
that the BCD year 00 corresponds to 1970, but this results in a wrong leap
90-
year calculation. The correct time base is the year 2000.
91-
104+
- Fixed RTC year handling. Previously, the implementation incorrectly assumed that the BCD year 00
105+
corresponds to 1970, but this results in a wrong leap year calculation. The correct time base is
106+
the year 2000.
92107

93108
## [v0.7.0] - 2021-03-10
94109

95110
### Additions
96111

97112
- Timers: Add support for TIM6 ([#101])
98-
- Timers: Implement `LinkedTimer` ([#115]). It is initialized with two hardware
99-
timers (either TIM2/TIM3 or TIM21/TIM22). The two timers are configured in
100-
master/slave mode so that an overflow of the master timer triggers an update
101-
on the slave timer. This way, two 16 bit timers can be combined to a single
102-
32 bit timer. (The STM32L0 does not have 32 bit timers.)
113+
- Timers: Implement `LinkedTimer` ([#115]). It is initialized with two hardware timers (either
114+
TIM2/TIM3 or TIM21/TIM22). The two timers are configured in master/slave mode so that an overflow
115+
of the master timer triggers an update on the slave timer. This way, two 16 bit timers can be
116+
combined to a single 32 bit timer. (The STM32L0 does not have 32 bit timers.)
103117
- Remove config tests that prevented stm32l0x1 devices from using ADC with DMA ([#124])
104118
- Add `enable_lse` method to RCC structure that configures LSE ([#130])
105119
- Expose factory calibration data ([#121])
@@ -124,8 +138,8 @@ forget to update the links at the bottom of the changelog as well.-->
124138
### Fixes
125139

126140
- I2C: Before starting new transaction ensure that both TX and RX buffers are empty ([#98])
127-
- Detect rollover using positions rather than DMA flags ([#127]). This fixes a
128-
faulty DMA buffer overflow in `adc_trig` example ([#104]).
141+
- Detect rollover using positions rather than DMA flags ([#127]). This fixes a faulty DMA buffer
142+
overflow in `adc_trig` example ([#104]).
129143
- Maximum frequency for stm32l0 increased to 32MHz ([#129])
130144
- GPIO: Fix `Pin::into_pull_down_input` ([#142])
131145

@@ -135,33 +149,25 @@ forget to update the links at the bottom of the changelog as well.-->
135149
- Port examples to RTFM/RTIC 0.5 ([#100], [#116])
136150
- Improve README ([#119])
137151

138-
139-
140152
## [v0.6.2] - 2020-05-03
141153

142154
_Not yet tracked in this changelog._
143155

144-
145-
146156
## [v0.6.1] - 2020-04-08
147157

148158
_Not yet tracked in this changelog._
149159

150-
151-
152160
## [v0.6.0] - 2020-04-05
153161

154162
_Not yet tracked in this changelog._
155163

156-
157-
158164
## v0.5.0 - 2019-12-02
159165

160-
*Not yet tracked in this changelog.*
161-
162-
166+
_Not yet tracked in this changelog._
163167

164168
<!-- Links to pull requests and issues. -->
169+
170+
[#215]: https://github.com/stm32-rs/stm32l0xx-hal/pull/215
165171
[#208]: https://github.com/stm32-rs/stm32l0xx-hal/pull/208
166172
[#206]: https://github.com/stm32-rs/stm32l0xx-hal/pull/206
167173
[#203]: https://github.com/stm32-rs/stm32l0xx-hal/pull/203
@@ -202,7 +208,8 @@ _Not yet tracked in this changelog._
202208
[#98]: https://github.com/stm32-rs/stm32l0xx-hal/pull/98
203209

204210
<!-- Links to version diffs. -->
205-
[Unreleased]: https://github.com/stm32-rs/stm32l0xx-hal/compare/v0.9.0...HEAD
211+
212+
[unreleased]: https://github.com/stm32-rs/stm32l0xx-hal/compare/v0.9.0...HEAD
206213
[v0.9.0]: https://github.com/stm32-rs/stm32l0xx-hal/compare/v0.8.0...v0.9.0
207214
[v0.8.0]: https://github.com/stm32-rs/stm32l0xx-hal/compare/v0.7.0...v0.8.0
208215
[v0.7.0]: https://github.com/stm32-rs/stm32l0xx-hal/compare/v0.6.2...v0.7.0

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ targets = ["thumbv6m-none-eabi"]
2222

2323
[dependencies]
2424
as-slice = "0.2.1"
25-
cast = { version = "0.2.2", default-features = false }
26-
cortex-m = "0.7.0"
27-
cortex-m-rt = "0.6.8"
25+
cast = { version = "0.3.0", default-features = false }
26+
cortex-m = "0.7.0"
27+
cortex-m-rt = "0.7.0"
2828
embedded-hal = { version = "0.2.3", features = ["unproven"] }
2929
embedded-time = "0.12.0"
3030
nb = "1.0.0"
31-
rtcc = { version = "0.2", optional = true }
32-
stm32l0 = "0.13.0"
31+
rtcc = { version = "0.3.0", optional = true }
32+
stm32l0 = "0.15.1"
3333
stm32-usbd = { version = "0.6.0", optional = true }
3434
void = { version = "1.0.2", default-features = false }
3535

3636
[dev-dependencies]
37-
aligned = "0.3.1"
38-
cortex-m-rtic = "0.5.6"
39-
cortex-m-semihosting = "0.3.2"
37+
aligned = "0.4.1"
38+
cortex-m-rtic = "1.1.3"
39+
cortex-m-semihosting = "0.5.0"
4040
heapless = "0.7.1"
4141
panic-halt = "0.2.0"
42-
panic-semihosting = "0.5.1"
42+
panic-semihosting = "0.6.0"
4343
usb-device = "0.2.3"
4444
usbd-serial = "0.1.0"
4545

examples/button_irq_rtic.rs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
// #![deny(warnings)]
1+
#![deny(warnings)]
22
#![deny(unsafe_code)]
33
#![no_main]
44
#![no_std]
55

6-
extern crate panic_halt;
7-
6+
use panic_halt as _;
87
use rtic::app;
9-
use stm32l0xx_hal::{
10-
exti::{Exti, ExtiLine, GpioLine, TriggerEdge},
11-
gpio::*,
12-
prelude::*,
13-
rcc::Config,
14-
syscfg::SYSCFG,
15-
};
168

179
#[app(device = stm32l0xx_hal::pac, peripherals = true)]
18-
const APP: () = {
19-
struct Resources {
10+
mod app {
11+
use stm32l0xx_hal::{
12+
exti::{Exti, ExtiLine, GpioLine, TriggerEdge},
13+
gpio::*,
14+
prelude::*,
15+
rcc::Config,
16+
syscfg::SYSCFG,
17+
};
18+
19+
#[shared]
20+
struct Shared {}
21+
22+
#[local]
23+
struct Local {
2024
led: Pin<Output<PushPull>>,
21-
int: Exti,
2225
}
2326

2427
#[init]
25-
fn init(ctx: init::Context) -> init::LateResources {
28+
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
2629
let device = ctx.device;
2730

2831
// Configure the clock.
@@ -46,23 +49,21 @@ const APP: () = {
4649
exti.listen_gpio(&mut syscfg, button.port(), line, TriggerEdge::Falling);
4750

4851
// Return the initialised resources.
49-
init::LateResources { led, int: exti }
52+
(Shared {}, Local { led }, init::Monotonics())
5053
}
5154

52-
#[task(binds = EXTI0_1, resources = [led])]
53-
fn EXTI0_1(ctx: EXTI0_1::Context) {
54-
static mut STATE: bool = false;
55-
55+
#[task(binds = EXTI0_1, local = [ led, state: bool = false ])]
56+
fn exti0_1(ctx: exti0_1::Context) {
5657
// Clear the interrupt flag.
5758
Exti::unpend(GpioLine::from_raw_line(0).unwrap());
5859

5960
// Change the LED state on each interrupt.
60-
if *STATE {
61-
ctx.resources.led.set_low().unwrap();
62-
*STATE = false;
61+
if *ctx.local.state {
62+
ctx.local.led.set_low().unwrap();
63+
*ctx.local.state = false;
6364
} else {
64-
ctx.resources.led.set_high().unwrap();
65-
*STATE = true;
65+
ctx.local.led.set_high().unwrap();
66+
*ctx.local.state = true;
6667
}
6768
}
68-
};
69+
}

examples/mco.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ fn main() -> ! {
2727
let gpioa = dp.GPIOA.split(&mut rcc);
2828

2929
// Source MCO from HSI16, configure prescaler to divide by 8 to get 2MHz output.
30-
rcc.configure_mco(MCOSEL_A::HSI16, MCOPRE_A::DIV8, (gpioa.pa8, gpioa.pa9));
30+
rcc.configure_mco(MCOSEL_A::Hsi16, MCOPRE_A::Div8, (gpioa.pa8, gpioa.pa9));
3131

3232
// Individual pins can also be set by passing them directly:
33-
// rcc.enable_mco(MCOSEL_A::HSI16, MCOPRE_A::DIV8, gpioa.pa8);
33+
// rcc.enable_mco(MCOSEL_A::Hsi16, MCOPRE_A::Div8, gpioa.pa8);
3434

3535
// Or for larger devices, all 3 MCO pins can be configured:
36-
// rcc.configure_mco(MCOSEL_A::HSI16, MCOPRE_A::DIV8, (gpioa.pa8, gpioa.pa9, gpiob.pb13));
36+
// rcc.configure_mco(MCOSEL_A::Hsi16, MCOPRE_A::Div8, (gpioa.pa8, gpioa.pa9, gpiob.pb13));
3737

3838
// Probe PA8 or PA9 to see generated 2MHz MCO signal.
3939
loop {}

examples/temperature.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ fn main() -> ! {
110110

111111
loop {
112112
let mcu_value = mcutemp.read_tempc(&mut adc);
113-
hprintln!("inaccurate MCU temp: {}", mcu_value).unwrap();
113+
hprintln!("inaccurate MCU temp: {}", mcu_value);
114114

115115
let tmp36_mv: u32 = tmp36.read_mv(&mut adc);
116116
let tmp36_temp: i32 = tmp36.read_tempc(&mut adc);
117-
hprintln!("external sensor: {} mV, {} C.", tmp36_mv, tmp36_temp).unwrap();
117+
hprintln!("external sensor: {} mV, {} C.", tmp36_mv, tmp36_temp);
118118
}
119119
}

0 commit comments

Comments
 (0)