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>
This commit is contained in:
Damien George 2022-10-27 14:32:43 +11:00
parent e8f5cfe0e1
commit cd35b8a2a3
5 changed files with 11 additions and 1 deletions

View File

@ -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 \

View File

@ -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

View File

@ -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 \

View File

@ -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)

View File

@ -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)