-
Notifications
You must be signed in to change notification settings - Fork 989
Implement pin interrupts #1094
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
Implement pin interrupts #1094
Conversation
@aykevl merge conflict needs resolution, please. |
@aykevl Here's something I noticed about SAMD21, so I'll report it.
Translated with www.DeepL.com/Translator (free version) |
435688c
to
7d94489
Compare
@deadprogram rebased.
Oops, thank you for catching that! I've updated the PR.
I don't think so. INTENSET already performs the
|
I made a mistake. |
I wrote the code for SAMD51J19A. https://github.com/sago35/tinygo/tree/interrupts-pins-samd51 I'm struggling with how to write the following parts.
|
@sago35 it would be easier to give feedback on an actual (work-in-progress) PR. Can you perhaps make one? |
7d94489
to
dacaf1c
Compare
Excellent progress on this! Now merging. |
This PR implements pin interrupts for Nordic devices and for SAM D21 devices.
I have kept the API very simple, so it is easy to generalize to many different microcontrollers. It is also possible to make it faster, but that would make the API also less flexible. Right now it will just read the callback from a global, which should be good enough for most purposes.
Something else that it doesn't implement (yet) is level interrupts (as opposed to edge interrupts). Level interrupts, while (probably) easier to implement in hardware, are harder to use in practice. The main advantage of level interrupts appears to be that some chips support them even in very low power states. For simplicity, I've just left them out in this version.
I have also implemented interrupts for AVR devices (Arduino Uno and Digispark), so that means 3 different chip families support this API. However, the code needs to be cleaned up a bit and I would like to clean up pin handling first (see #1093).
There are some features that I have not implemented, such as using one interrupt channel for multiple pins on the SAM D21. This would have complicated things so again, I've just left that out.