From 233b3f4e216a2d664bda3f81c528ca6ce48bece5 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 6 Jan 2021 20:19:29 +0200 Subject: [PATCH] ports/nrf: Add common board init macros. --- ports/nrf/Makefile | 1 + ports/nrf/main.c | 6 +++++- ports/nrf/mpconfigport.h | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index c32e09d2c9ce8..51032a1ed6ab8 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -274,6 +274,7 @@ SRC_C += \ drivers/ticker.c \ drivers/bluetooth/ble_drv.c \ drivers/bluetooth/ble_uart.c \ + $(wildcard boards/$(BOARD)/*.c) \ ifeq ($(MCU_SUB_VARIANT), nrf52840) diff --git a/ports/nrf/main.c b/ports/nrf/main.c index 2ec16194cb571..9c8cb6ba8022c 100644 --- a/ports/nrf/main.c +++ b/ports/nrf/main.c @@ -107,9 +107,13 @@ extern uint32_t _heap_start; extern uint32_t _heap_end; int main(int argc, char **argv) { + // Hook for a board to run code at start up, for example check if a + // bootloader should be entered instead of the main application. + MICROPY_BOARD_STARTUP(); - + MICROPY_BOARD_EARLY_INIT(); soft_reset: + #if MICROPY_PY_TIME_TICKS rtc1_init_time_ticks(); #endif diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 29bdd3f80ca4e..04bd5b4c265b2 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -366,3 +366,11 @@ extern const struct _mp_obj_module_t music_module; #ifndef MP_NEED_LOG2 #define MP_NEED_LOG2 (1) #endif + +#ifndef MICROPY_BOARD_STARTUP +#define MICROPY_BOARD_STARTUP() +#endif + +#ifndef MICROPY_BOARD_EARLY_INIT +#define MICROPY_BOARD_EARLY_INIT() +#endif