10000 nrf: Add machine.bootloader for boards with custom bootloaders. · micropython/micropython@7d34b3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d34b3d

Browse files
committed
nrf: Add machine.bootloader for boards with custom bootloaders.
1 parent 912811d commit 7d34b3d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ports/nrf/modules/machine/modmachine.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ STATIC mp_obj_t machine_disable_irq(void) {
189189
}
190190
MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
191191

192+
#if defined(MICROPY_BOARD_ENTER_BOOTLOADER)
193+
STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
194+
MICROPY_BOARD_ENTER_BOOTLOADER(0, 0);
195+
while (1) {
196+
;
197+
}
198+
}
199+
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_bootloader_obj, 0, 1, machine_bootloader);
200+
#endif
201+
192202
STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
193203
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) },
194204
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) },
@@ -240,6 +250,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
240250
#if defined(NRF52_SERIES)
241251
{ MP_ROM_QSTR(MP_QSTR_NFC_RESET), MP_ROM_INT(PYB_RESET_NFC) },
242252
#endif
253+
#if defined(MICROPY_BOARD_ENTER_BOOTLOADER)
254+
{ MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) },
255+
#endif
243256
};
244257

245258
STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table);

0 commit comments

Comments
 (0)
0