aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/pre_init.rs
diff options
context:
space:
mode:
authorGravatar bors[bot] <26634292+bors[bot]@users.noreply.github.com> 2020-10-23 22:03:08 +0000
committerGravatar GitHub <noreply@github.com> 2020-10-23 22:03:08 +0000
commit4f4c95be40019f6656d4eee549932ee811a40116 (patch)
tree092cede9ccdaa9b7a4381f7c369db79583d7eb8b /macros/src/codegen/pre_init.rs
parentbbcae14e37c5f4ab5701b2a688bee52bfa7aaa1b (diff)
parent1c244a995d54332649c1643aa0a3178f169406e4 (diff)
downloadrtic-4f4c95be40019f6656d4eee549932ee811a40116.tar.gz
rtic-4f4c95be40019f6656d4eee549932ee811a40116.tar.zst
rtic-4f4c95be40019f6656d4eee549932ee811a40116.zip
Merge #400
400: codegen and examples r=AfoHT a=perlindgren just a test Co-authored-by: Per Lindgren <per.lindgren@ltu.se>
Diffstat (limited to 'macros/src/codegen/pre_init.rs')
-rw-r--r--macros/src/codegen/pre_init.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs
index 17c9c2f4..969de84a 100644
--- a/macros/src/codegen/pre_init.rs
+++ b/macros/src/codegen/pre_init.rs
@@ -26,22 +26,20 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
let mut core: rtic::export::Peripherals = rtic::export::Peripherals::steal().into();
));
- let device = extra.device;
+ let device = &extra.device;
let nvic_prio_bits = quote!(#device::NVIC_PRIO_BITS);
+ let interrupt_ids = analysis.interrupts.iter().map(|(p, (id, _))| (p, id));
+
// Unmask interrupts and set their priorities
- for (&priority, name) in analysis
- .interrupts
- .iter()
- .chain(app.hardware_tasks.values().flat_map(|task| {
- if !util::is_exception(&task.args.binds) {
- Some((&task.args.priority, &task.args.binds))
- } else {
- // We do exceptions in another pass
- None
- }
- }))
- {
+ for (&priority, name) in interrupt_ids.chain(app.hardware_tasks.values().flat_map(|task| {
+ if !util::is_exception(&task.args.binds) {
+ Some((&task.args.priority, &task.args.binds))
+ } else {
+ // We do exceptions in another pass
+ None
+ }
+ })) {
// Compile time assert that this priority is supported by the device
stmts.push(quote!(let _ = [(); ((1 << #nvic_prio_bits) - #priority as usize)];));