Skip to content
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

RP2040: add Alarm module #4816

Merged
merged 8 commits into from
Jun 24, 2021
Merged

RP2040: add Alarm module #4816

merged 8 commits into from
Jun 24, 2021

Conversation

hierophect
Copy link
Collaborator

This PR adds the Alarm module for the raspberrypi port, with the TimeAlarm and PinAlarm alarm types (the RP2040 does not have a touch module). Tested on the Raspberry Pi Pico.

Adds light and deep sleep functionality for the TimeAlarm and PinAlarm
alarm categories. Adds board deinit for all platforms.
@hierophect hierophect added power rp2 Raspberry Pi RP2 Micros labels May 27, 2021
@hierophect hierophect requested a review from dhalbert May 27, 2021 22:38
@hierophect
Copy link
Collaborator Author

One complication of this implementation was the RP2040's inability to wake off the RTC when in "dormant" mode, unless the RTC is supplied with an external clock input from a GPIO pin while sleeping. There are a couple options for how to approach this, and I'm not sure which is the best fit for Circuitpython:

  1. Throw a ValueError when attempting to use a TimeAlarm with deep sleep (current implementation)
  2. Allow RTC Alarms, but trust the user to supply a clock source. This isn't very Circuitpython-y, but could maybe be augmented by extra checks or something?
  3. Defer to the lower tier of sleep when a TimeAlarm is included in the alarm list, but gate the clocks very severely. This avoids any user-facing changes but can only obtain a minimum power draw of ~5mA, so it isn't very good deep sleep performance. It might seem like a mysterious degradation in battery life from the user's perspective when compared to only using PinAlarms.

@dhalbert
Copy link
Collaborator

3. It might seem like a mysterious degradation in battery life from the user's perspective when compared to only using PinAlarms.

On other boards the opposite is true (though not 5mA, but 1.5mA, say): PinAlarms are more expensive in terms of power than TimeAlarms. So I'm not sure this is terrible, though it is disappointing.

@dhalbert
Copy link
Collaborator

dhalbert commented Jun 1, 2021

Hi - some build issues due to board_deinit() not found.

@hierophect
Copy link
Collaborator Author

@dhalbert think you could take another look at this this week?

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed this was ready for re-review.

ports/raspberrypi/common-hal/alarm/SleepMemory.c Outdated Show resolved Hide resolved
ports/raspberrypi/common-hal/alarm/SleepMemory.c Outdated Show resolved Hide resolved
ports/raspberrypi/common-hal/alarm/SleepMemory.h Outdated Show resolved Hide resolved
ports/raspberrypi/common-hal/alarm/SleepMemory.h Outdated Show resolved Hide resolved
@hierophect hierophect requested a review from dhalbert June 20, 2021 22:09
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience. Let's go with this for now, and we can think about improvements later.

@dhalbert dhalbert merged commit 836db4e into adafruit:main Jun 24, 2021
@hierophect hierophect deleted the rp2040-alarms branch June 24, 2021 17:57
@hierophect hierophect mentioned this pull request Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
power rp2 Raspberry Pi RP2 Micros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants