diff --git a/extmod/extmod.mk b/extmod/extmod.mk index 3b10fc857c..c087e13cbd 100644 --- a/extmod/extmod.mk +++ b/extmod/extmod.mk @@ -10,6 +10,7 @@ SRC_EXTMOD_C += \ extmod/machine_pwm.c \ extmod/machine_signal.c \ extmod/machine_spi.c \ + extmod/machine_timer.c \ extmod/modbluetooth.c \ extmod/modbtree.c \ extmod/modframebuf.c \ diff --git a/ports/stm32/machine_timer.c b/extmod/machine_timer.c similarity index 98% rename from ports/stm32/machine_timer.c rename to extmod/machine_timer.c index 640d1d200f..cdace4ee24 100644 --- a/ports/stm32/machine_timer.c +++ b/extmod/machine_timer.c @@ -28,6 +28,8 @@ #include "py/mphal.h" #include "shared/runtime/softtimer.h" +#if MICROPY_PY_MACHINE_TIMER + typedef soft_timer_entry_t machine_timer_obj_t; const mp_obj_type_t machine_timer_type; @@ -144,3 +146,5 @@ MP_DEFINE_CONST_OBJ_TYPE( print, machine_timer_print, locals_dict, &machine_timer_locals_dict ); + +#endif // MICROPY_PY_MACHINE_TIMER diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index 79bf8b54bf..e99d386e49 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -329,7 +329,6 @@ SRC_C += \ machine_i2c.c \ machine_i2s.c \ machine_spi.c \ - machine_timer.c \ machine_uart.c \ modmachine.c \ modpyb.c \ diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 34b3a6abad..de12f03207 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -126,6 +126,7 @@ #define MICROPY_PY_MACHINE_SPI_MSB (SPI_FIRSTBIT_MSB) #define MICROPY_PY_MACHINE_SPI_LSB (SPI_FIRSTBIT_LSB) #define MICROPY_PY_MACHINE_SOFTSPI (1) +#define MICROPY_PY_MACHINE_TIMER (1) #endif #define MICROPY_HW_SOFTSPI_MIN_DELAY (0) #define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (HAL_RCC_GetSysClockFreq() / 48) diff --git a/py/mpconfig.h b/py/mpconfig.h index 99fa87e5c1..0ae6fcdd11 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1631,6 +1631,11 @@ typedef double mp_float_t; #define MICROPY_PY_MACHINE_SOFTSPI (0) #endif +// Whether to provide the "machine.Timer" class +#ifndef MICROPY_PY_MACHINE_TIMER +#define MICROPY_PY_MACHINE_TIMER (0) +#endif + // The default backlog value for socket.listen(backlog) #ifndef MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT #define MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT (2)