diff options
| author | Damien George <damien@micropython.org> | 2022-10-27 14:32:43 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-10-27 14:32:43 +1100 |
| commit | cd35b8a2a3f27499d36c522930ca70d6f26997cd (patch) | |
| tree | e17b9c6033655a730bc93dfa7553443a66e86fea | |
| parent | e8f5cfe0e140f510fa0c94c6a5f474430e4a4bef (diff) | |
extmod/machine_timer: Move stm32's implementation of machine.Timer here.
So it can be reused by other ports.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | extmod/extmod.mk | 1 | ||||
| -rw-r--r-- | extmod/machine_timer.c (renamed from ports/stm32/machine_timer.c) | 4 | ||||
| -rw-r--r-- | ports/stm32/Makefile | 1 | ||||
| -rw-r--r-- | ports/stm32/mpconfigport.h | 1 | ||||
| -rw-r--r-- | py/mpconfig.h | 5 |
5 files changed, 11 insertions, 1 deletions
diff --git a/extmod/extmod.mk b/extmod/extmod.mk index 3b10fc857..c087e13cb 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 index 640d1d200..cdace4ee2 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 79bf8b54b..e99d386e4 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 34b3a6aba..de12f0320 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 99fa87e5c..0ae6fcdd1 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) |
