8000 zephyr: Allow pins to support both hard and soft interrupts. by danicampora · Pull Request #16916 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

zephyr: Allow pins to support both hard and soft interrupts. #16916

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

Closed

Conversation

danicampora
Copy link
Member

The Pin irq method has an option hard parameter that us used to select if the IRQ callback will be called from interrupt context or not. At the moment in the Zephyr port this parameter value is saved but nothing is done with it and all pin interrupts are treated as hard. This PR presents a small change that allows to also handle interrupts in soft mode where the interrupt callback is called out of interrupt context allowing to execute bigger and less time sensitive routines.

Signed-off-by: Daniel Campora <danicampora@gmail.com>
@jonnor
Copy link
Contributor
jonnor commented Mar 12, 2025

This looks quite useful, thanks! And the change seems to be rather simple at first glance. Have you tested this on hardware?

@jonnor jonnor requested a review from dpgeorge March 12, 2025 22:31
@danicampora
Copy link
Member Author

@jonnor yes, tested it on nRF52840 and nRF5340

@projectgus
Copy link
Contributor

@danicampora Thanks for contributing this fix. I want to double check, are you sure that Zephyr doesn't already support both hard and soft interrupts? Take a look at the implementation of mp_irq_handler() in shared/runtime/mpirq.c.

If soft interrupts are already working, I think that it probably is still worth updating the comment in gpio_callback_handler that implies this won't be the case. (Does it also matter that soft irqs briefly switch the stack check and then switch it back? Maybe, although it seems like a pretty lightweight operation so probably fine.)

@danicampora
Copy link
Member Author

@projectgus yes you are right, they are already working, not sure how I missed that. Thanks for pointing it out.

@danicampora danicampora closed this Apr 8, 2025
@projectgus
Copy link
Contributor

they are already working, not sure how I missed that.

The comment is written in a way that makes it sound like all interrupts are hard IRQs. I'll submit a quick PR to update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0