diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2020-04-14 17:09:48 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-04-14 17:09:48 -0700 |
| commit | 7dfcae6067ee07ad644278a66aaa114759b181a8 (patch) | |
| tree | eae47f00a66c79993a074eb0565fc8ae8ea420b2 | |
| parent | a6fb0beaa9f1065256bfe7ea97b2fc32ba80a43b (diff) | |
Tweaks from jepler
| -rw-r--r-- | ports/stm/common-hal/pulseio/PulseIn.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/ports/stm/common-hal/pulseio/PulseIn.c b/ports/stm/common-hal/pulseio/PulseIn.c index 2536ae73b..227d77a08 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; |
