esp-hal icon indicating copy to clipboard operation
esp-hal copied to clipboard

Improve easy-of-use for `#[interrupt]` macro on ESP32-C3

Open bjoernQ opened this issue 2 years ago • 1 comments

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

bjoernQ avatar Sep 27 '22 12:09 bjoernQ

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.

MabezDev avatar Sep 30 '22 13:09 MabezDev

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

dimpolo avatar Dec 07 '22 12:12 dimpolo

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?

MabezDev avatar Dec 22 '22 12:12 MabezDev