diff --git a/main.c b/main.c index d16db235e8..7020ab3851 100755 --- a/main.c +++ b/main.c @@ -404,8 +404,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { new_status_color(BLACK); board_deinit(); if (!supervisor_workflow_active()) { - // Enter deep sleep. When we wake up we'll return from - // this loop. + // Enter true deep sleep. When we wake up we'll be back at the + // top of main(), not in this loop. common_hal_alarm_enter_deep_sleep(); // Does not return. } else { @@ -426,18 +426,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #if CIRCUITPY_ALARM common_hal_alarm_pretending_deep_sleep(); - bool serial_in = (serial_connected() && - serial_bytes_available()); - supervisor_set_run_reason(RUN_REASON_STARTUP); - board_init(); - if (serial_in) { - bool ctrl_d = serial_read() == CHAR_CTRL_D; - if (ctrl_d) { - supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); - } - return ctrl_d; - } - return true; #else port_idle_until_interrupt(); #endif diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index e87fcd7991..a27fb88e4c 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 microDev - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/alarm/SleepMemory.h b/ports/nrf/common-hal/alarm/SleepMemory.h index 11cc4a8fb9..816f4f492b 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.h +++ b/ports/nrf/common-hal/alarm/SleepMemory.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index aabb27ef25..f60a33ca4c 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -167,6 +166,9 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); } +// TODO: this handles all possible types of wakeup, which is redundant with main. +// revise to extract all parts essential to enabling sleep wakeup, but leave the +// alarm/non-alarm sorting to the existing main loop. nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t prescaler) { bool have_timeout = false; uint64_t start_tick = 0, end_tick = 0; @@ -382,7 +384,7 @@ void common_hal_alarm_pretending_deep_sleep(void) { print_wakeup_cause(cause); #endif - alarm_reset(); + // alarm_reset(); #if 0 // if one of Alarm event occurred, reset myself diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h index ce8ca5f327..2473ab64a1 100644 --- a/ports/nrf/common-hal/alarm/__init__.h +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries. + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 89ec2ad30f..b6293ad1c5 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries - * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.h b/ports/nrf/common-hal/alarm/pin/PinAlarm.h index 93672c1f2d..0b7401669f 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.h +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index c4b06982bf..c6a79cbbc9 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.h b/ports/nrf/common-hal/alarm/time/TimeAlarm.h index a824c52535..61938210a2 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.h +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index 420ba14b82..9cf33279f7 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -1,6 +1,27 @@ /* - * debug functions - * (will be removed) + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jun2Sak + * + * 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