kopia lustrzana https://github.com/micropython/micropython
Merge 5ac719cc01
into 5114f2c1ea
commit
e59884c2be
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
#include CPU_HEADER_H
|
#include CPU_HEADER_H
|
||||||
|
|
||||||
|
#define MIMXRT_DEEPSLEEP_MIN (1)
|
||||||
|
|
||||||
#if defined(MICROPY_HW_LED1_PIN)
|
#if defined(MICROPY_HW_LED1_PIN)
|
||||||
#define MICROPY_PY_MACHINE_LED_ENTRY { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&machine_led_type) },
|
#define MICROPY_PY_MACHINE_LED_ENTRY { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&machine_led_type) },
|
||||||
#else
|
#else
|
||||||
|
@ -129,7 +131,9 @@ 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) {
|
NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
if (n_args != 0) {
|
if (n_args != 0) {
|
||||||
mp_int_t seconds = mp_obj_get_int(args[0]) / 1000;
|
mp_int_t seconds = mp_obj_get_int(args[0]) / 1000;
|
||||||
if (seconds > 0) {
|
if (seconds < MIMXRT_DEEPSLEEP_MIN) {
|
||||||
|
seconds = MIMXRT_DEEPSLEEP_MIN;
|
||||||
|
}
|
||||||
machine_rtc_alarm_helper(seconds, false);
|
machine_rtc_alarm_helper(seconds, false);
|
||||||
#ifdef MIMXRT117x_SERIES
|
#ifdef MIMXRT117x_SERIES
|
||||||
GPC_CM_EnableIrqWakeup(GPC_CPU_MODE_CTRL_0, SNVS_HP_NON_TZ_IRQn, true);
|
GPC_CM_EnableIrqWakeup(GPC_CPU_MODE_CTRL_0, SNVS_HP_NON_TZ_IRQn, true);
|
||||||
|
@ -137,7 +141,6 @@ NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
GPC_EnableIRQ(GPC, SNVS_HP_WRAPPER_IRQn);
|
GPC_EnableIRQ(GPC, SNVS_HP_WRAPPER_IRQn);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(MIMXRT117x_SERIES)
|
#if defined(MIMXRT117x_SERIES)
|
||||||
machine_pin_config(pin_WAKEUP_DIG, PIN_MODE_IT_RISING, PIN_PULL_DISABLED, PIN_DRIVE_OFF, 0, PIN_AF_MODE_ALT5);
|
machine_pin_config(pin_WAKEUP_DIG, PIN_MODE_IT_RISING, PIN_PULL_DISABLED, PIN_DRIVE_OFF, 0, PIN_AF_MODE_ALT5);
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
#define RP2_RESET_PWRON (1)
|
#define RP2_RESET_PWRON (1)
|
||||||
#define RP2_RESET_WDT (3)
|
#define RP2_RESET_WDT (3)
|
||||||
|
#define RP2_LIGHTSLEEP_MIN (1)
|
||||||
|
|
||||||
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
|
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
|
||||||
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) }, \
|
{ 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) {
|
if (n_args == 1) {
|
||||||
delay_ms = mp_obj_get_int(args[0]);
|
delay_ms = mp_obj_get_int(args[0]);
|
||||||
if (delay_ms <= 1) {
|
if (delay_ms <= RP2_LIGHTSLEEP_MIN) {
|
||||||
// Sleep is too small, just use standard delay.
|
// Sleep time is too small, just use standard delay.
|
||||||
mp_hal_delay_ms(delay_ms);
|
mp_hal_delay_ms(RP2_LIGHTSLEEP_MIN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
use_timer_alarm = delay_ms < (1ULL << 32) / 1000;
|
use_timer_alarm = delay_ms < (1ULL << 32) / 1000;
|
||||||
|
|
|
@ -117,6 +117,9 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
uint32_t freq = get_cpu_freq();
|
uint32_t freq = get_cpu_freq();
|
||||||
if (n_args > 0) {
|
if (n_args > 0) {
|
||||||
duration = mp_obj_get_int(args[0]);
|
duration = mp_obj_get_int(args[0]);
|
||||||
|
if (duration <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EIC_occured = false;
|
EIC_occured = false;
|
||||||
// Slow down
|
// 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;
|
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK3 | EIC_GCLK_ID;
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
uint32_t t0 = systick_ms;
|
uint32_t t0 = systick_ms;
|
||||||
while ((systick_ms - t0 < duration) && (EIC_occured == false)) {
|
while (((systick_ms - t0) < duration) && (EIC_occured == false)) {
|
||||||
__WFI();
|
__WFI();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Ładowanie…
Reference in New Issue