@@ -56,7 +56,6 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
56
56
self -> idle_state = idle_state ;
57
57
self -> start = 0 ;
58
58
self -> len = 0 ;
59
- self -> len_target = 0 ;
60
59
61
60
common_hal_rp2pio_statemachine_construct (& self -> state_machine ,
62
61
pulsein_program , MP_ARRAY_SIZE (pulsein_program ),
@@ -134,8 +133,6 @@ void common_hal_pulseio_pulsein_interrupt(void *self_in) {
134
133
self -> buffer [buf_index ] = (uint16_t )result ;
135
134
if (self -> len < self -> maxlen ) {
136
135
self -> len ++ ;
137
- self -> len_target ++ ; // The interrupt will only cause a problem in either len or len_target, not both.
138
- // So we can just check for a match, and choose the higher.
139
136
} else {
140
137
self -> start = (self -> start + 1 ) % self -> maxlen ;
141
138
}
@@ -176,14 +173,10 @@ uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) {
176
173
mp_raise_IndexError_varg (translate ("pop from empty %q" ), MP_QSTR_PulseIn );
177
174
}
178
175
uint16_t value = self -> buffer [self -> start ];
176
+ common_hal_mcu_disable_interrupts ();
179
177
self -> start = (self -> start + 1 ) % self -> maxlen ;
180
- self -> len_target -- ;
181
178
self -> len -- ;
182
- if (self -> len != self -> len_target ) {
183
- uint16_t len_accurate = self -> len > self -> len_target ? self -> len : self -> len_target ;
184
- self -> len_target = len_accurate ;
185
- self -> len = len_accurate ;
186
- }
179
+ common_hal_mcu_enable_interrupts ();
187
180
return value ;
188
181
}
189
182
0 commit comments