From 7dfcae6067ee07ad644278a66aaa114759b181a8 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 14 Apr 2020 17:09:48 -0700 Subject: [PATCH] Tweaks from jepler --- ports/stm/common-hal/pulseio/PulseIn.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ports/stm/common-hal/pulseio/PulseIn.c b/ports/stm/common-hal/pulseio/PulseIn.c index 2536ae73bd..227d77a08e 100644 --- a/ports/stm/common-hal/pulseio/PulseIn.c +++ b/ports/stm/common-hal/pulseio/PulseIn.c @@ -79,12 +79,9 @@ static void pulsein_handler(uint8_t num) { self->first_edge = false; } } else { - uint32_t total_diff = current_count + 0xffff * (current_overflow - self->last_overflow) - self->last_count; + uint32_t total_diff = current_count + 0x10000 * (current_overflow - self->last_overflow) - self->last_count; // Cap duration at 16 bits. - uint16_t duration = 0xffff; - if (total_diff < duration) { - duration = total_diff; - } + uint16_t duration = MIN(0xffff, total_diff); uint16_t i = (self->start + self->len) % self->maxlen; self->buffer[i] = duration;