forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Deep Sleep support on CPY #3467
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
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
39d0130
Initial Sleep Support
microdev1 9579b78
Update soft reboot message
microdev1 dfb3943
Get io wake working
microdev1 a0789f4
Add function to get time elapsed during sleep
microdev1 ec2111d
Add function to disable alarm
microdev1 97101e9
Renamed alarm modules
microdev1 2a45ae3
restructure alarm modules
microdev1 81852ba
Fix build error
microdev1 82ff412
Add alarm_touch module
microdev1 9321434
Add description of alarm modules
microdev1 7c5783f
Add check for invalid io, function to disable all alarms
microdev1 5f960b7
Merge branch 'main' into sleepCPY
microdev1 7796f85
Implement sleep on code.py exit
microdev1 67f62d7
Resolve merge conflict
microdev1 46ce440
Update translation
microdev1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-09-29 20:14-0500\n" | ||
"POT-Creation-Date: 2020-10-07 09:55+0530\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -17,6 +17,13 @@ msgstr "" | |
"Content-Type: text/plain; charset=CHARSET\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
#: main.c | ||
msgid "" | ||
"\n" | ||
"\n" | ||
"------ soft reboot ------\n" | ||
msgstr "" | ||
|
||
#: main.c | ||
msgid "" | ||
"\n" | ||
|
@@ -948,6 +955,10 @@ msgstr "" | |
msgid "I2SOut not available" | ||
msgstr "" | ||
|
||
#: ports/esp32s2/common-hal/alarm_io/__init__.c | ||
msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" | ||
msgstr "" | ||
|
||
#: shared-bindings/aesio/aes.c | ||
#, c-format | ||
msgid "IV must be %d bytes long" | ||
|
@@ -2743,6 +2754,10 @@ msgstr "" | |
msgid "invalid syntax for number" | ||
msgstr "" | ||
|
||
#: ports/esp32s2/common-hal/alarm_io/__init__.c | ||
msgid "io must be rtc io" | ||
msgstr "" | ||
|
||
#: py/objtype.c | ||
msgid "issubclass() arg 1 must be a class" | ||
msgstr "" | ||
|
@@ -3144,13 +3159,15 @@ msgstr "" | |
msgid "pow() with 3 arguments requires integers" | ||
msgstr "" | ||
|
||
#: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h | ||
#: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h | ||
#: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h | ||
#: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h | ||
#: ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.h | ||
#: ports/esp32s2/boards/microdev_micro_s2/mpconfigboard.h | ||
#: ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.h | ||
#: ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h | ||
#: ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h | ||
msgid "pressing boot button at start up.\n" | ||
msgstr "" | ||
|
||
|
@@ -3247,7 +3264,7 @@ msgstr "" | |
msgid "size is defined for ndarrays only" | ||
msgstr "" | ||
|
||
#: shared-bindings/time/__init__.c | ||
#: shared-bindings/alarm_time/__init__.c shared-bindings/time/__init__.c | ||
msgid "sleep length must be non-negative" | ||
msgstr "" | ||
|
||
|
@@ -3263,10 +3280,6 @@ msgstr "" | |
msgid "small int overflow" | ||
msgstr "" | ||
|
||
#: main.c | ||
msgid "soft reboot\n" | ||
msgstr "" | ||
|
||
#: extmod/ulab/code/numerical/numerical.c | ||
msgid "sort argument must be an ndarray" | ||
msgstr "" | ||
|
@@ -3347,6 +3360,10 @@ msgstr "" | |
msgid "threshold must be in the range 0-65536" | ||
msgstr "" | ||
|
||
#: ports/esp32s2/common-hal/alarm_time/__init__.c | ||
msgid "time out of range" | ||
msgstr "" | ||
|
||
#: shared-bindings/time/__init__.c | ||
msgid "time.struct_time() takes a 9-sequence" | ||
msgstr "" | ||
|
@@ -3392,6 +3409,10 @@ msgstr "" | |
msgid "trapz is defined for 1D arrays of equal length" | ||
msgstr "" | ||
|
||
#: ports/esp32s2/common-hal/alarm_io/__init__.c | ||
msgid "trigger level must be 0 or 1" | ||
msgstr "" | ||
|
||
#: extmod/ulab/code/linalg/linalg.c | ||
msgid "tuple index out of range" | ||
msgstr "" | ||
|
@@ -3520,6 +3541,10 @@ msgstr "" | |
msgid "vectors must have same lengths" | ||
msgstr "" | ||
|
||
#: ports/esp32s2/common-hal/alarm_io/__init__.c | ||
msgid "wakeup conflict" | ||
msgstr "" | ||
|
||
#: shared-bindings/watchdog/WatchDogTimer.c | ||
msgid "watchdog timeout must be greater than 0" | ||
msgstr "" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* This file is part of the MicroPython project, http://micropython.org/ | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries | ||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#include "shared-bindings/alarm/__init__.h" | ||
#include "shared-bindings/alarm_io/__init__.h" | ||
#include "shared-bindings/alarm_time/__init__.h" | ||
|
||
#include "esp_sleep.h" | ||
|
||
void common_hal_alarm_disable_all(void) { | ||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); | ||
} | ||
|
||
mp_obj_t common_hal_alarm_get_wake_alarm(void) { | ||
switch (esp_sleep_get_wakeup_cause()) { | ||
case ESP_SLEEP_WAKEUP_TIMER: ; | ||
//Wake up from timer. | ||
alarm_time_obj_t *timer = m_new_obj(alarm_time_obj_t); | ||
timer->base.type = &alarm_time_type; | ||
return timer; | ||
case ESP_SLEEP_WAKEUP_EXT0: ; | ||
//Wake up from GPIO | ||
alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); | ||
ext0->base.type = &alarm_io_type; | ||
return ext0; | ||
case ESP_SLEEP_WAKEUP_TOUCHPAD: | ||
//TODO: implement TouchIO | ||
//Wake up from touch on pad, esp_sleep_get_touchpad_wakeup_status() | ||
break; | ||
case ESP_SLEEP_WAKEUP_UNDEFINED: | ||
default: | ||
//Not a deep sleep reset | ||
break; | ||
} | ||
return mp_const_none; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "shared-bindings/alarm_io/__init__.h" | ||
|
||
#include "esp_sleep.h" | ||
#include "driver/rtc_io.h" | ||
|
||
mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { | ||
if (!rtc_gpio_is_valid_gpio(self_in->gpio)) { | ||
mp_raise_ValueError(translate("io must be rtc io")); | ||
} | ||
|
||
if (self_in->pull && !self_in->level) { | ||
for (uint8_t i = 0; i<=4; i+=2) { | ||
if (self_in->gpio == i) { | ||
mp_raise_ValueError(translate("IOs 0, 2 & 4 do not support internal pullup in sleep")); | ||
} | ||
} | ||
} | ||
|
||
switch(esp_sleep_enable_ext0_wakeup(self_in->gpio, self_in->level)) { | ||
case ESP_ERR_INVALID_ARG: | ||
mp_raise_ValueError(translate("trigger level must be 0 or 1")); | ||
case ESP_ERR_INVALID_STATE: | ||
mp_raise_RuntimeError(translate("wakeup conflict")); | ||
default: | ||
break; | ||
} | ||
|
||
if (self_in->pull) { (self_in->level) ? rtc_gpio_pulldown_en(self_in->gpio) : rtc_gpio_pullup_en(self_in->gpio); } | ||
|
||
return self_in; | ||
} | ||
|
||
void common_hal_alarm_io_disable (void) { | ||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0 | ESP_SLEEP_WAKEUP_EXT1); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "esp_sleep.h" | ||
|
||
#include "shared-bindings/alarm_time/__init__.h" | ||
|
||
void common_hal_alarm_time_duration (uint32_t ms) { | ||
if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) { | ||
mp_raise_ValueError(translate("time out of range")); | ||
} | ||
} | ||
|
||
void common_hal_alarm_time_disable (void) { | ||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "esp_sleep.h" | ||
|
||
#include "shared-bindings/alarm_touch/__init__.h" | ||
|
||
void common_hal_alarm_touch_disable (void) { | ||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TOUCHPAD); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.