Skip to content

Commit 0273aed

Browse files
committed
Sync upstream, update LPUART implementation.
2 parents f655a95 + bf2ded1 commit 0273aed

Some content is hidden

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

70 files changed

+7465
-3061
lines changed

.cargo/config

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,5 @@ rustflags = [
2727

2828
[build]
2929
# Pick ONE of these compilation targets
30-
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
31-
# target = "thumbv7m-none-eabi" # Cortex-M3
32-
target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
33-
# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
30+
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
31+
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

.github/workflows/ci.yml

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
on:
22
push:
3-
branches: [ master ]
3+
branches: [master]
44
pull_request:
55

66
name: Continuous integration
@@ -9,15 +9,56 @@ jobs:
99
ci:
1010
runs-on: ubuntu-latest
1111
strategy:
12-
matrix: # All permutations of {rust, mcu}
12+
matrix: # All permutations of {rust, mcu}
13+
rust:
14+
- stable
15+
mcu: # Note leading comma is required if any additional fetures are specified
16+
- { id: stm32l412, additional-features: ",stm32-usbd" }
17+
- { id: stm32l422, additional-features: ",stm32-usbd" }
18+
- { id: stm32l431, additional-features: "" }
19+
- { id: stm32l432, additional-features: ",stm32-usbd" }
20+
- { id: stm32l433, additional-features: ",stm32-usbd" }
21+
- { id: stm32l442, additional-features: ",stm32-usbd" }
22+
- { id: stm32l443, additional-features: ",stm32-usbd" }
23+
- { id: stm32l451, additional-features: "" }
24+
- { id: stm32l452, additional-features: ",stm32-usbd" }
25+
- { id: stm32l462, additional-features: ",stm32-usbd" }
26+
- { id: stm32l471, additional-features: "" }
27+
- { id: stm32l475, additional-features: "" } # USB_OTG not supported by PAC
28+
- { id: stm32l476, additional-features: ",otg_fs" }
29+
- { id: stm32l486, additional-features: ",otg_fs" }
30+
- { id: stm32l496, additional-features: ",otg_fs" }
31+
- { id: stm32l4a6, additional-features: ",otg_fs" }
32+
33+
steps:
34+
- uses: actions/checkout@v2
35+
- uses: actions-rs/toolchain@v1
36+
with:
37+
profile: minimal
38+
toolchain: ${{ matrix.rust }}
39+
target: thumbv7em-none-eabihf
40+
override: true
41+
- name: build
42+
uses: actions-rs/cargo@v1
43+
with:
44+
use-cross: true
45+
command: build
46+
args: --verbose --release --examples --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
47+
- name: test
48+
uses: actions-rs/cargo@v1
49+
with:
50+
command: test
51+
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
52+
53+
ci-r9:
54+
runs-on: ubuntu-latest
55+
strategy:
56+
matrix:
1357
rust:
1458
- stable
1559
mcu:
16-
- stm32l4x1
17-
- stm32l4x2
18-
- stm32l4x3
19-
- stm32l4x5
20-
- stm32l4x6
60+
- { id: stm32l4r9, additional-features: "" }
61+
- { id: stm32l4s9, additional-features: "" }
2162

2263
steps:
2364
- uses: actions/checkout@v2
@@ -27,12 +68,15 @@ jobs:
2768
toolchain: ${{ matrix.rust }}
2869
target: thumbv7em-none-eabihf
2970
override: true
30-
- uses: actions-rs/cargo@v1
71+
- name: build
72+
uses: actions-rs/cargo@v1
3173
with:
3274
use-cross: true
3375
command: build
34-
args: --verbose --release --examples --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu }}
35-
- uses: actions-rs/cargo@v1
76+
args: --verbose --release --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
77+
# note that examples were not built
78+
- name: test
79+
uses: actions-rs/cargo@v1
3680
with:
3781
command: test
38-
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu }}
82+
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}

.github/workflows/clippy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
- uses: actions-rs/clippy-check@v1
2020
with:
2121
token: ${{ secrets.GITHUB_TOKEN }}
22-
args: --examples --target thumbv7em-none-eabihf --features=stm32l4x2,rt,unproven
22+
args: --examples --target thumbv7em-none-eabihf --features=stm32l432,rt,unproven

CHANGELOG.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,63 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6-
## [Unreleased]
6+
7+
## [v0.7.1] - 2022-04-11
8+
9+
### Fixed
10+
11+
- Shorten old buffer when we have extra characters in DMA buffer after a character match.
12+
## [v0.7.0] - 2022-04-04
13+
14+
### Added
15+
16+
- Add delay implementation based on `cortex_m::asm::delay`.
17+
- Implement `RngCore` and `CryptoRng` for the hardware RNG.
18+
- Support analog to digital converters (ADC).
19+
- Support SPI slave mode.
20+
- Add DMA and interrupt support for SPI and ADC peripherals.
21+
- Add support for measuring Vref, Vbat and temperature.
22+
- Add alternate function 0 to GPIO.
23+
- Add preliminary bxCAN support.
24+
- Add more GPIO combinations for I2C and PWM peripherals.
25+
- Add wakeup clock sources to RTC config.
26+
- Support RTC domain backup registers.
27+
- Support I2C on stm32l4x3 devices.
28+
- Support I2C3 peripheral on stm32l4x6 devices.
29+
- Experimental support for the Synopsis USB library.
30+
- Experimental support for USB OTG FS for stm32l4x5 and stm32l4x6 devices.
31+
- Support stm32l4r9 devices.
32+
33+
### Changed
34+
35+
- Use device-specific features rather than by-peripheral features.
36+
- Use `fugit` duration nd rate units instead of custom
37+
- Use const-generics for GPIO (require Rust 1.51)
38+
- Import I2C implementation from `stm32h7xx-hal` crate.
39+
- Use a `Config` struct for initializing I2C peripherals.
40+
- Check that the clock requested for the low-power timer is enabled.
41+
- Take `clocks` argument by value when setting up low-power timer.
42+
- Use sane low-power timer defaults (LSI, no prescaler).
43+
- Make `LowPowerTimer<_>::set_autoreload()` public.
44+
- Enable SPI2 for all stm32l4x2 devices as some of them have it.
45+
- Target hardfp by default since stm32l4 cores are Cortex-M4F.
46+
- Require typed input when converting from milliseconds to hertz.
47+
- Rework alternate function typestates.
48+
- Use MSI as default/fallback clock source for SYSCLK.
49+
- Use specialized PAC for stm32l412 and stm32l422 devices.
50+
- Add `toggeable` trait to GPIO pins.
51+
- Update `stm32l4` dependency.
52+
53+
### Fixed
54+
55+
- Fix TIM1 PWM frequency computation.
56+
- Fix TIM5 counter width.
57+
- Fix PSC computation off-by-one error.
58+
- Change wait states values according to datasheet.
59+
- Fix incorrect I2C2 on PC0/PC1 on stm32l4x3 devices.
60+
- Swap QSPI pins and remove conflicting/wrong implementations.
61+
- Add power on GPIOG pins.
62+
- Support 0 byte writes on I2C.
763

864
## [v0.6.0] - 2020-12-11
965

@@ -192,7 +248,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
192248

193249
- Initial release
194250

195-
[Unreleased]: https://github.com/stm32-rs/stm32l4xx-hal/compare/v0.6.0...HEAD
251+
[v0.7.0]: https://github.com/stm32-rs/stm32l4xx-hal/compare/v0.6.0...v0.7.0
196252
[v0.6.0]: https://github.com/stm32-rs/stm32l4xx-hal/compare/v0.5.0...v0.6.0
197253
[v0.5.0]: https://github.com/stm32-rs/stm32l4xx-hal/compare/v0.4.0...v0.5.0
198254
[v0.4.0]: https://github.com/stm32-rs/stm32l4xx-hal/compare/v0.3.6...v0.4.0

Cargo.toml

Lines changed: 83 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stm32l4xx-hal"
3-
version = "0.6.0"
3+
version = "0.7.1"
44
authors = ["Scott Mabin <[email protected]>"]
55
description = "Hardware abstraction layer for the stm32l4xx chips"
66
keywords = ["no-std", "stm32l4xx", "stm32l4", "embedded", "embedded-hal"]
@@ -21,9 +21,13 @@ exclude = [
2121
edition = "2018"
2222

2323
[dependencies]
24-
cortex-m = "0.6.3"
24+
cortex-m = "0.7"
2525
nb = "0.1.1"
26-
stm32l4 = "0.13.0"
26+
stm32l4 = "0.14.0"
27+
embedded-dma = "0.1"
28+
bxcan = ">=0.4, <0.7"
29+
fugit = "0.3.5"
30+
bitfield = "0.13.2"
2731

2832
[dependencies.rand_core]
2933
version = "0.6.2"
@@ -42,7 +46,7 @@ default-features = false
4246
version = "1.1"
4347

4448
[dependencies.embedded-hal]
45-
version = "0.2.3"
49+
version = "0.2.6"
4650
features = ["unproven"]
4751

4852
[dependencies.stm32-usbd]
@@ -54,28 +58,73 @@ version = "0.2.4"
5458
features = ["cortex-m", "fs"]
5559
optional = true
5660

61+
[dependencies.time]
62+
version = "0.3"
63+
default-features = false
64+
5765
[package.metadata.docs.rs]
58-
features = ["rt", "stm32l4x2", "stm32-usbd"]
66+
features = ["rt", "stm32l432", "stm32-usbd"]
5967

6068
[features]
6169
rt = ["stm32l4/rt"]
62-
stm32l4x1 = ["stm32l4/stm32l4x1"]
63-
stm32l4x2 = ["stm32l4/stm32l4x2"]
64-
stm32l4x3 = ["stm32l4/stm32l4x3"]
65-
stm32l4x5 = ["stm32l4/stm32l4x5"]
66-
stm32l4x6 = ["stm32l4/stm32l4x6"]
6770
unproven = ["embedded-hal/unproven"]
6871
otg_fs = ["synopsys-usb-otg"]
6972

73+
# L4x1
74+
stm32l431 = [ "stm32l4/stm32l4x1" ]
75+
stm32l451 = [ "stm32l4/stm32l4x1" ]
76+
stm32l471 = [ "stm32l4/stm32l4x1" ]
77+
78+
# L412
79+
stm32l412 = [ "stm32l4/stm32l412" ]
80+
stm32l422 = [ "stm32l4/stm32l412" ]
81+
82+
# L4x2
83+
stm32l432 = [ "stm32l4/stm32l4x2" ]
84+
stm32l442 = [ "stm32l4/stm32l4x2" ]
85+
stm32l452 = [ "stm32l4/stm32l4x2" ]
86+
stm32l462 = [ "stm32l4/stm32l4x2" ]
87+
88+
# L4x3
89+
stm32l433 = [ "stm32l4/stm32l4x3" ]
90+
stm32l443 = [ "stm32l4/stm32l4x3" ]
91+
92+
# L4x5
93+
stm32l475 = [ "stm32l4/stm32l4x5" ]
94+
95+
# L4x6
96+
stm32l476 = [ "stm32l4/stm32l4x6" ]
97+
stm32l486 = [ "stm32l4/stm32l4x6" ]
98+
stm32l496 = [ "stm32l4/stm32l4x6" ]
99+
stm32l4a6 = [ "stm32l4/stm32l4x6" ]
100+
101+
# L4+ series PAC support??
102+
#stm32l4p5 = [ "stm32l4/stm32l4x5" ]
103+
#stm32l4q5 = [ "stm32l4/stm32l4x5" ]
104+
#stm32l4r5 = [ "stm32l4/stm32l4x5" ]
105+
#stm32l4s5 = [ "stm32l4/stm32l4x5" ]
106+
107+
# L4x7
108+
#stm32l4r7 = [ "stm32l4/stm32l4x7" ]
109+
#stm32l4s7 = [ "stm32l4/stm32l4x7" ]
110+
111+
## L4x9
112+
stm32l4r9 = [ "stm32l4/stm32l4r9" ] # PAC has an L4r9 specific variation
113+
stm32l4s9 = [ "stm32l4/stm32l4r9" ]
114+
70115
[dev-dependencies]
71116
panic-halt = "0.2.0"
72117
panic-semihosting = "0.5.0"
73118
cortex-m-semihosting = "0.3.5"
74-
cortex-m-rt = "0.6.12"
119+
cortex-m-rt = "0.7"
75120
usb-device = "0.2.3"
76121
usbd-serial = "0.1.0"
77122
heapless = "0.5"
78-
cortex-m-rtic = "0.5.5"
123+
124+
[dev-dependencies.cortex-m-rtic]
125+
version = "0.5.9"
126+
default-features = false
127+
features = ["cortex-m-7"]
79128

80129
[dev-dependencies.panic-rtt-target]
81130
version = "0.1.1"
@@ -97,15 +146,19 @@ lto = true
97146

98147
[[example]]
99148
name = "adc"
100-
required-features = ["rt", "stm32l4x3"]
149+
required-features = ["rt"]
150+
151+
[[example]]
152+
name = "can-loopback"
153+
required-features = ["rt", "stm32l433" ] # CAN peripheral on ever series except L41/L42, gate so CI will pass
101154

102155
[[example]]
103156
name = "irq_button"
104157
required-features = ["rt"]
105158

106159
[[example]]
107160
name = "qspi"
108-
required-features = ["rt", "stm32l4x5"]
161+
required-features = ["rt", "stm32l476"] # L433/43 have no QSPI peripheral and are highly likely to be used
109162

110163
[[example]]
111164
name = "rng"
@@ -117,25 +170,36 @@ required-features = ["rt"]
117170

118171
[[example]]
119172
name = "rtic_frame_serial_dma"
120-
required-features = ["rt", "stm32l4x2"]
173+
required-features = ["rt"]
174+
175+
[[example]]
176+
name = "spi_dma_rxtx"
177+
required-features = ["rt"]
121178

122179
[[example]]
123180
name = "serial_echo_rtic"
124-
required-features = ["rt", "stm32l4x3"]
181+
required-features = ["rt"]
125182

126183
[[example]]
127184
name = "timer"
128185
required-features = ["rt"]
129186

130187
[[example]]
131188
name = "usb_serial"
132-
required-features = ["rt", "stm32l4x2", "stm32-usbd"]
189+
required-features = ["rt", "stm32-usbd"]
133190

134191
[[example]]
135192
name = "otg_fs_serial"
136-
required-features = ["rt", "stm32l4x6", "otg_fs"]
193+
required-features = ["rt", "otg_fs"]
137194

138195
[[example]]
139196
name = "i2c_write"
140-
required-features = ["stm32l4x1"]
197+
required-features = ["stm32l433"]
198+
199+
[[example]]
200+
name = "lptim_rtic"
201+
required-features = ["rt"]
141202

203+
[[example]]
204+
name = "adc_dma"
205+
required-features = ["rt"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _formerly [MabezDev/stm32l4xx-hal](https://github.com/mabezdev/stm32l4xx-hal)_
1414

1515
## About
1616

17-
- Minimum rustc version 1.31
17+
- Minimum rustc version 1.51
1818

1919
## License
2020

examples/adc.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ use panic_rtt_target as _;
55

66
use cortex_m_rt::entry;
77
use rtt_target::{rprint, rprintln};
8-
use stm32l4xx_hal::{adc::ADC, delay::Delay, pac, prelude::*};
8+
use stm32l4xx_hal::{
9+
adc::{Adc, AdcCommon},
10+
delay::Delay,
11+
pac,
12+
prelude::*,
13+
};
914

1015
#[entry]
1116
fn main() -> ! {
@@ -22,13 +27,8 @@ fn main() -> ! {
2227
let clocks = rcc.cfgr.freeze(&mut flash.acr, &mut pwr);
2328

2429
let mut delay = Delay::new(cp.SYST, clocks);
25-
let mut adc = ADC::new(
26-
dp.ADC1,
27-
dp.ADC_COMMON,
28-
&mut rcc.ahb2,
29-
&mut rcc.ccipr,
30-
&mut delay,
31-
);
30+
let adc_common = AdcCommon::new(dp.ADC_COMMON, &mut rcc.ahb2);
31+
let mut adc = Adc::adc1(dp.ADC1, adc_common, &mut rcc.ccipr, &mut delay);
3232

3333
let mut gpioc = dp.GPIOC.split(&mut rcc.ahb2);
3434
let mut a1 = gpioc.pc0.into_analog(&mut gpioc.moder, &mut gpioc.pupdr);

0 commit comments

Comments
 (0)