Browse Source

extmod/modmachine: Add MICROPY_PY_MACHINE_RESET configuration option.

Disabled by default, but enabled on all boards that previously had
`MICROPY_PY_MACHINE_BARE_METAL_FUNCS` enabled.

Signed-off-by: Damien George <damien@micropython.org>
pull/14089/head
Damien George 8 months ago
parent
commit
bfc3dde2c9
  1. 25
      extmod/modmachine.c
  2. 1
      ports/cc3200/mpconfigport.h
  3. 1
      ports/esp32/mpconfigport.h
  4. 1
      ports/esp8266/mpconfigport.h
  5. 1
      ports/mimxrt/mpconfigport.h
  6. 1
      ports/nrf/mpconfigport.h
  7. 1
      ports/renesas-ra/mpconfigport.h
  8. 1
      ports/rp2/mpconfigport.h
  9. 1
      ports/samd/mpconfigport.h
  10. 1
      ports/stm32/mpconfigport.h
  11. 5
      py/mpconfig.h

25
extmod/modmachine.c

@ -43,10 +43,13 @@ static void mp_machine_idle(void);
NORETURN void mp_machine_bootloader(size_t n_args, const mp_obj_t *args);
#endif
#if MICROPY_PY_MACHINE_BARE_METAL_FUNCS
static mp_obj_t mp_machine_unique_id(void);
#if MICROPY_PY_MACHINE_RESET
NORETURN static void mp_machine_reset(void);
static mp_int_t mp_machine_reset_cause(void);
#endif
#if MICROPY_PY_MACHINE_BARE_METAL_FUNCS
static mp_obj_t mp_machine_unique_id(void);
static mp_obj_t mp_machine_get_freq(void);
static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args);
static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args);
@ -77,12 +80,7 @@ static mp_obj_t machine_idle(void) {
}
static MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle);
#if MICROPY_PY_MACHINE_BARE_METAL_FUNCS
static mp_obj_t machine_unique_id(void) {
return mp_machine_unique_id();
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id);
#if MICROPY_PY_MACHINE_RESET
NORETURN static mp_obj_t machine_reset(void) {
mp_machine_reset();
@ -94,6 +92,15 @@ static mp_obj_t machine_reset_cause(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause);
#endif
#if MICROPY_PY_MACHINE_BARE_METAL_FUNCS
static mp_obj_t machine_unique_id(void) {
return mp_machine_unique_id();
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id);
static mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
return mp_machine_get_freq();
@ -154,7 +161,7 @@ static const mp_rom_map_elem_t machine_module_globals_table[] = {
#if MICROPY_PY_MACHINE_BOOTLOADER
{ MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) },
#endif
#if MICROPY_PY_MACHINE_BARE_METAL_FUNCS
#if MICROPY_PY_MACHINE_RESET
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) },
{ MP_ROM_QSTR(MP_QSTR_reset_cause), MP_ROM_PTR(&machine_reset_cause_obj) },
#endif

1
ports/cc3200/mpconfigport.h

@ -127,6 +127,7 @@
#define MICROPY_PY_VFS (1)
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/cc3200/mods/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)
#define MICROPY_PY_MACHINE_WDT (1)

1
ports/esp32/mpconfigport.h

@ -114,6 +114,7 @@
#define MICROPY_PY_OS_URANDOM (1)
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/esp32/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)
#define MICROPY_PY_MACHINE_ADC (1)

1
ports/esp8266/mpconfigport.h

@ -66,6 +66,7 @@
#define MICROPY_PY_LWIP_SOCK_RAW (1)
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/esp8266/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)
#define MICROPY_PY_MACHINE_ADC (1)

1
ports/mimxrt/mpconfigport.h

@ -79,6 +79,7 @@ uint32_t trng_random_u32(void);
#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (trng_random_u32())
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/mimxrt/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)

1
ports/nrf/mpconfigport.h

@ -174,6 +174,7 @@
#define MICROPY_PY_TIME (1)
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/nrf/modules/machine/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
#define MICROPY_PY_MACHINE_PULSE (0)

1
ports/renesas-ra/mpconfigport.h

@ -131,6 +131,7 @@
#ifndef MICROPY_PY_MACHINE
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/renesas-ra/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
#define MICROPY_PY_MACHINE_ADC (1)

1
ports/rp2/mpconfigport.h

@ -115,6 +115,7 @@
#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (rosc_random_u32())
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/rp2/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)

1
ports/samd/mpconfigport.h

@ -73,6 +73,7 @@
#define MICROPY_PY_TIME_INCLUDEFILE "ports/samd/modtime.c"
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/samd/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)

1
ports/stm32/mpconfigport.h

@ -111,6 +111,7 @@
#ifndef MICROPY_PY_MACHINE
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/stm32/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
#define MICROPY_PY_MACHINE_ADC (1)

5
py/mpconfig.h

@ -1692,6 +1692,11 @@ typedef double mp_float_t;
#define MICROPY_PY_MACHINE (0)
#endif
// Whether to include: reset, reset_cause
#ifndef MICROPY_PY_MACHINE_RESET
#define MICROPY_PY_MACHINE_RESET (0)
#endif
// Whether to include: bitstream
#ifndef MICROPY_PY_MACHINE_BITSTREAM
#define MICROPY_PY_MACHINE_BITSTREAM (0)

Loading…
Cancel
Save