Skip to content

Commit 4a2fd6f

Browse files
committed
only re-export core peripherals available on all Cortex-M devices
1 parent 92067f7 commit 4a2fd6f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/generate.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
8686
::generate::interrupt(d, target, &d.peripherals, items);
8787

8888
const CORE_PERIPHERALS: &[&str] = &[
89+
"CBP",
8990
"CPUID",
9091
"DCB",
9192
"DWT",
@@ -106,13 +107,19 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
106107
pub use cortex_m::peripheral::Peripherals as CorePeripherals;
107108
});
108109

109-
for p in CORE_PERIPHERALS {
110-
let id = Ident::new(*p);
111-
112-
items.push(quote! {
113-
pub use cortex_m::peripheral::#id;
114-
});
115-
}
110+
// NOTE re-export only core peripherals available on *all* Cortex-M devices
111+
// (if we want to re-export all core peripherals available for the target then we are going
112+
// to need to replicate the `#[cfg]` stuff that cortex-m uses and that would require all
113+
// device crates to define the custom `#[cfg]`s that cortex-m uses in their build.rs ...)
114+
items.push(quote! {
115+
pub use cortex_m::peripheral::CPUID;
116+
pub use cortex_m::peripheral::DCB;
117+
pub use cortex_m::peripheral::DWT;
118+
pub use cortex_m::peripheral::MPU;
119+
pub use cortex_m::peripheral::NVIC;
120+
pub use cortex_m::peripheral::SCB;
121+
pub use cortex_m::peripheral::SYST;
122+
});
116123
}
117124

118125
for p in &d.peripherals {

0 commit comments

Comments
 (0)