wip: ResetReason to microcontroller.cpu
This commit is contained in:
parent
e4c66990e2
commit
75559f35cc
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-19 00:28-0500\n"
|
||||
"POT-Creation-Date: 2020-11-21 12:36-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -990,7 +990,7 @@ msgstr ""
|
|||
msgid "I2SOut not available"
|
||||
msgstr ""
|
||||
|
||||
#: ports/esp32s2/common-hal/alarm_io/__init__.c
|
||||
#: ports/esp32s2/common-hal/alarm/pin/__init__.c
|
||||
msgid "IOs 0, 2 & 4 do not support internal pullup in sleep"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2449,6 +2449,10 @@ msgstr ""
|
|||
msgid "division by zero"
|
||||
msgstr ""
|
||||
|
||||
#: ports/esp32s2/common-hal/alarm/time/DurationAlarm.c
|
||||
msgid "duration out of range"
|
||||
msgstr ""
|
||||
|
||||
#: py/objdeque.c
|
||||
msgid "empty"
|
||||
msgstr ""
|
||||
|
@ -2809,7 +2813,7 @@ msgstr ""
|
|||
msgid "invalid syntax for number"
|
||||
msgstr ""
|
||||
|
||||
#: ports/esp32s2/common-hal/alarm_io/__init__.c
|
||||
#: ports/esp32s2/common-hal/alarm/pin/__init__.c
|
||||
msgid "io must be rtc io"
|
||||
msgstr ""
|
||||
|
||||
|
@ -3434,10 +3438,6 @@ 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 ""
|
||||
|
@ -3484,7 +3484,7 @@ msgstr ""
|
|||
msgid "trapz is defined for 1D arrays of equal length"
|
||||
msgstr ""
|
||||
|
||||
#: ports/esp32s2/common-hal/alarm_io/__init__.c
|
||||
#: ports/esp32s2/common-hal/alarm/pin/__init__.c
|
||||
msgid "trigger level must be 0 or 1"
|
||||
msgstr ""
|
||||
|
||||
|
@ -3630,7 +3630,7 @@ msgstr ""
|
|||
msgid "vectors must have same lengths"
|
||||
msgstr ""
|
||||
|
||||
#: ports/esp32s2/common-hal/alarm_io/__init__.c
|
||||
#: ports/esp32s2/common-hal/alarm/pin/__init__.c
|
||||
msgid "wakeup conflict"
|
||||
msgstr ""
|
||||
|
||||
|
|
9
main.c
9
main.c
|
@ -330,7 +330,7 @@ bool run_code_py(safe_mode_t safe_mode) {
|
|||
#if CIRCUITPY_ALARM
|
||||
// If USB isn't enumerated then deep sleep.
|
||||
if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) {
|
||||
common_hal_mcu_deep_sleep();
|
||||
common_hal_alarm_restart_on_alarm(0, NULL);
|
||||
}
|
||||
#endif
|
||||
// Show the animation every N seconds.
|
||||
|
@ -430,14 +430,9 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
|
|||
if (!skip_boot_output) {
|
||||
// Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write,
|
||||
// in case power is momentary or will fail shortly due to, say a low, battery.
|
||||
#if CIRCUITPY_ALARM
|
||||
if (common_hal_alarm_get_reset_reason() == RESET_REASON_POWER_ON) {
|
||||
#endif
|
||||
if (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON) {
|
||||
mp_hal_delay_ms(1500);
|
||||
#if CIRCUITPY_ALARM
|
||||
}
|
||||
#endif
|
||||
|
||||
// USB isn't up, so we can write the file.
|
||||
filesystem_set_internal_writable_by_usb(false);
|
||||
f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS);
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
|
||||
#include "py/mphal.h"
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
|
||||
#include "samd/adc.h"
|
||||
|
||||
|
@ -349,3 +350,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
|
|
@ -84,10 +84,6 @@ void common_hal_mcu_reset(void) {
|
|||
reset();
|
||||
}
|
||||
|
||||
void common_hal_mcu_deep_sleep(void) {
|
||||
//deep sleep call here
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||
// It currently only has properties, and no state.
|
||||
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
// For NAN: remove when not needed.
|
||||
#include <math.h>
|
||||
#include "py/mphal.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
|
||||
uint32_t common_hal_mcu_processor_get_frequency(void) {
|
||||
return cxd56_get_cpu_baseclk();
|
||||
|
@ -47,3 +48,7 @@ float common_hal_mcu_processor_get_voltage(void) {
|
|||
void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
||||
boardctl(BOARDIOC_UNIQUEID, (uintptr_t) raw_id);
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
|
|
@ -81,10 +81,6 @@ void common_hal_mcu_reset(void) {
|
|||
boardctl(BOARDIOC_RESET, 0);
|
||||
}
|
||||
|
||||
void common_hal_mcu_deep_sleep(void) {
|
||||
//deep sleep call here
|
||||
}
|
||||
|
||||
STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART2_RXD), MP_ROM_PTR(&pin_UART2_RXD) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART2_TXD), MP_ROM_PTR(&pin_UART2_TXD) },
|
||||
|
|
|
@ -35,23 +35,6 @@ void common_hal_alarm_disable_all(void) {
|
|||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL);
|
||||
}
|
||||
|
||||
alarm_reset_reason_t common_hal_alarm_get_reset_reason(void) {
|
||||
switch (esp_sleep_get_wakeup_cause()) {
|
||||
case ESP_SLEEP_WAKEUP_TIMER:
|
||||
return RESET_REASON_DEEP_SLEEP_ALARM;
|
||||
|
||||
case ESP_SLEEP_WAKEUP_EXT0:
|
||||
return RESET_REASON_DEEP_SLEEP_ALARM;
|
||||
|
||||
case ESP_SLEEP_WAKEUP_TOUCHPAD:
|
||||
//TODO: implement TouchIO
|
||||
case ESP_SLEEP_WAKEUP_UNDEFINED:
|
||||
default:
|
||||
return RESET_REASON_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mp_obj_t common_hal_alarm_get_wake_alarm(void) {
|
||||
switch (esp_sleep_get_wakeup_cause()) {
|
||||
case ESP_SLEEP_WAKEUP_TIMER: {
|
||||
|
|
|
@ -28,8 +28,9 @@
|
|||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "soc/efuse_reg.h"
|
||||
|
@ -74,3 +75,23 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
|||
*ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
|
||||
*ptr-- = swap_nibbles(mac_address_part & 0xff);
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
switch (esp_sleep_get_wakeup_cause()) {
|
||||
case ESP_SLEEP_WAKEUP_TIMER:
|
||||
return RESET_REASON_DEEP_SLEEP_ALARM;
|
||||
|
||||
case ESP_SLEEP_WAKEUP_EXT0:
|
||||
return RESET_REASON_DEEP_SLEEP_ALARM;
|
||||
|
||||
case ESP_SLEEP_WAKEUP_TOUCHPAD:
|
||||
//TODO: implement TouchIO
|
||||
case ESP_SLEEP_WAKEUP_UNDEFINED:
|
||||
default:
|
||||
return RESET_REASON_POWER_APPLIED;
|
||||
}
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
|
|
@ -79,10 +79,6 @@ void common_hal_mcu_reset(void) {
|
|||
while(1);
|
||||
}
|
||||
|
||||
void common_hal_mcu_deep_sleep(void) {
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||
// It currently only has properties, and no state.
|
||||
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
|
|
|
@ -26,8 +26,10 @@
|
|||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "csr.h"
|
||||
|
@ -62,3 +64,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
|||
raw_id[13] = csr_readl(CSR_VERSION_SEED_ADDR + 8);
|
||||
raw_id[14] = csr_readl(CSR_VERSION_SEED_ADDR + 12);
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
|
|
@ -89,10 +89,6 @@ void common_hal_mcu_reset(void) {
|
|||
while(1);
|
||||
}
|
||||
|
||||
void common_hal_mcu_deep_sleep(void) {
|
||||
//deep sleep call here
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||
// It currently only has properties, and no state.
|
||||
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
|
||||
#include "fsl_tempmon.h"
|
||||
#include "fsl_ocotp.h"
|
||||
|
@ -70,3 +71,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
|||
}
|
||||
OCOTP_Deinit(OCOTP);
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
|
|
@ -86,10 +86,6 @@ void common_hal_mcu_reset(void) {
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void common_hal_mcu_deep_sleep(void) {
|
||||
//deep sleep call here
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||
// It currently only has properties, and no state.
|
||||
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
|
|
|
@ -24,8 +24,10 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "nrfx_saadc.h"
|
||||
|
@ -119,3 +121,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
|||
((uint32_t*) raw_id)[i] = NRF_FICR->DEVICEID[i];
|
||||
}
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
|
|
@ -95,10 +95,6 @@ void common_hal_mcu_reset(void) {
|
|||
reset_cpu();
|
||||
}
|
||||
|
||||
void common_hal_mcu_deep_sleep(void) {
|
||||
//deep sleep call here
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||
// It currently only has properties, and no state.
|
||||
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
|
|
|
@ -25,9 +25,12 @@
|
|||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include STM32_HAL_H
|
||||
|
||||
#if CPY_STM32F4
|
||||
|
@ -138,3 +141,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
|
|
@ -81,10 +81,6 @@ void common_hal_mcu_reset(void) {
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void common_hal_mcu_deep_sleep(void) {
|
||||
//deep sleep call here
|
||||
}
|
||||
|
||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||
// It currently only has properties, and no state.
|
||||
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||
|
|
|
@ -394,7 +394,6 @@ $(filter $(SRC_PATTERNS), \
|
|||
_bleio/Attribute.c \
|
||||
_bleio/ScanEntry.c \
|
||||
_eve/__init__.c \
|
||||
alarm/ResetReason.c \
|
||||
camera/ImageFormat.c \
|
||||
canio/Match.c \
|
||||
digitalio/Direction.c \
|
||||
|
@ -402,6 +401,7 @@ $(filter $(SRC_PATTERNS), \
|
|||
digitalio/Pull.c \
|
||||
fontio/Glyph.c \
|
||||
math/__init__.c \
|
||||
microcontroller/ResetReason.c \
|
||||
microcontroller/RunMode.c \
|
||||
)
|
||||
|
||||
|
|
|
@ -54,13 +54,12 @@ FrameBuffer = Union[rgbmatrix.RGBMatrix]
|
|||
"""
|
||||
|
||||
Alarm = Union[
|
||||
alarm_time.Time, alarm_pin.PinLevel, alarm_touch.PinTouch
|
||||
alarm.pin.PinAlarm, alarm.time.DurationAlarm
|
||||
]
|
||||
"""Classes that implement the audiosample protocol
|
||||
"""Classes that implement alarms for sleeping and asynchronous notification.
|
||||
|
||||
- `alarm_time.Time`
|
||||
- `alarm_pin.PinLevel`
|
||||
- `alarm_touch.PinTouch`
|
||||
- `alarm.pin.PinAlarm`
|
||||
- `alarm.time.DurationAlarm`
|
||||
|
||||
You can play use these alarms to wake from light or deep sleep.
|
||||
You can use these alarms to wake from light or deep sleep.
|
||||
"""
|
||||
|
|
|
@ -1,3 +1,37 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Dan Halbert 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 "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/alarm/__init__.h"
|
||||
#include "shared-bindings/alarm/ResetReason.h"
|
||||
#include "shared-bindings/alarm/pin/PinAlarm.h"
|
||||
#include "shared-bindings/alarm/time/DurationAlarm.h"
|
||||
|
||||
//| """Power-saving light and deep sleep. Alarms can be set to wake up from sleep.
|
||||
//|
|
||||
//| The `alarm` module provides sleep related functionality. There are two supported levels of
|
||||
|
@ -11,54 +45,43 @@
|
|||
//| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save
|
||||
//| a more significant amount of power, but CircuitPython must start ``code.py`` from the beginning when woken
|
||||
//| up. CircuitPython will enter deep sleep automatically when the current program exits without error
|
||||
//| or calls `sys.exit(0)`.
|
||||
//| or calls ``sys.exit(0)``.
|
||||
//| If an error causes CircuitPython to exit, error LED error flashes will be done periodically.
|
||||
//| An error includes an uncaught exception, or sys.exit called with a non-zero argumetn.
|
||||
//| To set alarms for deep sleep use `alarm.reload_on_alarm()` they will apply to next deep sleep only."""
|
||||
//| To set alarms for deep sleep use `alarm.restart_on_alarm()` they will apply to next deep sleep only."""
|
||||
//|
|
||||
|
||||
//| wake_alarm: Alarm
|
||||
//| """The most recent alarm to wake us up from a sleep (light or deep.)"""
|
||||
//|
|
||||
|
||||
//| reset_reason: ResetReason
|
||||
//| """The reason the chip started up from reset state. This can may be power up or due to an alarm."""
|
||||
//|
|
||||
|
||||
//| def sleep(alarm: Alarm, ...) -> Alarm:
|
||||
//| def sleep_until_alarm(*alarms: Alarm) -> Alarm:
|
||||
//| """Performs a light sleep until woken by one of the alarms. The alarm that triggers the wake
|
||||
//| is returned, and is also available as `alarm.wake_alarm`
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/alarm/__init__.h"
|
||||
#include "shared-bindings/alarm/ResetReason.h"
|
||||
#include "shared-bindings/alarm/pin/PinAlarm.h"
|
||||
#include "shared-bindings/alarm/time/DurationAlarm.h"
|
||||
|
||||
STATIC mp_obj_t alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args) {
|
||||
// TODO
|
||||
common_hal_alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarm);
|
||||
|
||||
//| def restart_on_alarm(alarm: Alarm, ...) -> None:
|
||||
//| def restart_on_alarm(*alarms: Alarm) -> None:
|
||||
//| """Set one or more alarms to wake up from a deep sleep.
|
||||
//| When awakened, ``code.py`` will restart from the beginning.
|
||||
//| The last alarm to wake us up is available as `wake_alarm`.
|
||||
//| The last alarm to wake us up is available as `alarm.wake_alarm`.
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args) {
|
||||
// TODO
|
||||
common_hal_alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_restart_on_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_restart_on_alarm);
|
||||
|
||||
//| """The `alarm.pin` module contains alarm attributes and classes related to pins
|
||||
//| """The `alarm.pin` module contains alarm attributes and classes related to pins.
|
||||
//| """
|
||||
//|
|
||||
STATIC const mp_map_elem_t alarm_pin_globals_table[] = {
|
||||
|
@ -95,7 +118,6 @@ STATIC mp_map_elem_t alarm_module_globals_table[] = {
|
|||
|
||||
// wake_alarm and reset_reason are mutable attributes.
|
||||
{ MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset_reason), MP_OBJ_FROM_PTR(&reset_reason_INVALID_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), MP_OBJ_FROM_PTR(&alarm_sleep_until_alarm_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_restart_on_alarm), MP_OBJ_FROM_PTR(&alarm_restart_on_alarm_obj) },
|
||||
|
@ -116,16 +138,6 @@ void common_hal_alarm_set_wake_alarm(mp_obj_t alarm) {
|
|||
}
|
||||
}
|
||||
|
||||
void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason) {
|
||||
// Equivalent of:
|
||||
// alarm.reset_reason = reset_reason
|
||||
mp_map_elem_t *elem =
|
||||
mp_map_lookup(&alarm_module_globals.map, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP);
|
||||
if (elem) {
|
||||
elem->value = reset_reason;
|
||||
}
|
||||
}
|
||||
|
||||
const mp_obj_module_t alarm_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&alarm_module_globals,
|
||||
|
|
|
@ -29,11 +29,9 @@
|
|||
|
||||
#include "py/obj.h"
|
||||
|
||||
#include "shared-bindings/alarm/ResetReason.h"
|
||||
|
||||
extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm);
|
||||
|
||||
extern alarm_reset_reason_t common_hal_alarm_get_reset_reason(void);
|
||||
extern void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason);
|
||||
extern mp_obj_t common_hal_alarm_restart_on_alarm(size_t n_alarms, const mp_obj_t *alarms);
|
||||
extern mp_obj_t alarm_sleep_until_alarm(size_t n_alarms, const mp_obj_t *alarms);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H
|
||||
|
|
|
@ -35,27 +35,27 @@
|
|||
#include "supervisor/shared/translate.h"
|
||||
|
||||
//| class PinAlarm:
|
||||
//| """Trigger an alarm when a pin changes state.
|
||||
//| """Trigger an alarm when a pin changes state."""
|
||||
//|
|
||||
//| def __init__(self, pin: microcontroller.Pin, level: bool, *, edge: bool = False, pull: bool = False) -> None:
|
||||
//| """Create an alarm triggered by a `~microcontroller.Pin` level. The alarm is not active
|
||||
//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep()` or
|
||||
//| `alarm.wake_after_exit()`.
|
||||
|
||||
//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep_until_alarm()` or
|
||||
//| `alarm.restart_on_alarm()`.
|
||||
//|
|
||||
//| :param ~microcontroller.Pin pin: The pin to monitor. On some ports, the choice of pin
|
||||
//| may be limited due to hardware restrictions, particularly for deep-sleep alarms.
|
||||
//| may be limited due to hardware restrictions, particularly for deep-sleep alarms.
|
||||
//| :param bool level: When active, trigger when the level is high (``True``) or low (``False``).
|
||||
//| On some ports, multiple `PinAlarm` objects may need to have coordinated levels
|
||||
//| for deep-sleep alarms
|
||||
//| On some ports, multiple `PinAlarm` objects may need to have coordinated levels
|
||||
//| for deep-sleep alarms.
|
||||
//| :param bool edge: If ``True``, trigger only when there is a transition to the specified
|
||||
//| value of `level`. If ``True``, if the alarm becomes active when the pin level already
|
||||
//| matches `level`, the alarm is not triggered: the pin must transition from ``not level``
|
||||
//| to ``level`` to trigger the alarm. On some ports, edge-triggering may not be available,
|
||||
//| particularly for deep-sleep alarms.
|
||||
//| value of `level`. If ``True``, if the alarm becomes active when the pin level already
|
||||
//| matches `level`, the alarm is not triggered: the pin must transition from ``not level``
|
||||
//| to ``level`` to trigger the alarm. On some ports, edge-triggering may not be available,
|
||||
//| particularly for deep-sleep alarms.
|
||||
//| :param bool pull: Enable a pull-up or pull-down which pulls the pin to level opposite
|
||||
//| opposite that of `level`. For instance, if `level` is set to ``True``, setting `pull`
|
||||
//| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal
|
||||
//| pulls it high.
|
||||
//| opposite that of `level`. For instance, if `level` is set to ``True``, setting `pull`
|
||||
//| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal
|
||||
//| pulls it high.
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
|
|
|
@ -34,14 +34,13 @@
|
|||
#include "supervisor/shared/translate.h"
|
||||
|
||||
//| class DurationAlarm:
|
||||
//| """Trigger an alarm at a specified interval from now.
|
||||
//| """Trigger an alarm at a specified interval from now."""
|
||||
//|
|
||||
//| def __init__(self, secs: float) -> None:
|
||||
//| """Create an alarm that will be triggered in `secs` seconds **from the time
|
||||
//| the alarm is created**. The alarm is not active until it is listed in an
|
||||
//| `alarm`-enabling function, such as `alarm.sleep()` or
|
||||
//| `alarm.wake_after_exit()`. But the interval starts immediately upon
|
||||
//| instantiation.
|
||||
//| """Create an alarm that will be triggered in `secs` seconds from the time
|
||||
//| sleep starts. The alarm is not active until it is listed in an
|
||||
//| `alarm`-enabling function, such as `alarm.sleep_until_alarm()` or
|
||||
//| `alarm.restart_on_alarm()`.
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
|
|
|
@ -67,6 +67,23 @@ const mp_obj_property_t mcu_processor_frequency_obj = {
|
|||
},
|
||||
};
|
||||
|
||||
//| reset_reason: `microcontroller.ResetReason`
|
||||
//| """The reason the microcontroller started up from reset state."""
|
||||
//|
|
||||
STATIC mp_obj_t mcu_processor_get_reset_reason(mp_obj_t self) {
|
||||
return cp_enum_find(&mcu_reset_reason_type, common_hal_mcu_processor_get_reset_reason());
|
||||
}
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_reset_reason_obj, mcu_processor_get_reset_reason);
|
||||
|
||||
const mp_obj_property_t mcu_reset_reason_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&mcu_processor_get_reason_reason_obj, // getter
|
||||
(mp_obj_t)&mp_const_none_obj, // no setter
|
||||
(mp_obj_t)&mp_const_none_obj, // no deleter
|
||||
},
|
||||
};
|
||||
|
||||
//| temperature: Optional[float]
|
||||
//| """The on-chip temperature, in Celsius, as a float. (read-only)
|
||||
//|
|
||||
|
@ -128,6 +145,7 @@ const mp_obj_property_t mcu_processor_voltage_obj = {
|
|||
|
||||
STATIC const mp_rom_map_elem_t mcu_processor_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&mcu_processor_frequency_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset_reason), MP_ROM_PTR(&mcu_processor_reset_reason_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_temperature), MP_ROM_PTR(&mcu_processor_temperature_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_uid), MP_ROM_PTR(&mcu_processor_uid_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_voltage), MP_ROM_PTR(&mcu_processor_voltage_obj) },
|
||||
|
|
|
@ -29,11 +29,12 @@
|
|||
|
||||
#include "py/obj.h"
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
|
||||
extern const mp_obj_type_t mcu_processor_type;
|
||||
|
||||
uint32_t common_hal_mcu_processor_get_frequency(void);
|
||||
mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void);
|
||||
float common_hal_mcu_processor_get_temperature(void);
|
||||
void common_hal_mcu_processor_get_uid(uint8_t raw_id[]);
|
||||
float common_hal_mcu_processor_get_voltage(void);
|
||||
|
|
|
@ -27,42 +27,37 @@
|
|||
#include "py/obj.h"
|
||||
#include "py/enum.h"
|
||||
|
||||
#include "shared-bindings/alarm/ResetReason.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, INVALID, RESET_REASON_INVALID);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_ON, RESET_REASON_POWER_ON);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, BROWNOUT, RESET_REASON_BROWNOUT);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, RESET_PIN, RESET_REASON_RESET_PIN);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, WATCHDOG, RESET_REASON_WATCHDOG);
|
||||
MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, POWER_ON, RESET_REASON_POWER_ON);
|
||||
MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, BROWNOUT, RESET_REASON_BROWNOUT);
|
||||
MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE);
|
||||
MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM);
|
||||
MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, RESET_PIN, RESET_REASON_RESET_PIN);
|
||||
MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, WATCHDOG, RESET_REASON_WATCHDOG);
|
||||
|
||||
//| class ResetReason:
|
||||
//| """The reason the chip was last reset"""
|
||||
//|
|
||||
//| INVALID: object
|
||||
//| """Invalid reason: indicates an internal error."""
|
||||
//| """The reason the microntroller was last reset"""
|
||||
//|
|
||||
//| POWER_ON: object
|
||||
//| """The chip was started from power off."""
|
||||
//| """The microntroller was started from power off."""
|
||||
//|
|
||||
//| BROWNOUT: object
|
||||
//| """The chip was reset due to voltage brownout."""
|
||||
//| """The microntroller was reset due to too low a voltage."""
|
||||
//|
|
||||
//| SOFTWARE: object
|
||||
//| """The chip was reset from software."""
|
||||
//| """The microntroller was reset from software."""
|
||||
//|
|
||||
//| DEEP_SLEEP_ALARM: object
|
||||
//| """The chip was reset for deep sleep and restarted by an alarm."""
|
||||
//| """The microntroller was reset for deep sleep and restarted by an alarm."""
|
||||
//|
|
||||
//| RESET_PIN: object
|
||||
//| """The chip was reset by a signal on its reset pin. The pin might be connected to a reset buton."""
|
||||
//| """The microntroller was reset by a signal on its reset pin. The pin might be connected to a reset button."""
|
||||
//|
|
||||
//| WATCHDOG: object
|
||||
//| """The chip was reset by its watchdog timer."""
|
||||
//| """The chip microcontroller reset by its watchdog timer."""
|
||||
//|
|
||||
MAKE_ENUM_MAP(alarm_reset_reason) {
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, INVALID),
|
||||
MAKE_ENUM_MAP(mcu_reset_reason) {
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, BROWNOUT),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE),
|
||||
|
@ -70,8 +65,8 @@ MAKE_ENUM_MAP(alarm_reset_reason) {
|
|||
MAKE_ENUM_MAP_ENTRY(reset_reason, RESET_PIN),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, WATCHDOG),
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(alarm_reset_reason_locals_dict, alarm_reset_reason_locals_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(mcu_reset_reason_locals_dict, mcu_reset_reason_locals_table);
|
||||
|
||||
MAKE_PRINTER(alarm, alarm_reset_reason);
|
||||
MAKE_PRINTER(alarm, mcu_reset_reason);
|
||||
|
||||
MAKE_ENUM_TYPE(alarm, ResetReason, alarm_reset_reason);
|
||||
MAKE_ENUM_TYPE(alarm, ResetReason, mcu_reset_reason);
|
|
@ -24,24 +24,28 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/enum.h"
|
||||
|
||||
typedef enum {
|
||||
RESET_REASON_INVALID,
|
||||
RESET_REASON_POWER_ON,
|
||||
RESET_REASON_BROWNOUT,
|
||||
RESET_REASON_SOFTWARE,
|
||||
RESET_REASON_DEEP_SLEEP_ALARM,
|
||||
RESET_REASON_RESET_PIN,
|
||||
RESET_REASON_WATCHDOG,
|
||||
} alarm_reset_reason_t;
|
||||
} mcu_reset_reason_t;
|
||||
|
||||
extern const cp_enum_obj_t reset_reason_INVALID_obj;
|
||||
extern const cp_enum_obj_t reset_reason_POWER_ON_obj;
|
||||
extern const cp_enum_obj_t reset_reason_BROWNOUT_obj;
|
||||
extern const cp_enum_obj_t reset_reason_SOFTWARE_obj;
|
||||
extern const cp_enum_obj_t reset_reason_DEEP_SLEEP_ALARM_obj;
|
||||
extern const cp_enum_obj_t reset_reason_RESET_PIN_obj;
|
||||
extern const cp_enum_obj_t reset_reason_WATCHDOG_obj;
|
||||
|
||||
extern const mp_obj_type_t alarm_reset_reason_type;
|
||||
extern const mp_obj_type_t mcu_reset_reason_type;
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H
|
|
@ -135,13 +135,6 @@ STATIC mp_obj_t mcu_reset(void) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset);
|
||||
|
||||
STATIC mp_obj_t mcu_sleep(void) {
|
||||
common_hal_mcu_deep_sleep();
|
||||
// We won't actually get here because mcu is going into sleep.
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_sleep_obj, mcu_sleep);
|
||||
|
||||
//| nvm: Optional[ByteArray]
|
||||
//| """Available non-volatile memory.
|
||||
//| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise.
|
||||
|
@ -176,8 +169,6 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_on_next_reset), MP_ROM_PTR(&mcu_on_next_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mcu_reset_obj) },
|
||||
//ToDo: Remove MP_QSTR_sleep when sleep on code.py exit implemented.
|
||||
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mcu_sleep_obj) },
|
||||
#if CIRCUITPY_INTERNAL_NVM_SIZE > 0
|
||||
{ MP_ROM_QSTR(MP_QSTR_nvm), MP_ROM_PTR(&common_hal_mcu_nvm_obj) },
|
||||
#else
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "py/mpconfig.h"
|
||||
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
#include "shared-bindings/microcontroller/RunMode.h"
|
||||
|
||||
extern void common_hal_mcu_delay_us(uint32_t);
|
||||
|
@ -43,8 +43,6 @@ extern void common_hal_mcu_enable_interrupts(void);
|
|||
extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode);
|
||||
extern void common_hal_mcu_reset(void);
|
||||
|
||||
extern void common_hal_mcu_deep_sleep(void);
|
||||
|
||||
extern const mp_obj_dict_t mcu_pin_globals;
|
||||
|
||||
extern const mcu_processor_obj_t common_hal_mcu_processor_obj;
|
||||
|
|
|
@ -28,35 +28,35 @@
|
|||
|
||||
#include "shared-bindings/supervisor/RunReason.h"
|
||||
|
||||
MAKE_ENUM_VALUE(canio_bus_state_type, run_reason, ERROR_ACTIVE, RUN_REASON_STARTUP);
|
||||
MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_PASSIVE, RUN_REASON_AUTORELOAD);
|
||||
MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_WARNING, RUN_REASON_SUPERVISOR_RELOAD);
|
||||
MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, RUN_REASON_RELOAD_HOTKEY);
|
||||
MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, STARTUP, RUN_REASON_STARTUP);
|
||||
MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, AUTORELOAD, RUN_REASON_AUTORELOAD);
|
||||
MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, SUPERVISOR_RELOAD, RUN_REASON_SUPERVISOR_RELOAD);
|
||||
MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_REPL_RELOAD);
|
||||
|
||||
//| class RunReason:
|
||||
//| """The state of the CAN bus"""
|
||||
//| """The reason that CircuitPython started running."""
|
||||
//|
|
||||
//| STARTUP: object
|
||||
//| """The first VM was run after the microcontroller started up. See `microcontroller.start_reason`
|
||||
//| for more detail why the microcontroller was started."""
|
||||
//| """CircuitPython started the microcontroller started up. See `microcontroller.cpu.reset_reason`
|
||||
//| for more detail on why the microcontroller was started."""
|
||||
//|
|
||||
//| AUTORELOAD: object
|
||||
//| """The VM was run due to a USB write to the filesystem."""
|
||||
//| """CircuitPython restarted due to a USB write to the filesystem."""
|
||||
//|
|
||||
//| SUPERVISOR_RELOAD: object
|
||||
//| """The VM was run due to a call to `supervisor.reload()`."""
|
||||
//| """CircuitPython restarted due to a call to `supervisor.reload()`."""
|
||||
//|
|
||||
//| RELOAD_HOTKEY: object
|
||||
//| """The VM was run due CTRL-D."""
|
||||
//| REPL_RELOAD: object
|
||||
//| """CircuitPython started due to the user typing CTRL-D in the REPL."""
|
||||
//|
|
||||
MAKE_ENUM_MAP(canio_bus_state) {
|
||||
MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE),
|
||||
MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE),
|
||||
MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_WARNING),
|
||||
MAKE_ENUM_MAP_ENTRY(bus_state, BUS_OFF),
|
||||
MAKE_ENUM_MAP(run_reason) {
|
||||
MAKE_ENUM_MAP_ENTRY(run_reason, STARTUP),
|
||||
MAKE_ENUM_MAP_ENTRY(run_reason, AUTORELOAD),
|
||||
MAKE_ENUM_MAP_ENTRY(run_reason, SUPERVISOR_RELOAD),
|
||||
MAKE_ENUM_MAP_ENTRY(run_reason, REPL_RELOAD),
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(canio_bus_state_locals_dict, canio_bus_state_locals_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(supervisor_run_reason_locals_dict, supervisor_run_reason_locals_table);
|
||||
|
||||
MAKE_PRINTER(canio, canio_bus_state);
|
||||
MAKE_PRINTER(supervisor, supervisor_run_reason);
|
||||
|
||||
MAKE_ENUM_TYPE(canio, BusState, canio_bus_state);
|
||||
MAKE_ENUM_TYPE(supervisor, RunReason, supervisor_run_reason);
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef enum {
|
|||
RUN_REASON_STARTUP,
|
||||
RUN_REASON_AUTORELOAD,
|
||||
RUN_REASON_SUPERVISOR_RELOAD,
|
||||
RUN_REASON_RELOAD_HOTKEY
|
||||
RUN_REASON_REPL_RELOAD,
|
||||
} supervisor_run_reason_t;
|
||||
|
||||
extern const mp_obj_type_t canio_bus_state_type;
|
||||
extern const mp_obj_type_t supervisor_run_reason_type;
|
||||
|
|
|
@ -91,15 +91,11 @@ const mp_obj_property_t supervisor_serial_bytes_available_obj = {
|
|||
|
||||
|
||||
//| run_reason: RunReason
|
||||
//| """Returns why the Python VM was run this time."""
|
||||
//| """Returns why CircuitPython started running this particular time.
|
||||
//|
|
||||
STATIC mp_obj_t supervisor_get_run_reason(mp_obj_t self) {
|
||||
if (!common_hal_get_serial_bytes_available()) {
|
||||
return mp_const_false;
|
||||
}
|
||||
else {
|
||||
return mp_const_true;
|
||||
}
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_get_run_reason_obj, supervisor_get_run_reason);
|
||||
|
||||
|
|
|
@ -29,10 +29,8 @@
|
|||
#include "mphalport.h"
|
||||
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#if CIRCUITPY_ALARM
|
||||
#include "shared-bindings/alarm/__init__.h"
|
||||
#include "shared-bindings/alarm/ResetReason.h"
|
||||
#endif
|
||||
#include "shared-bindings/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
|
||||
#include "supervisor/serial.h"
|
||||
#include "supervisor/shared/rgb_led_colors.h"
|
||||
|
@ -56,12 +54,12 @@ safe_mode_t wait_for_safe_mode_reset(void) {
|
|||
current_safe_mode = safe_mode;
|
||||
return safe_mode;
|
||||
}
|
||||
#if CIRCUITPY_ALARM
|
||||
if (common_hal_alarm_get_reset_reason() != RESET_REASON_POWER_ON &&
|
||||
common_hal_alarm_get_reset_reason() != RESET_REASON_RESET_PIN) {
|
||||
|
||||
const mcu_reset_reason_t reset_reason = common_hal_mcu_processor_get_reset_reason();
|
||||
if (reset_reason != RESET_REASON_POWER_ON &&
|
||||
reset_reason != RESET_REASON_RESET_PIN) {
|
||||
return NO_SAFE_MODE;
|
||||
}
|
||||
#endif
|
||||
port_set_saved_word(SAFE_MODE_DATA_GUARD | (MANUAL_SAFE_MODE << 8));
|
||||
// Wait for a while to allow for reset.
|
||||
temp_status_color(SAFE_MODE);
|
||||
|
|
Loading…
Reference in New Issue