File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
ports/raspberrypi/common-hal/pulseio Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 39
39
#define NO_PIN 0xff
40
40
#define MAX_PULSE 65535
41
41
#define MIN_PULSE 10
42
- volatile uint32_t result = 0 ;
43
42
44
43
uint16_t pulsein_program [] = {
45
44
0x4001 , // 1: in pins, 1
@@ -82,7 +81,6 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
82
81
pio_sm_clear_fifos (self -> state_machine .pio ,self -> state_machine .state_machine );
83
82
self -> last_level = self -> idle_state ;
84
83
self -> level_count = 0 ;
85
- result = 0 ;
86
84
self -> buf_index = 0 ;
87
85
88
86
pio_sm_set_in_pins (self -> state_machine .pio ,self -> state_machine .state_machine ,pin -> number );
@@ -119,7 +117,6 @@ void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) {
119
117
pio_sm_set_enabled (self -> state_machine .pio , self -> state_machine .state_machine , false);
120
118
self -> last_level = self -> idle_state ;
121
119
self -> level_count = 0 ;
122
- result = 0 ;
123
120
self -> buf_index = 0 ;
124
121
}
125
122
void common_hal_pulseio_pulsein_interrupt (pulseio_pulsein_obj_t * self ) {
@@ -136,7 +133,7 @@ void common_hal_pulseio_pulsein_interrupt(pulseio_pulsein_obj_t *self) {
136
133
if (level == self -> last_level ) {
137
134
self -> level_count ++ ;
138
135
} else {
139
- result = self -> level_count ;
136
+ uint32_t result = self -> level_count ;
140
137
self -> last_level = level ;
141
138
self -> level_count = 0 ;
142
139
// Pulses that are longer than MAX_PULSE will return MAX_PULSE
Original file line number Diff line number Diff line change 36
36
typedef struct {
37
37
mp_obj_base_t base ;
38
38
uint8_t pin ;
39
- uint16_t * buffer ;
40
- uint16_t maxlen ;
41
39
bool idle_state ;
42
- bool last_level ;
43
- uint32_t level_count ;
44
- volatile uint16_t buf_index ;
45
- volatile uint16_t start ;
40
+ uint16_t maxlen ;
41
+ uint16_t * buffer ;
42
+ volatile bool last_level ;
43
+ volatile uint32_t level_count ;
46
44
volatile uint16_t len ;
45
+ volatile uint16_t start ;
46
+ volatile uint16_t buf_index ;
47
47
rp2pio_statemachine_obj_t state_machine ;
48
48
} pulseio_pulsein_obj_t ;
49
49
You can’t perform that action at this time.
0 commit comments