riscv-rust / e310x-hal

Implementation of the `embedded-hal` traits for E310x microcontrollers
17 stars 18 forks source link

How to assign interrupt handlers to GPIOs #48

Closed romancardenas closed 1 year ago

romancardenas commented 1 year ago

I've been studying the riscv-rt, e310x and e310x-hal crates for a while, and I'm currently exploring different interruption modes. As far as I know, riscv-rt leaves you the MachineExternal function for dealing with all the machine external interrupts. The e310x crate allows you to define specific interrupt handlers for each interrupt source (e.g., a GPIO) with the interrupt macro. However, I don't see a clear connection between MachineExternal and these functions (I mean, which part of the code does the trick to identify the source and call the proper interrupt handler if exists).

I managed to catch GPIO interruptions by defining a common MachineExternal function and analyzing the interrupt source, but I wonder if it's possible to define custom handlers for a given GPIO using the interrupt macro and forget about the MachineExternal common handler.

romancardenas commented 1 year ago

As part of this issue, @steewbsd and I have been working on an optional feature that allow users to use a vectored interrupt handling mechanism for external interrupts. We opened a pull request with a proof of concept in PR #49