Skip to content

Commit 7dfcae6

Browse files
committed
Tweaks from jepler
1 parent a6fb0be commit 7dfcae6

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

ports/stm/common-hal/pulseio/PulseIn.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,9 @@ static void pulsein_handler(uint8_t num) {
7979
self->first_edge = false;
8080
}
8181
} else {
82-
uint32_t total_diff = current_count + 0xffff * (current_overflow - self->last_overflow) - self->last_count;
82+
uint32_t total_diff = current_count + 0x10000 * (current_overflow - self->last_overflow) - self->last_count;
8383
// Cap duration at 16 bits.
84-
uint16_t duration = 0xffff;
85-
if (total_diff < duration) {
86-
duration = total_diff;
87-
}
84+
uint16_t duration = MIN(0xffff, total_diff);
8885

8986
uint16_t i = (self->start + self->len) % self->maxlen;
9087
self->buffer[i] = duration;

0 commit comments

Comments
 (0)