We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a6fb0be commit 7dfcae6Copy full SHA for 7dfcae6
1 file changed
ports/stm/common-hal/pulseio/PulseIn.c
@@ -79,12 +79,9 @@ static void pulsein_handler(uint8_t num) {
79
self->first_edge = false;
80
}
81
} else {
82
- 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;
83
// Cap duration at 16 bits.
84
- uint16_t duration = 0xffff;
85
- if (total_diff < duration) {
86
- duration = total_diff;
87
- }
+ uint16_t duration = MIN(0xffff, total_diff);
88
89
uint16_t i = (self->start + self->len) % self->maxlen;
90
self->buffer[i] = duration;
0 commit comments