-
Notifications
You must be signed in to change notification settings - Fork 946
esp32c3 interrupt implementation #2170
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
the mpie must be set before mret. remove memory allocation from interrupt code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about this PR and how to implement interrupts correctly on the ESP32-C3.
I think it would actually make more sense to make the Interrupt
type be the 31 interrupt vectors. It would then work as follows:
- Code that wants to use an interrupt can do so using
interrupt.New
, for exampleinterrupt.New(5, func(interrupt.Interrupt) { ... })
. - It will have to manually map the interrupt source to the interrupt vector, for example
esp.INTERRUPT_CORE0.GPIO_INTERRUPT_PRO_MAP.Set(5)
. - The
handleInterrupt
logic now becomes a lot simpler. It can now directly callcallInterruptHandler
with the interrupt number frommcause
.
It is still possible to map multiple interrupt sources to a single interrupt vector: interrupt.New
can be used for multiple handlers on a single interrupt number. For example:
// configuring GPIO:
intr := interrupt.New(5, func(interrupt.Interrupt) {
status := esp.GPIO.STATUS.Get()
if status != 0 {
// handle GPIO interrupt
}
})
intr.Enable()
esp.INTERRUPT_CORE0.GPIO_INTERRUPT_PRO_MAP.Set(5)
// configuring UART:
intr := interrupt.New(5, func(i interrupt.Interrupt) {
flag := esp.UART0.INT_ST.Get()
if flag != 0 {
// handle UART interrupt
}
})
intr.Enable()
esp.INTERRUPT_CORE0.UART0_INTERRUPT_PRO_MAP.Set(5)
(These two don't need to be on the same interrupt vector, I'm only showing that it is possible).
What do you think?
I didn't know you can call |
@aykevl not sure if you get notification on my comments above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you for all the work!
CI is failing, but I think that's an unrelated issue. |
Oh now I see. You have made the PR against the espnet branch. Can you rebase it against the dev branch? |
I could, but don’t we need other changes you made like stdio, pico lib and FreeRTOS?
… On Oct 22, 2021, at 6:59 PM, Ayke ***@***.***> wrote:
Oh now I see. You have made the PR against the espnet branch. Can you rebase it against the dev branch?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#2170 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACI2FGP4NA36ES4CPIN3L3UIHUDVANCNFSM5F2XORKA>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Yes, but by merging this in the dev branch it will become available to everybody, not just those working from the espnet branch. That's why I also made a few other PRs like #2135, #2136, and #2143. In general I prefer working as much as possible directly from the dev branch for independent features. |
this is merged with PR #2200 |
@aykevl this is only interrupt implementation for esp32c3.
No exported APIs except enum values of
HandlerID
type to initialize chip's modules.Tested with pin src/examples/pininterrupt/pininterrupt.go (not checked in)