extmod/modmachine: Allow more than one argument to machine.freq().

The limit is set by a `MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX` define, which
defaults to 1 and is set for stm32 to 4.

For stm32 this fixes a regression introduced in commit
e1ec6af654 where the maximum number of
arguments was changed from 4 to 1.

Signed-off-by: robert-hh <robert@hammelrath.com>
This commit is contained in:
robert-hh
2024-07-06 09:18:22 +02:00
committed by Damien George
parent 358e501e75
commit 2be45dd682
3 changed files with 7 additions and 1 deletions

View File

@@ -109,7 +109,7 @@ static mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
return mp_const_none; return mp_const_none;
} }
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_freq_obj, 0, 1, machine_freq); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_freq_obj, 0, MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX, machine_freq);
static mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) { static mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) {
mp_machine_lightsleep(n_args, args); mp_machine_lightsleep(n_args, args);

View File

@@ -113,6 +113,7 @@
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/stm32/modmachine.c" #define MICROPY_PY_MACHINE_INCLUDEFILE "ports/stm32/modmachine.c"
#define MICROPY_PY_MACHINE_RESET (1) #define MICROPY_PY_MACHINE_RESET (1)
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1) #define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
#define MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX (4)
#define MICROPY_PY_MACHINE_BOOTLOADER (1) #define MICROPY_PY_MACHINE_BOOTLOADER (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_ADC_INCLUDEFILE "ports/stm32/machine_adc.c" #define MICROPY_PY_MACHINE_ADC_INCLUDEFILE "ports/stm32/machine_adc.c"

View File

@@ -1736,6 +1736,11 @@ typedef double mp_float_t;
#define MICROPY_PY_MACHINE_RESET (0) #define MICROPY_PY_MACHINE_RESET (0)
#endif #endif
// Maximum number of arguments for machine.freq()
#ifndef MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX
#define MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX (1)
#endif
// Whether to include: bitstream // Whether to include: bitstream
#ifndef MICROPY_PY_MACHINE_BITSTREAM #ifndef MICROPY_PY_MACHINE_BITSTREAM
#define MICROPY_PY_MACHINE_BITSTREAM (0) #define MICROPY_PY_MACHINE_BITSTREAM (0)