Skip to content

Commit 0bb3c7d

Browse files
committed
stmhal: Enable machine.time_pulse_us() function.
1 parent c08f50b commit 0bb3c7d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

stmhal/modmachine.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "py/runtime.h"
3232
#include "py/mphal.h"
3333
#include "extmod/machine_mem.h"
34+
#include "extmod/machine_pulse.h"
3435
#include "extmod/machine_i2c.h"
3536
#include "lib/fatfs/ff.h"
3637
#include "lib/fatfs/diskio.h"
@@ -517,6 +518,8 @@ STATIC const mp_map_elem_t machine_module_globals_table[] = {
517518
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable_irq), (mp_obj_t)&pyb_disable_irq_obj },
518519
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable_irq), (mp_obj_t)&pyb_enable_irq_obj },
519520

521+
{ MP_OBJ_NEW_QSTR(MP_QSTR_time_pulse_us), (mp_obj_t)&machine_time_pulse_us_obj },
522+
520523
{ MP_ROM_QSTR(MP_QSTR_mem8), (mp_obj_t)&machine_mem8_obj },
521524
{ MP_ROM_QSTR(MP_QSTR_mem16), (mp_obj_t)&machine_mem16_obj },
522525
{ MP_ROM_QSTR(MP_QSTR_mem32), (mp_obj_t)&machine_mem32_obj },

stmhal/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#define MICROPY_PY_UHEAPQ (1)
9696
#define MICROPY_PY_UHASHLIB (1)
9797
#define MICROPY_PY_MACHINE (1)
98+
#define MICROPY_PY_MACHINE_PULSE (1)
9899
#define MICROPY_PY_MACHINE_I2C (1)
99100
#define MICROPY_PY_MACHINE_SPI (1)
100101
#define MICROPY_PY_MACHINE_SPI_MIN_DELAY (0)

stmhal/mphalport.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ extern const unsigned char mp_hal_status_to_errno_table[4];
3434
NORETURN void mp_hal_raise(HAL_StatusTypeDef status);
3535
void mp_hal_set_interrupt_char(int c); // -1 to disable
3636

37-
#define mp_hal_delay_ms HAL_Delay
38-
#define mp_hal_ticks_ms HAL_GetTick
39-
40-
// needed for machine.I2C
37+
// timing functions
4138
#include "stmhal/systick.h"
39+
#define mp_hal_delay_ms HAL_Delay
4240
#define mp_hal_delay_us_fast(us) sys_tick_udelay(us)
41+
#define mp_hal_ticks_ms HAL_GetTick
42+
#define mp_hal_ticks_us() sys_tick_get_microseconds()
4343

4444
// C-level pin HAL
4545
#include "stmhal/pin.h"

0 commit comments

Comments
 (0)