Skip to content

Commit 1c6e72f

Browse files
committed
don't generate an API for core peripherals
instead re-export the cortex-m crate's API
1 parent 637ed01 commit 1c6e72f

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Changed
11+
12+
- [breaking-change]. svd2rust no longer generates an API for core peripherals
13+
like NVIC. Instead, it just re-exports the cortex-m crate's API.
14+
1015
## [v0.6.2] - 2017-04-23
1116

1217
### Changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "register", "map", "generator"]
77
license = "MIT OR Apache-2.0"
88
name = "svd2rust"
99
repository = "https://github.com/japaric/svd2rust"
10-
version = "0.6.2"
10+
version = "0.7.0"
1111

1212
[dependencies]
1313
cast = "0.2.0"

src/generate.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,36 @@ pub fn device(d: &Device, items: &mut Vec<Tokens>) -> Result<()> {
3838

3939
::generate::interrupt(&d.peripherals, items);
4040

41+
const CORE_PERIPHERALS: &'static [&'static str] = &[
42+
"CPUID",
43+
"DCB",
44+
"DWT",
45+
"FPB",
46+
"FPU",
47+
"ITM",
48+
"MPU",
49+
"NVIC",
50+
"SCB",
51+
"SYST",
52+
"TPIU",
53+
];
54+
55+
for p in CORE_PERIPHERALS {
56+
let ty_ = Ident::new(p.to_sanitized_pascal_case());
57+
let p = Ident::new(*p);
58+
59+
items.push(quote! {
60+
pub use cortex_m::peripheral::#ty_;
61+
pub use cortex_m::peripheral::#p;
62+
});
63+
}
64+
4165
for p in &d.peripherals {
66+
if CORE_PERIPHERALS.contains(&&*p.name.to_uppercase()) {
67+
// Core peripherals are handled above
68+
continue;
69+
}
70+
4271
::generate::peripheral(p, items, &d.defaults)?;
4372
}
4473

0 commit comments

Comments
 (0)