kopia lustrzana https://github.com/micropython/micropython
ports/rp2: Additions for rp2 init hooks.
Signed-off-by: Christopher Parrott <chris@pimoroni.com>pull/12283/head
rodzic
b1ac266bb5
commit
e73f8fd5f7
|
@ -412,6 +412,7 @@ endif()
|
||||||
list(APPEND MICROPY_SOURCE_QSTR
|
list(APPEND MICROPY_SOURCE_QSTR
|
||||||
${MICROPY_SOURCE_EXTMOD}
|
${MICROPY_SOURCE_EXTMOD}
|
||||||
${MICROPY_SOURCE_USERMOD}
|
${MICROPY_SOURCE_USERMOD}
|
||||||
|
${MICROPY_SOURCE_BOARD}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define mpy-cross flags
|
# Define mpy-cross flags
|
||||||
|
@ -430,6 +431,7 @@ target_sources(${MICROPY_TARGET} PRIVATE
|
||||||
${MICROPY_SOURCE_LIB}
|
${MICROPY_SOURCE_LIB}
|
||||||
${MICROPY_SOURCE_DRIVERS}
|
${MICROPY_SOURCE_DRIVERS}
|
||||||
${MICROPY_SOURCE_PORT}
|
${MICROPY_SOURCE_PORT}
|
||||||
|
${MICROPY_SOURCE_BOARD}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${MICROPY_TARGET} micropy_lib_mbedtls)
|
target_link_libraries(${MICROPY_TARGET} micropy_lib_mbedtls)
|
||||||
|
|
|
@ -76,6 +76,9 @@ int main(int argc, char **argv) {
|
||||||
// This is a tickless port, interrupts should always trigger SEV.
|
// This is a tickless port, interrupts should always trigger SEV.
|
||||||
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
|
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
|
||||||
|
|
||||||
|
// Hook for setting up anything that needs to be super early in the bootup process
|
||||||
|
MICROPY_BOARD_STARTUP();
|
||||||
|
|
||||||
#if MICROPY_HW_ENABLE_UART_REPL
|
#if MICROPY_HW_ENABLE_UART_REPL
|
||||||
bi_decl(bi_program_feature("UART REPL"))
|
bi_decl(bi_program_feature("UART REPL"))
|
||||||
setup_default_uart();
|
setup_default_uart();
|
||||||
|
@ -146,6 +149,9 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Hook for setting up anything that can wait until after other hardware features are initialised
|
||||||
|
MICROPY_BOARD_EARLY_INIT();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
// Initialise MicroPython runtime.
|
// Initialise MicroPython runtime.
|
||||||
|
@ -169,6 +175,9 @@ int main(int argc, char **argv) {
|
||||||
mod_network_lwip_init();
|
mod_network_lwip_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Hook for setting up anything that should follow the MicroPy runtime but be prior to _boot.py
|
||||||
|
MICROPY_BOARD_LATE_INIT();
|
||||||
|
|
||||||
// Execute _boot.py to set up the filesystem.
|
// Execute _boot.py to set up the filesystem.
|
||||||
#if MICROPY_VFS_FAT && MICROPY_HW_USB_MSC
|
#if MICROPY_VFS_FAT && MICROPY_HW_USB_MSC
|
||||||
pyexec_frozen_module("_boot_fat.py", false);
|
pyexec_frozen_module("_boot_fat.py", false);
|
||||||
|
@ -207,6 +216,10 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
soft_reset_exit:
|
soft_reset_exit:
|
||||||
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
||||||
|
|
||||||
|
// Hook for resetting anything immediately following a soft reboot command
|
||||||
|
MICROPY_BOARD_EARLY_RESET();
|
||||||
|
|
||||||
#if MICROPY_PY_NETWORK
|
#if MICROPY_PY_NETWORK
|
||||||
mod_network_deinit();
|
mod_network_deinit();
|
||||||
#endif
|
#endif
|
||||||
|
@ -227,6 +240,9 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
gc_sweep_all();
|
gc_sweep_all();
|
||||||
mp_deinit();
|
mp_deinit();
|
||||||
|
|
||||||
|
// Hook for resetting anything after the MicroPy runtime has been deinitialised
|
||||||
|
MICROPY_BOARD_LATE_RESET();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -275,3 +275,23 @@ extern void lwip_lock_release(void);
|
||||||
#define MICROPY_PY_BLUETOOTH_ENTER uint32_t atomic_state = 0;
|
#define MICROPY_PY_BLUETOOTH_ENTER uint32_t atomic_state = 0;
|
||||||
#define MICROPY_PY_BLUETOOTH_EXIT (void)atomic_state;
|
#define MICROPY_PY_BLUETOOTH_EXIT (void)atomic_state;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MICROPY_BOARD_STARTUP
|
||||||
|
#define MICROPY_BOARD_STARTUP()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MICROPY_BOARD_EARLY_INIT
|
||||||
|
#define MICROPY_BOARD_EARLY_INIT()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MICROPY_BOARD_LATE_INIT
|
||||||
|
#define MICROPY_BOARD_LATE_INIT()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MICROPY_BOARD_EARLY_RESET
|
||||||
|
#define MICROPY_BOARD_EARLY_RESET()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MICROPY_BOARD_LATE_RESET
|
||||||
|
#define MICROPY_BOARD_LATE_RESET()
|
||||||
|
#endif
|
||||||
|
|
Ładowanie…
Reference in New Issue