From 70c75d8b79a97c967feb84aedd31b0b94e2ae86f Mon Sep 17 00:00:00 2001 From: Wouter Geraedts Date: Wed, 10 Apr 2024 15:31:03 +0200 Subject: [PATCH] Use explicit list of external interrupts which can be used by RTIC --- rtic-macros/src/codegen/bindings/esp32c6.rs | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rtic-macros/src/codegen/bindings/esp32c6.rs b/rtic-macros/src/codegen/bindings/esp32c6.rs index 28984db8ec..65ea384884 100644 --- a/rtic-macros/src/codegen/bindings/esp32c6.rs +++ b/rtic-macros/src/codegen/bindings/esp32c6.rs @@ -13,6 +13,12 @@ mod esp32c6 { use std::collections::HashSet; use syn::{parse, Attribute, Ident}; + // Section 1.6.2 technical reference manual specifies which interrupts can be configured. + const EXTERNAL_INTERRUPTS: [u8; 28] = [ + 1, 2, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, + ]; + #[allow(clippy::too_many_arguments)] pub fn impl_mutex( _app: &App, @@ -82,16 +88,15 @@ mod esp32c6 { } pub fn pre_init_enable_interrupts(app: &App, analysis: &CodegenAnalysis) -> Vec { let mut stmts = vec![]; - let mut curr_cpu_id: u8 = 1; //cpu interrupt id 0 is reserved let rt_err = util::rt_err_ident(); let max_prio: usize = 15; //unfortunately this is not part of pac, but we know that max prio is 15. let interrupt_ids = analysis.interrupts.iter().map(|(p, (id, _))| (p, id)); // Unmask interrupts and set their priorities - for (&priority, name) in interrupt_ids.chain( + for ((&priority, name), curr_cpu_id) in interrupt_ids.chain( app.hardware_tasks .values() .filter_map(|task| Some((&task.args.priority, &task.args.binds))), - ) { + ).zip(EXTERNAL_INTERRUPTS) { let es = format!( "Maximum priority used by interrupt vector '{name}' is more than supported by hardware" ); @@ -106,7 +111,6 @@ mod esp32c6 { #curr_cpu_id, ); )); - curr_cpu_id += 1; } stmts } @@ -224,26 +228,22 @@ mod esp32c6 { dispatcher_name: Ident, ) -> Vec { let mut stmts = vec![]; - let mut curr_cpu_id = 1; - //let mut ret = ""; let interrupt_ids = analysis.interrupts.iter().map(|(p, (id, _))| (p, id)); - for (_, name) in interrupt_ids.chain( + for ((_, name), curr_cpu_id) in interrupt_ids.chain( app.hardware_tasks .values() .filter_map(|task| Some((&task.args.priority, &task.args.binds))), - ) { + ).zip(EXTERNAL_INTERRUPTS) { if *name == dispatcher_name { let ret = &("cpu_int_".to_owned() + &curr_cpu_id.to_string() + "_handler"); stmts.push(quote!(#[export_name = #ret])); } - curr_cpu_id += 1; } stmts } -pub fn extra_modules(_app: &App, _analysis: &SyntaxAnalysis) -> Vec { - vec![] + pub fn extra_modules(_app: &App, _analysis: &SyntaxAnalysis) -> Vec { + vec![] + } } -} -