-
Notifications
You must be signed in to change notification settings - Fork 1.3k
functioning samd deep sleep ('alarm.time' & 'alarm.pin') #5425
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
Conversation
cherry-picked original hierophect commit and merged with my samd `alarm` (deep sleep) work
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.
Thanks for the PR!
I think you'll want to dig into the hard fault status register (HFSR) which could give you a better clue to the fault. This is a good reference for further hard fault debugging: https://interrupt.memfault.com/blog/cortex-m-fault-debug
Don't delete: ports/espressif/certificates/nina-fw
@tannewt thank you for that link! Very helpful. I'll dive into this next.
This occurred when I cherry-picked Lucian's commit. How do I restore it (submodule directory)? |
I think you'll want to rebase and fix the commit that originally removes it. |
1 similar comment
I think you'll want to rebase and fix the commit that originally removes it. |
Co-authored-by: Scott Shawcroft <[email protected]>
Resolving circuipthon.pot conflicts with new samd alarm module
Update
Overall it still has some quirks but it's certainly functioning. |
More updates
Question: I make individual time/pin callbacks from port.c as shown here. This requires a couple extra imports in port.c: #include "shared-bindings/alarm/time/TimeAlarm.h"
#include "shared-bindings/alarm/pin/PinAlarm.h" @tannewt Would it be more memory efficient to call a new function from |
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 think calling the callbacks directly is fine because port.c is still relatively private piece of code. I don't think there is much difference from the compiler's perspective if you added a wrapper function.
Please get the CI passing before I review again.
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.
One more question and then it should be good. Thanks for your persistence.
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.
Thank you! Let's get this in.
This builds upon #5048, to achieve a preliminary-but-functional
alarm
module for the SAMD port.1This partially addresses #4837 via the following features:
alarm.time
BACKUP
sleepmode (lowest power consumption).RTC->COMP[1]
and a callback in port.c'sRTC_Handler
main.py -> fake deep sleep -> soft reset
continuously without issue. HOWEVER, the same build & code on a PyCubed board always crashes intoHardFault_Handler
on the 4th iteration. Always.HardFault_Handler
doesn't occur when built withDEBUG=1
alarm.pin
TAMPER
function to wake us fromBACKUP
sleepmode.TAMPCTRL.bit.IN2ACT
)TAMPER
interrupt as true deep sleep, but with a callback in port.c'sRTC_Handler
to catch fake sleepHardFault_Handler
.EIC
to wake from sleepmodeSTANDBY
time.sleep()
. So we may want to disable it for the time being to not confuse folks.alarm.wake_alarm
rtc_init
before RTC reset.alarm.exit_and_deep_sleep_until_alarms
original post
alarm.time
BACKUP
sleepmode (lowest power consumption).port_interrupt_after_ticks
call during TimeAlarm setup and checks toport_idle_until_interrupt
during "pretending to deep sleep".main.py -> fake deep sleep -> soft reset
continuously without issue. HOWEVER, the same build & code on a PyCubed board always crashes intoHardFault_Handler
on the 4th iteration. Always.HardFault_Handler
doesn't occur when built withDEBUG=1
alarm.pin
TAMPER
function to wake us fromBACKUP
sleepmode.TAMPCTRL.bit.IN2ACT
)EIC
to wake from sleepmodeSTANDBY
time.sleep()
. So we may want to disable it for the time being to not confuse folks.alarm.wake_alarm
BACKUP
but I'm unable to discern between a TimeAlarm and PinAlarm cause.RTC->MODE0.INTENSET
register is getting cleared during reset, so I'm unable to rule out ifTAMP
interrupt woke us.Footnotes
@hierophect I ended up just cherry-picking https://github.com/hierophect/circuitpython/commit/3f92ca82f09901d0122141be3dc250f3c8087659 in order to incorporate those commits. Let me know if this is sufficient. ↩
Only the following pins can be configured for tamper input
IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01
There's alsoOUT:PB01
but haven't checked if that can generate an interrupt to wake. ↩ ↩2