File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
ports/raspberrypi/common-hal/pulseio Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -147,9 +147,12 @@ void common_hal_pulseio_pulsein_interrupt(void *self_in) {
147
147
}
148
148
// return pulses that are not too short
149
149
if (result > MIN_PULSE ) {
150
- self -> buffer [self -> buf_index ] = (uint16_t )result ;
150
+ size_t buf_index = (self -> start + self -> len ) % self -> maxlen ;
151
+ self -> buffer [buf_index ] = (uint16_t )result ;
151
152
if (self -> len < self -> maxlen ) {
152
153
self -> len ++ ;
154
+ } else {
155
+ self -> start = (self -> start + 1 ) % self -> maxlen ;
153
156
}
154
157
if (self -> buf_index < self -> maxlen ) {
155
158
self -> buf_index ++ ;
@@ -169,7 +172,6 @@ void common_hal_pulseio_pulsein_interrupt(void *self_in) {
169
172
pio_sm_restart (self -> state_machine .pio ,self -> state_machine .state_machine );
170
173
pio_sm_set_enabled (self -> state_machine .pio , self -> state_machine .state_machine , true);
171
174
self -> buf_index = 0 ;
172
- self -> start = 0 ;
173
175
}
174
176
}
175
177
void common_hal_pulseio_pulsein_resume (pulseio_pulsein_obj_t * self ,
You can’t perform that action at this time.
0 commit comments