summaryrefslogtreecommitdiff
path: root/supervisor/port.h
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-12-06 14:24:20 -0800
committerScott Shawcroft <scott@tannewt.org>2018-12-06 14:24:20 -0800
commit6ef863997186e1893cdf19c0e04d0a8a3f33ad9d (patch)
tree461360ed76e39ca0a534a0dee040fc1cf6848d70 /supervisor/port.h
parent7ad2e6ace34a6d417ec1b84472fa409d5451137b (diff)
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.
Diffstat (limited to 'supervisor/port.h')
-rw-r--r--supervisor/port.h18
1 files changed, 8 insertions, 10 deletions
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