Skip to content

Commit 05482a8

Browse files
committed
add "rt" feature, and update the documentation
1 parent fb97b80 commit 05482a8

File tree

4 files changed

+128
-118
lines changed

4 files changed

+128
-118
lines 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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["arm", "cortex-m", "register", "map", "generator"]
88
license = "MIT OR Apache-2.0"
99
name = "svd2rust"
1010
repository = "https://github.com/japaric/svd2rust"
11-
version = "0.10.0"
11+
version = "0.11.0"
1212

1313
[dependencies]
1414
cast = "0.2.0"
@@ -19,3 +19,8 @@ inflections = "1.1.0"
1919
quote = "0.3.15"
2020
svd-parser = "0.5.1"
2121
syn = "0.11.9"
22+
23+
[[bin]]
24+
doc = false
25+
name = "svd2rust"
26+
path = "src/main.rs"

src/generate.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,23 @@ pub fn device(d: &Device, items: &mut Vec<Tokens>) -> Result<()> {
2323
);
2424
items.push(
2525
quote! {
26+
#![cfg_attr(feature = "rt", feature(asm))]
27+
#![cfg_attr(feature = "rt", feature(core_intrinsics))]
28+
#![cfg_attr(feature = "rt", feature(linkage))]
29+
#![cfg_attr(feature = "rt", feature(macro_reexport))]
30+
#![cfg_attr(feature = "rt", feature(naked_functions))]
31+
#![cfg_attr(feature = "rt", feature(used))]
2632
#![doc = #doc]
2733
#![deny(missing_docs)]
2834
#![deny(warnings)]
2935
#![allow(non_camel_case_types)]
30-
#![feature(asm)]
31-
#![feature(core_intrinsics)]
3236
#![feature(const_fn)]
33-
#![feature(linkage)]
34-
#![feature(naked_functions)]
35-
#![feature(used)]
3637
#![no_std]
3738

3839
extern crate cortex_m;
40+
#[macro_reexport(default_handler, exception)]
41+
#[cfg(feature = "rt")]
42+
extern crate cortex_m_rt;
3943
extern crate vcell;
4044

4145
use core::ops::Deref;
@@ -149,6 +153,7 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
149153
#(
150154
#[allow(non_snake_case)]
151155
#[allow(private_no_mangle_fns)]
156+
#[cfg(feature = "rt")]
152157
#[linkage = "weak"]
153158
#[naked]
154159
#[no_mangle]
@@ -160,10 +165,13 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
160165
}
161166
)*
162167

168+
#[allow(private_no_mangle_statics)]
169+
#[cfg(feature = "rt")]
170+
#[doc(hidden)]
163171
#[link_section = ".vector_table.interrupts"]
164172
#[no_mangle]
165173
#[used]
166-
static INTERRUPTS: [Option<extern "C" fn()>; #n] = [
174+
pub static INTERRUPTS: [Option<extern "C" fn()>; #n] = [
167175
#(#elements,)*
168176
];
169177

@@ -181,6 +189,7 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
181189
}
182190
}
183191

192+
#[cfg(feature = "rt")]
184193
#[macro_export]
185194
macro_rules! interrupt {
186195
($NAME:ident, $f:ident, local: {
@@ -232,7 +241,9 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
232241
if interrupts.len() > 0 {
233242
items.push(
234243
quote! {
235-
/// Interrupts
244+
pub use interrupt::Interrupt;
245+
246+
#[doc(hidden)]
236247
pub mod interrupt {
237248
#(#mod_items)*
238249
}

0 commit comments

Comments
 (0)