Skip to content

Commit e5bcf1f

Browse files
committed
Implement new InterruptNumber trait from next cortex-m release
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]>
1 parent 29129c0 commit e5bcf1f

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

ci/script.sh

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,13 @@ 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 = { git = "https://github.com/rust-embedded/cortex-m.git" }' >> $td/Cargo.toml
7372
echo 'vcell = "0.1.0"' >> $td/Cargo.toml
7473
echo '[profile.dev]' >> $td/Cargo.toml
7574
echo 'incremental = false' >> $td/Cargo.toml
7675

7776
case $VENDOR in
7877
Atmel)
79-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
80-
echo 'version = "0.2.0"' >> $td/Cargo.toml
81-
8278
# BAD-SVD missing resetValue
8379
# test_svd AT91SAM9CN11
8480
# test_svd AT91SAM9CN12
@@ -162,9 +158,6 @@ main() {
162158
;;
163159

164160
Freescale)
165-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
166-
echo 'version = "0.2.0"' >> $td/Cargo.toml
167-
168161
# BAD-SVD bad enumeratedValue value
169162
# test_svd MKV56F20
170163
# test_svd MKV56F22
@@ -313,9 +306,6 @@ main() {
313306
;;
314307

315308
Fujitsu)
316-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
317-
echo 'version = "0.2.0"' >> $td/Cargo.toml
318-
319309
# OK
320310
test_svd MB9AF10xN
321311
test_svd MB9AF10xR
@@ -420,19 +410,13 @@ main() {
420410
;;
421411

422412
Holtek)
423-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
424-
echo 'version = "0.2.0"' >> $td/Cargo.toml
425-
426413
# OK
427414
test_svd ht32f125x
428415
test_svd ht32f175x
429416
test_svd ht32f275x
430417
;;
431418

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

@@ -441,18 +425,12 @@ main() {
441425
;;
442426

443427
Nuvoton)
444-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
445-
echo 'version = "0.2.0"' >> $td/Cargo.toml
446-
447428
# OK
448429
test_svd M051_Series
449430
test_svd NUC100_Series
450431
;;
451432

452433
NXP)
453-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
454-
echo 'version = "0.2.0"' >> $td/Cargo.toml
455-
456434
test_svd MK22F25612
457435
test_svd MKW41Z4
458436

@@ -517,9 +495,6 @@ main() {
517495
;;
518496

519497
SiliconLabs)
520-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
521-
echo 'version = "0.2.0"' >> $td/Cargo.toml
522-
523498
# #99 regression tests
524499
test_svd SIM3C1x4_SVD
525500
test_svd SIM3C1x6_SVD
@@ -536,9 +511,6 @@ main() {
536511
;;
537512

538513
Spansion)
539-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
540-
echo 'version = "0.2.0"' >> $td/Cargo.toml
541-
542514
# OK
543515
test_svd MB9AF12xK
544516
test_svd MB9AF12xL
@@ -634,9 +606,6 @@ main() {
634606
;;
635607

636608
STMicro)
637-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
638-
echo 'version = "0.2.0"' >> $td/Cargo.toml
639-
640609
# OK
641610
test_svd STM32F030
642611
test_svd STM32F031x
@@ -676,9 +645,6 @@ main() {
676645
;;
677646

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

ci/svd2rust-regress/src/svd_test.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ 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] =
11+
&["cortex-m = { git = \"https://github.com/rust-embedded/cortex-m.git\" }"];
1112
const CRATES_RISCV: &[&str] = &["riscv = \"0.5.0\"", "riscv-rt = \"0.6.0\""];
1213
const CRATES_XTENSALX6: &[&str] = &["xtensa-lx6-rt = \"0.2.0\"", "xtensa-lx6 = \"0.1.0\""];
1314
const PROFILE_ALL: &[&str] = &["[profile.dev]", "incremental = false"];
14-
const FEATURES_ALL: &[&str] = &["[features]"];
15+
const FEATURES_ALL: &[&str] = &["[features]", "rt = []", "default = [\"rt\"]"];
1516

1617
fn path_helper(input: &[&str]) -> PathBuf {
1718
input.iter().collect()

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
}

0 commit comments

Comments
 (0)