-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of interrupt allocation #1063
Comments
I like the idea of runtime binding of interrupt handlers as suggested here: #1047 (comment) I had a brief look at our code and I think it won't add much more latency - if any - for the vectored interrupt handling (which I guess is the most used option) |
Fleshing out my ideas from #1047 (comment). I believe that we might want to remove the Let's use With the above in mind, we need changes to the current interrupt mechanism. The current mechanism uses linkage to bind the interrupt handlers, but we need to turn this into a runtime mechanism. The code inside the |
Basically, had a similar thing in mind (minus the type-state).
And in case of non-async we probably want to provide a function to register a user provided interrupt handler.
I also think so - I think we need to place |
FYI the reason I added the type-state is so we only implement certain traits in specific modes, for example, we don't want to implement the async traits if a driver is initialized in blocking mode. |
After some discussion, I think we're all on board with trying to explore the proposal above. We found four areas we'll need to investigate before we can commit to this design:
Extended goals, not critical to the initial design:
|
Thanks to @bjoernQ for investigating much of this! With the exploratory PR in #112, we can check off three of the four items in the list. The last side to explore is the user facing side, how we change the driver constructors and how users interact with interrupts. For now we are focusing on unifying the HAL. |
@MabezDev what is this blocked on? |
I wanted to start working on the real implementation of this after the next HAL release (I certainly can start behind the curtain earlier). Good thing is we don't need to have it in a big-bang |
The next steps are as follows: @bjoernQ will be taking care of DMA, which is another special case like GPIO. The next stage for the rest of the drivers needs to be designed. I've posted some ideas earlier in this thread, but this isn't a full solution, but it's pretty close I think. We can probably skip the interrupt as a resource bit for now, and keep interrupt enable outside of the driver (though we can move it in the driver for async mode). I probably won't get to it today, but I'll try and get a small-ish driver converted (maybe uart?) and see how it feels. Once we have a pattern to copy we can split the work up a bit. |
For some reason there were some peripherals listed in the task list that we do not currently support interrupts for, so I have removed those as they're irrelevant to this task. |
Working on the |
Working on TWAI now |
Working on debug-assist |
I'll look into SoftwareInterruptControl and friends next |
Once the remaining items in the task list have been completed, we should do a review to ensure that we have not missed any peripherals. While doing this, it may also be beneficial to determine which existing drivers have not implemented interrupt support, though that probably deserves a separate issue for tracking. |
At least there shouldn't be any usage of
Definitely another issue, agreed. I think there are also some drivers which can bind an interrupt handler now but it's almost impossible to really make use of that in user code. But that's probably another issue on its own then |
I'll take |
Working on rtc-wdt |
I think the changes are not required for MCPWM, just removed it from the list |
There are only two items remaining in our current task list which do not already have PRs opened:
We will need to review the code base in its current form and ensure that we have not missed anything, but I think we're pretty close to being done here. Thanks a bunch to everybody who has helped out with this already! |
Seems like LCD_CAM currently doesn't offer or use any interrupt functionality. I suggest to remove it from the list - whenever interrupt support is added it will follow the new way of handling interrupts EDIT: I removed it |
Looks like we're done here! I'm going to go ahead and close this issue, if we discover any other drivers which we've missed we can open issues on a per-case basis. Thanks again everybody for helping out with this! |
Currently when using the
async
(and some other) features, a number of interrupts are automatically bound to handlers.This can be problematic for various reasons. One such example is implementing the
embedded_hal_async::delay::DelayNs
trait, which when implemented forTIMG$n
/SYSTIMER
conflict with the Embassy time drivers. In other cases, users may want to define their own interrupt handlers for certain peripherals, while still using the default interrupt handlers defined via theasync
feature in the HAL. This is presently not possible.I'm not sure what the solution for this is yet. #1047 tried making the interrupt handlers overrideable, but we did not end up merging this; see the discussion in the PR for details. I would like to hear people's thoughts on potential solutions to this problem.
Progress:
#[interrupt]
in GPIO driver #1278Peripheral conversion
UsbSerialJtag
: async/blocking constructors, runtime interrupt binding support #1377The text was updated successfully, but these errors were encountered: