From 6ef863997186e1893cdf19c0e04d0a8a3f33ad9d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 14:24:20 -0800 Subject: Rework safe mode and have heap overwrite trigger it. This creates a common safe mode mechanic that ports can share. As a result, the nRF52 now has safe mode support as well. The common safe mode adds a 700ms delay at startup where a reset during that window will cause a reset into safe mode. This window is designated by a yellow status pixel and flashing the single led three times. A couple NeoPixel fixes are included for the nRF52 as well. Fixes #1034. Fixes #990. Fixes #615. --- supervisor/port.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'supervisor/port.h') diff --git a/supervisor/port.h b/supervisor/port.h index dd4a82209..59898c8e4 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -33,12 +33,7 @@ #error "Please define PORT_HEAP_SIZE to specify heap size in bytes." #endif -typedef enum { - NO_SAFE_MODE = 0, - BROWNOUT, - HARD_CRASH, - USER_SAFE_MODE, -} safe_mode_t; +#include "supervisor/shared/safe_mode.h" // Provided by the linker; extern uint32_t _ezero; @@ -51,7 +46,10 @@ extern uint32_t _ebss; safe_mode_t port_init(void); -// Reset the microcontroller. +// Reset the microcontroller completely. +void reset_cpu(void); + +// Reset the microcontroller state. void reset_port(void); // Reset the rest of the board. @@ -60,8 +58,8 @@ void reset_board(void); // Reset to the bootloader void reset_to_bootloader(void); -#ifdef NRF52_SERIES -void HardFault_Handler(void); -#endif +// Save and retrieve a word from memory that is preserved over reset. Used for safe mode. +void port_set_saved_word(uint32_t); +uint32_t port_get_saved_word(void); #endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H -- cgit v1.2.3