esp-hal
esp-hal copied to clipboard
Improve easy-of-use for `#[interrupt]` macro on ESP32-C3
The macro needs to reference the TrapFrame ( https://github.com/esp-rs/esp-hal/blob/7889a992d7efcbbba0a5c7ef679694877f30380e/esp-hal-procmacros/src/lib.rs#L224 )
This requires importing something like use esp32c3_hal::interrupt;
in the root
Maybe we can come up with a better solution which doesn't require that import
Yeah, I hate that part, it's super annoying. For context, this "check" is here to make sure a given interrupt actually exists. Hopefully we can find a better way to do this check.
Same thing applies to this line requiring pac
to be in scope:
https://github.com/esp-rs/esp-hal/blob/4ab05e89235e620287a6c3b24486c0b8c2c05a28/esp-hal-procmacros/src/lib.rs#L202
I don't think there is a way around having to import the TrapFrame, because its part of the public API of the function. Thankfully, because it's public it's easy to spot that it needs to be imported.
Same thing applies to this line requiring pac to be in scope:
I've been looking at improving this, I don't think there is an easy way to check, without doing strange things like having const
to_string
methods on each of the interrupt enums and comparing the to string with the name of the interrupt handler.
I'm thinking about removing the check entirely, and instead adding a log statement inside each hal's extern "C" fn EspDefaultHandler(_interrupt: peripherals::Interrupt) {}
saying "Unhandled Interrupt : X". Thoughts?