-
Notifications
You must be signed in to change notification settings - Fork 195
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
Make HAL defined interrupt handlers overridable #1047
Conversation
I think this looks fine in general, thanks for taking a swing at it. One nitpick, not a huge fan of the name I will take a closer look at the changes and do some testing in a bit, let me know your feelings on the renaming (we don't need to change it, after all). |
Sure - |
Yeah probably outside the scope of this PR but I was thinking we can probably do something like this. At least for now, as you mentioned the comment should hopefully discourage use. |
I'm a bit worried about silently breaking async code by defining an interrupt, at least with the current mechanism it stops you from shooting yourself in the foot. I think at the very least we need to make the interrupt code for handling async public so that users can call it too in their own handlers. Long term I think we might move away from using linkage to resolve interrupt handlers and instead move to something at runtime. At the same time, we can start treating interrupts as a resource and take them in peripheral constructors etc, this solves this issue quite neatly, as well as the forgetting to enable the interrupt problem we also have. |
Yes, probably good to allow users to call the interrupt handler from their own handlers if needed
Agreed - might give some performance penalties but it's probably a non-issue in most cases and when low-latency interrupts are needed, already |
Ok after thinking about this I'm about to close this PR: I don't think that having your own interrupt handler but wanting to use the async feature of that driver is a real use case? If that assumption is true, then having a feature for each of the async drivers (e.g. That way we would keep the compile time (link time) safety - if the user doesn't activate e.g. Probably it wouldn't be needed to check every combination of these features in CI - we could continue to check There is a limit of 300 features per crate on crates.io but I don't think we'll get close to that (even if we would add more per-driver features) |
Fixes #856
When using the
async
feature the HAL implements interrupt handlers for various peripherals.It was not possible to override them in user code (and not using the async feature of that driver)
This makes all the handlers implemented by the HAL weak so user code can override them.
If the user uses the async feature of a peripheral AND provides an alternative implementation of the interrupt handler it won't work. We cannot detect that at compile time but we could check it at runtime. I haven't implemented that - we can see if this ever becomes a real problem and do it then when needed.
Drawback might be that we need to maintain the
weak_isrs.x
file when adding a new HAL defined interrupt handler implementation but on the other hand forgetting that will become obvious very quicklyAlternatives to this