Skip to content

don't generate core peripherals if SVD is explicitly not Cortex M #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ pub fn device(d: &Device, items: &mut Vec<Tokens>) -> Result<()> {
},
);

let generate_core_peripherals = match d.cpu {
Some(ref cpu) => cpu.is_cortex_m(),
None => true, // assume has Cortex M peripherals by default
};

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

const CORE_PERIPHERALS: &'static [&'static str] = &[
Expand All @@ -57,18 +62,20 @@ pub fn device(d: &Device, items: &mut Vec<Tokens>) -> Result<()> {
"TPIU",
];

for p in CORE_PERIPHERALS {
let ty_ = Ident::new(p.to_sanitized_pascal_case());
let p = Ident::new(*p);
if generate_core_peripherals {
for p in CORE_PERIPHERALS {
let ty_ = Ident::new(p.to_sanitized_pascal_case());
let p = Ident::new(*p);

items.push(quote! {
pub use cortex_m::peripheral::#ty_ as #p;
pub use cortex_m::peripheral::#p;
});
items.push(quote! {
pub use cortex_m::peripheral::#ty_ as #p;
pub use cortex_m::peripheral::#p;
});
}
}

for p in &d.peripherals {
if CORE_PERIPHERALS.contains(&&*p.name.to_uppercase()) {
if generate_core_peripherals && CORE_PERIPHERALS.contains(&&*p.name.to_uppercase()) {
// Core peripherals are handled above
continue;
}
Expand Down