@@ -129,36 +129,36 @@ void common_hal_pulseio_pulsein_interrupt(pulseio_pulsein_obj_t *self) {
129
129
rxfifo = pio_sm_get_blocking (self -> state_machine .pio , self -> state_machine .state_machine );
130
130
// translate from fifo to buffer
131
131
if ((rxfifo == 0 && self -> last_level == false) || (rxfifo == 0xffffffff && self -> last_level == true)) {
132
- self -> level_count = self -> level_count + 32 ;
132
+ self -> level_count = self -> level_count + 32 ;
133
133
} else {
134
- for (uint i = 0 ; i < 32 ; i ++ ) {
135
- bool level = (rxfifo & (1 << i )) >> i ;
136
- if (level == self -> last_level ) {
137
- self -> level_count ++ ;
138
- } else {
139
- result = self -> level_count ;
140
- self -> last_level = level ;
141
- self -> level_count = 0 ;
142
- // Pulses that are longer than MAX_PULSE will return MAX_PULSE
143
- if (result > MAX_PULSE ) {
144
- result = MAX_PULSE ;
145
- }
146
- // return pulses that are not too short
147
- if (result > MIN_PULSE ) {
148
- self -> buffer [self -> buf_index ] = (uint16_t )result ;
149
- if (self -> len < self -> maxlen ) {
150
- self -> len ++ ;
134
+ for (uint i = 0 ; i < 32 ; i ++ ) {
135
+ bool level = (rxfifo & (1 << i )) >> i ;
136
+ if (level == self -> last_level ) {
137
+ self -> level_count ++ ;
138
+ } else {
139
+ result = self -> level_count ;
140
+ self -> last_level = level ;
141
+ self -> level_count = 0 ;
142
+ // Pulses that are longer than MAX_PULSE will return MAX_PULSE
143
+ if (result > MAX_PULSE ) {
144
+ result = MAX_PULSE ;
151
145
}
152
- if (self -> buf_index < self -> maxlen ) {
153
- self -> buf_index ++ ;
154
- } else {
155
- self -> start = 0 ;
156
- self -> buf_index = 0 ;
146
+ // return pulses that are not too short
147
+ if (result > MIN_PULSE ) {
148
+ self -> buffer [self -> buf_index ] = (uint16_t )result ;
149
+ if (self -> len < self -> maxlen ) {
150
+ self -> len ++ ;
151
+ }
152
+ if (self -> buf_index < self -> maxlen ) {
153
+ self -> buf_index ++ ;
154
+ } else {
155
+ self -> start = 0 ;
156
+ self -> buf_index = 0 ;
157
+ }
157
158
}
158
159
}
159
160
}
160
161
}
161
- }
162
162
163
163
// check for a pulse thats too long (MAX_PULSE us) or maxlen reached, and reset
164
164
if ((self -> level_count > MAX_PULSE ) || (self -> buf_index >= self -> maxlen )) {
0 commit comments