Robert Hammelrath 2024-04-04 07:10:14 +08:00 zatwierdzone przez GitHub
commit e59884c2be
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 18 dodań i 11 usunięć

Wyświetl plik

@ -44,6 +44,8 @@
#include CPU_HEADER_H
#define MIMXRT_DEEPSLEEP_MIN (1)
#if defined(MICROPY_HW_LED1_PIN)
#define MICROPY_PY_MACHINE_LED_ENTRY { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&machine_led_type) },
#else
@ -129,14 +131,15 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
if (n_args != 0) {
mp_int_t seconds = mp_obj_get_int(args[0]) / 1000;
if (seconds > 0) {
machine_rtc_alarm_helper(seconds, false);
#ifdef MIMXRT117x_SERIES
GPC_CM_EnableIrqWakeup(GPC_CPU_MODE_CTRL_0, SNVS_HP_NON_TZ_IRQn, true);
#else
GPC_EnableIRQ(GPC, SNVS_HP_WRAPPER_IRQn);
#endif
if (seconds < MIMXRT_DEEPSLEEP_MIN) {
seconds = MIMXRT_DEEPSLEEP_MIN;
}
machine_rtc_alarm_helper(seconds, false);
#ifdef MIMXRT117x_SERIES
GPC_CM_EnableIrqWakeup(GPC_CPU_MODE_CTRL_0, SNVS_HP_NON_TZ_IRQn, true);
#else
GPC_EnableIRQ(GPC, SNVS_HP_WRAPPER_IRQn);
#endif
}
#if defined(MIMXRT117x_SERIES)

Wyświetl plik

@ -46,6 +46,7 @@
#define RP2_RESET_PWRON (1)
#define RP2_RESET_WDT (3)
#define RP2_LIGHTSLEEP_MIN (1)
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) }, \
@ -111,9 +112,9 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
if (n_args == 1) {
delay_ms = mp_obj_get_int(args[0]);
if (delay_ms <= 1) {
// Sleep is too small, just use standard delay.
mp_hal_delay_ms(delay_ms);
if (delay_ms <= RP2_LIGHTSLEEP_MIN) {
// Sleep time is too small, just use standard delay.
mp_hal_delay_ms(RP2_LIGHTSLEEP_MIN);
return;
}
use_timer_alarm = delay_ms < (1ULL << 32) / 1000;

Wyświetl plik

@ -117,6 +117,9 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
uint32_t freq = get_cpu_freq();
if (n_args > 0) {
duration = mp_obj_get_int(args[0]);
if (duration <= 0) {
return;
}
}
EIC_occured = false;
// Slow down
@ -130,7 +133,7 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK3 | EIC_GCLK_ID;
if (duration > 0) {
uint32_t t0 = systick_ms;
while ((systick_ms - t0 < duration) && (EIC_occured == false)) {
while (((systick_ms - t0) < duration) && (EIC_occured == false)) {
__WFI();
}
} else {