Browse Source

nrf/modmachine: Add machine.bootloader() and make it customisable.

pull/8756/head
iabdalkader 3 years ago
committed by Damien George
parent
commit
d8f5669532
  1. 8
      ports/nrf/modules/machine/modmachine.c
  2. 1
      ports/nrf/modules/machine/modmachine.h
  3. 4
      ports/nrf/mpconfigport.h

8
ports/nrf/modules/machine/modmachine.c

@ -153,6 +153,13 @@ STATIC mp_obj_t machine_soft_reset(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
MICROPY_BOARD_ENTER_BOOTLOADER(n_args, args);
for (;;) {
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_bootloader_obj, 0, 1, machine_bootloader);
STATIC mp_obj_t machine_lightsleep(void) {
__WFE();
return mp_const_none;
@ -196,6 +203,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) },
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) },
{ MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) },
{ MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) },
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_lightsleep_obj) },

1
ports/nrf/modules/machine/modmachine.h

@ -38,5 +38,6 @@ MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(machine_info_obj);
MP_DECLARE_CONST_FUN_OBJ_0(machine_reset_obj);
MP_DECLARE_CONST_FUN_OBJ_0(machine_lightsleep_obj);
MP_DECLARE_CONST_FUN_OBJ_0(machine_deepsleep_obj);
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args);
#endif // __MICROPY_INCLUDED_NRF5_MODMACHINE_H__

4
ports/nrf/mpconfigport.h

@ -371,6 +371,10 @@ extern const struct _mp_obj_module_t music_module;
#define MICROPY_BOARD_STARTUP()
#endif
#ifndef MICROPY_BOARD_ENTER_BOOTLOADER
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args)
#endif
#ifndef MICROPY_BOARD_EARLY_INIT
#define MICROPY_BOARD_EARLY_INIT()
#endif

Loading…
Cancel
Save