8000 Made suggested changes (mostly) · domdfcoding/circuitpython@43275e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43275e0

Browse files
committed
Made suggested changes (mostly)
1 parent 1c80696 commit 43275e0

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ports/raspberrypi/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#define NO_PIN 0xff
4040
#define MAX_PULSE 65535
4141
#define MIN_PULSE 10
42-
volatile uint32_t result = 0;
4342

4443
uint16_t pulsein_program[] = {
4544
0x4001, // 1: in pins, 1
@@ -82,7 +81,6 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
8281
pio_sm_clear_fifos(self->state_machine.pio,self->state_machine.state_machine);
8382
self->last_level = self->idle_state;
8483
self->level_count = 0;
85-
result = 0;
8684
self->buf_index = 0;
8785

8886
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) {
119117
pio_sm_set_enabled(self->state_machine.pio, self->state_machine.state_machine, false);
120118
self->last_level = self->idle_state;
121119
self->level_count = 0;
122-
result = 0;
123120
self->buf_index = 0;
124121
}
125122
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) {
136133
if (level == self->last_level) {
137134
self->level_count++;
138135
} else {
139-
result = self->level_count;
136+
uint32_t result = self->level_count;
140137
self->last_level = level;
141138
self->level_count = 0;
142139
// Pulses that are longer than MAX_PULSE will return MAX_PULSE

ports/raspberrypi/common-hal/pulseio/PulseIn.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
typedef struct {
3737
mp_obj_base_t base;
3838
uint8_t pin;
39-
uint16_t *buffer;
40-
uint16_t maxlen;
4139
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;
4644
volatile uint16_t len;
45+
volatile uint16_t start;
46+
volatile uint16_t buf_index;
4747
rp2pio_statemachine_obj_t state_machine;
4848
} pulseio_pulsein_obj_t;
4949

0 commit comments

Comments
 (0)
0