mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
stm32/boardctrl: Allow boards to override fatal-error handler.
To override it a board must define MICROPY_BOARD_FATAL_ERROR to a function that takes a string message and does not return. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "py/objstr.h"
|
||||
#include "py/mphal.h"
|
||||
@@ -33,6 +35,26 @@
|
||||
#include "led.h"
|
||||
#include "usrsw.h"
|
||||
|
||||
NORETURN void boardctrl_fatal_error(const char *msg) {
|
||||
for (volatile uint delay = 0; delay < 10000000; delay++) {
|
||||
}
|
||||
led_state(1, 1);
|
||||
led_state(2, 1);
|
||||
led_state(3, 1);
|
||||
led_state(4, 1);
|
||||
mp_hal_stdout_tx_strn("\nFATAL ERROR:\n", 14);
|
||||
mp_hal_stdout_tx_strn(msg, strlen(msg));
|
||||
for (uint i = 0;;) {
|
||||
led_toggle(((i++) & 3) + 1);
|
||||
for (volatile uint delay = 0; delay < 10000000; delay++) {
|
||||
}
|
||||
if (i >= 16) {
|
||||
// to conserve power
|
||||
__WFI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void flash_error(int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
led_state(PYB_LED_RED, 1);
|
||||
|
||||
Reference in New Issue
Block a user