summaryrefslogtreecommitdiff
path: root/extmod/machine_pulse.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-05-23 12:57:20 +1000
committerDamien George <damien@micropython.org>2025-06-13 16:27:35 +1000
commit398da22492d9e593f87f0b9ae4fc043f8b2b8a11 (patch)
treed4c164106d1a2de870a4c065b33b3e81248e14c8 /extmod/machine_pulse.c
parentef21ade602116421db2734d23320401ac6669773 (diff)
esp8266/modmachine: Use common machine_time_pulse_us implementation.
Testing shows that for frequencies which the esp8266 can handle -- up to about 1kHz -- `machine.time_pulse_us()` now gives more accurate results. Prior to this commit it would measure on average about 1us lower, but now the average is much closer to the true value. For example a pulse that is 1000us long, it would measure between 998 and 1000us. Now it measures between 999us and 1001us. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/machine_pulse.c')
-rw-r--r--extmod/machine_pulse.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/extmod/machine_pulse.c b/extmod/machine_pulse.c
index 1ec4d5f08..b78a63f18 100644
--- a/extmod/machine_pulse.c
+++ b/extmod/machine_pulse.c
@@ -30,7 +30,7 @@
#if MICROPY_PY_MACHINE_PULSE
-MP_WEAK mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) {
+mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) {
mp_uint_t nchanges = 2;
mp_uint_t start = mp_hal_ticks_us();
for (;;) {