Skip to content

Commit c68b71c

Browse files
Merge #473
473: Implement new InterruptNumber trait from next cortex-m release r=adamgreig a=therealprof This eliminates the bare-metal and cortex-m-rt dependencies for Cortex-M and thus changes CI and svd2rust-regress accordingly. Replaces #455 Signed-off-by: Daniel Egger <[email protected]> Co-authored-by: Daniel Egger <[email protected]>
2 parents d6c668d + be9fd64 commit c68b71c

File tree

5 files changed

+15
-44
lines changed

5 files changed

+15
-44
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3333

3434
- Don't generate pre Edition 2018 `extern crate` statements anymore
3535

36+
- [breaking-change] Cortex-M PACs now rely on
37+
`cortex_m::interrupt::InterruptNumber` instead of `bare_metal::Nr` for
38+
interrupt number handling. The minimum supported `cortex-m` version is now
39+
**0.7** and `bare-metal` is not a dependency anymore.
40+
3641
## [v0.17.0] - 2019-12-31
3742

3843
### Fixed

ci/script.sh

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,14 @@ main() {
6868

6969
# test crate
7070
cargo init --name foo $td
71-
echo 'cortex-m = "0.6.0"' >> $td/Cargo.toml
72-
echo 'cortex-m-rt = "0.6.9"' >> $td/Cargo.toml
71+
echo 'cortex-m = "0.7.0"' >> $td/Cargo.toml
72+
echo 'cortex-m-rt = "0.6.13"' >> $td/Cargo.toml
7373
echo 'vcell = "0.1.0"' >> $td/Cargo.toml
7474
echo '[profile.dev]' >> $td/Cargo.toml
7575
echo 'incremental = false' >> $td/Cargo.toml
7676

7777
case $VENDOR in
7878
Atmel)
79-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
80-
echo 'version = "0.2.0"' >> $td/Cargo.toml
81-
8279
# BAD-SVD missing resetValue
8380
# test_svd AT91SAM9CN11
8481
# test_svd AT91SAM9CN12
@@ -162,9 +159,6 @@ main() {
162159
;;
163160

164161
Freescale)
165-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
166-
echo 'version = "0.2.0"' >> $td/Cargo.toml
167-
168162
# BAD-SVD bad enumeratedValue value
169163
# test_svd MKV56F20
170164
# test_svd MKV56F22
@@ -313,9 +307,6 @@ main() {
313307
;;
314308

315309
Fujitsu)
316-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
317-
echo 'version = "0.2.0"' >> $td/Cargo.toml
318-
319310
# OK
320311
test_svd MB9AF10xN
321312
test_svd MB9AF10xR
@@ -420,19 +411,13 @@ main() {
420411
;;
421412

422413
Holtek)
423-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
424-
echo 'version = "0.2.0"' >> $td/Cargo.toml
425-
426414
# OK
427415
test_svd ht32f125x
428416
test_svd ht32f175x
429417
test_svd ht32f275x
430418
;;
431419

432420
Nordic)
433-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
434-
echo 'version = "0.2.0"' >> $td/Cargo.toml
435-
436421
# BAD-SVD two enumeratedValues have the same value
437422
# test_svd nrf52
438423

@@ -441,18 +426,12 @@ main() {
441426
;;
442427

443428
Nuvoton)
444-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
445-
echo 'version = "0.2.0"' >> $td/Cargo.toml
446-
447429
# OK
448430
test_svd M051_Series
449431
test_svd NUC100_Series
450432
;;
451433

452434
NXP)
453-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
454-
echo 'version = "0.2.0"' >> $td/Cargo.toml
455-
456435
test_svd MK22F25612
457436
test_svd MKW41Z4
458437

@@ -517,9 +496,6 @@ main() {
517496
;;
518497

519498
SiliconLabs)
520-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
521-
echo 'version = "0.2.0"' >> $td/Cargo.toml
522-
523499
# #99 regression tests
524500
test_svd SIM3C1x4_SVD
525501
test_svd SIM3C1x6_SVD
@@ -536,9 +512,6 @@ main() {
536512
;;
537513

538514
Spansion)
539-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
540-
echo 'version = "0.2.0"' >> $td/Cargo.toml
541-
542515
# OK
543516
test_svd MB9AF12xK
544517
test_svd MB9AF12xL
@@ -634,9 +607,6 @@ main() {
634607
;;
635608

636609
STMicro)
637-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
638-
echo 'version = "0.2.0"' >> $td/Cargo.toml
639-
640610
# OK
641611
test_svd STM32F030
642612
test_svd STM32F031x
@@ -676,9 +646,6 @@ main() {
676646
;;
677647

678648
Toshiba)
679-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
680-
echo 'version = "0.2.0"' >> $td/Cargo.toml
681-
682649
# BAD-SVD resetValue is bigger than the register size
683650
# test_svd M365
684651
# test_svd M367

ci/svd2rust-regress/src/svd_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::process::{Command, Output};
77

88
const CRATES_ALL: &[&str] = &["bare-metal = \"0.2.0\"", "vcell = \"0.1.0\""];
99
const CRATES_MSP430: &[&str] = &["msp430 = \"0.2.2\""];
10-
const CRATES_CORTEX_M: &[&str] = &["cortex-m = \"0.6.0\"", "cortex-m-rt = \"0.6.0\""];
10+
const CRATES_CORTEX_M: &[&str] = &["cortex-m = \"0.7.0\"", "cortex-m-rt = \"0.6.13\""];
1111
const CRATES_RISCV: &[&str] = &["riscv = \"0.5.0\"", "riscv-rt = \"0.6.0\""];
1212
const CRATES_XTENSALX6: &[&str] = &["xtensa-lx6-rt = \"0.2.0\"", "xtensa-lx6 = \"0.1.0\""];
1313
const PROFILE_ALL: &[&str] = &["[profile.dev]", "incremental = false"];

src/generate/interrupt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ pub fn render(
155155

156156
let self_token = quote!(self);
157157
let (enum_repr, nr_expr) = if variants.is_empty() {
158-
(quote!(), quote!(match *#self_token {}))
158+
(quote!(), quote!(match #self_token {}))
159159
} else {
160-
(quote!(#[repr(u8)]), quote!(*#self_token as u8))
160+
(quote!(#[repr(u16)]), quote!(#self_token as u16))
161161
};
162162

163163
if target == Target::Msp430 {
@@ -180,9 +180,9 @@ pub fn render(
180180
#variants
181181
}
182182

183-
unsafe impl bare_metal::Nr for Interrupt {
183+
unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
184184
#[inline(always)]
185-
fn nr(&#self_token) -> u8 {
185+
fn number(#self_token) -> u16 {
186186
#nr_expr
187187
}
188188
}

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,18 @@
5353
//! ```
5454
//!
5555
//! The resulting crate must provide an opt-in "rt" feature and depend on these crates:
56-
//! `bare-metal` v0.2.x, `cortex-m` v0.5.x, `cortex-m-rt` >=v0.6.5 and `vcell` v0.1.x. Furthermore
56+
//! `cortex-m` v0.7, `cortex-m-rt` >=v0.6.13 and `vcell` v0.1.x. Furthermore
5757
//! the "device" feature of `cortex-m-rt` must be enabled when the "rt" feature is enabled. The
5858
//! `Cargo.toml` of the device crate will look like this:
5959
//!
6060
//! ``` toml
6161
//! [dependencies]
62-
//! bare-metal = "0.2.0"
63-
//! cortex-m = "0.5.8"
62+
//! cortex-m = "0.7"
6463
//! vcell = "0.1.0"
6564
//!
6665
//! [dependencies.cortex-m-rt]
6766
//! optional = true
68-
//! version = "0.6.5"
67+
//! version = "0.6.13"
6968
//!
7069
//! [features]
7170
//! rt = ["cortex-m-rt/device"]

0 commit comments

Comments
 (0)