36
36
#include "bindings/rp2pio/StateMachine.h"
37
37
#include "common-hal/pulseio/PulseIn.h"
38
38
39
- pulseio_pulsein_obj_t * save_self ;
40
-
41
39
#define NO_PIN 0xff
42
40
#define MAX_PULSE 65535
43
41
#define MIN_PULSE 10
@@ -62,7 +60,6 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
62
60
self -> idle_state = idle_state ;
63
61
self -> start = 0 ;
64
62
self -> len = 0 ;
65
- save_self = self ;
66
63
67
64
bool ok = rp2pio_statemachine_construct (& self -> state_machine ,
68
65
pulsein_program , sizeof (pulsein_program ) / sizeof (pulsein_program [0 ]),
@@ -88,7 +85,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
88
85
buf_index = 0 ;
89
86
90
87
pio_sm_set_in_pins (self -> state_machine .pio ,self -> state_machine .state_machine ,pin -> number );
91
- common_hal_rp2pio_statemachine_set_interrupt_handler (& (self -> state_machine ),& common_hal_pulseio_pulsein_interrupt ,NULL ,PIO_IRQ0_INTE_SM0_RXNEMPTY_BITS );
88
+ common_hal_rp2pio_statemachine_set_interrupt_handler (& (self -> state_machine ),& common_hal_pulseio_pulsein_interrupt ,self ,PIO_IRQ0_INTE_SM0_RXNEMPTY_BITS );
92
89
93
90
// exec a set pindirs to 0 for input
94
91
pio_sm_exec (self -> state_machine .pio ,self -> state_machine .state_machine ,0xe080 );
@@ -124,9 +121,8 @@ void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) {
124
121
result = 0 ;
125
122
buf_index = 0 ;
126
123
}
127
- void common_hal_pulseio_pulsein_interrupt () {
124
+ void common_hal_pulseio_pulsein_interrupt (pulseio_pulsein_obj_t * self ) {
128
125
129
- pulseio_pulsein_obj_t * self = save_self ;
130
126
uint32_t rxfifo = 0 ;
131
127
132
128
rxfifo = pio_sm_get_blocking (self -> state_machine .pio , self -> state_machine .state_machine );
0 commit comments