25
25
*/
26
26
27
27
#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h"
28
- <<<<<<< HEAD
29
- == = == ==
30
- #include "src/rp2_common/hardware_irq/include/hardware/irq.h"
31
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
32
28
33
29
#include <stdint.h>
34
30
@@ -49,16 +45,7 @@ volatile uint16_t result = 0;
49
45
volatile uint16_t buf_index = 0 ;
50
46
51
47
uint16_t pulsein_program [] = {
52
- <<<<<<< HEAD
53
48
0x4001 , // 1: in pins, 1
54
- = == == ==
55
- 0xe03f , // 0: set x, 31
56
- 0x4001 , // 1: in pins, 1
57
- 0x0041 , // 2: jmp x--, 2
58
- 0x8060 , // 3: push iffull block
59
- 0xc020 , // 4: irq wait 0
60
- 0x0000 , // 5: jmp 1
61
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
62
49
};
63
50
64
51
void common_hal_pulseio_pulsein_construct (pulseio_pulsein_obj_t * self ,
@@ -80,11 +67,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
80
67
81
68
bool ok = rp2pio_statemachine_construct (& state_machine ,
82
69
pulsein_program , sizeof (pulsein_program ) / sizeof (pulsein_program [0 ]),
83
- <<<<<<< HEAD
84
70
1000000 ,
85
- = == == ==
86
- 1000000 * 3 ,
87
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
88
71
NULL , 0 ,
89
72
NULL , 0 ,
90
73
pin , 1 ,
@@ -102,28 +85,14 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
102
85
self -> state_machine .state_machine = state_machine .state_machine ;
103
86
self -> state_machine .sm_config = state_machine .sm_config ;
104
87
self -> state_machine .offset = state_machine .offset ;
105
- <<<<<<< HEAD
106
- == = == ==
107
- if ( self -> state_machine .pio == pio0 ) {
108
- self -> pio_interrupt = PIO0_IRQ_0 ;
109
- } else {
110
- self -> pio_interrupt = PIO1_IRQ_0 ;
111
- }
112
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
113
88
pio_sm_clear_fifos (self -> state_machine .pio ,self -> state_machine .state_machine );
114
89
last_level = self -> idle_state ;
115
90
level_count = 0 ;
116
91
result = 0 ;
117
92
buf_index = 0 ;
118
93
119
94
pio_sm_set_in_pins (state_machine .pio ,state_machine .state_machine ,pin -> number );
120
- <<<<<<< HEAD
121
95
common_hal_rp2pio_statemachine_set_interrupt_handler (& state_machine ,& common_hal_pulseio_pulsein_interrupt ,NULL ,PIO_IRQ0_INTE_SM0_RXNEMPTY_BITS );
122
- = == == ==
123
- irq_set_exclusive_handler (self -> pio_interrupt , common_hal_pulseio_pulsein_interrupt );
124
- hw_clear_bits (& state_machine .pio -> inte0 , 1u << state_machine .state_machine );
125
- hw_set_bits (& state_machine .pio -> inte0 , 1u << (state_machine .state_machine + 8 ));
126
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
127
96
128
97
// exec a set pindirs to 0 for input
129
98
pio_sm_exec (state_machine .pio ,state_machine .state_machine ,0xe080 );
@@ -134,10 +103,6 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
134
103
pio_sm_exec (self -> state_machine .pio ,self -> state_machine .state_machine ,0x20a0 );
135
104
}
136
105
pio_sm_set_enabled (state_machine .pio , state_machine .state_machine , true);
137
- <<<<<<< HEAD
138
- == = == ==
139
- irq_set_enabled (self -> pio_interrupt , true);
140
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
141
106
}
142
107
143
108
bool common_hal_pulseio_pulsein_deinited (pulseio_pulsein_obj_t * self ) {
@@ -148,10 +113,6 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
148
113
if (common_hal_pulseio_pulsein_deinited (self )) {
149
114
return ;
150
115
}
151
- <<<<<<< HEAD
152
- == = == ==
153
- irq_set_enabled (self -> pio_interrupt , false);
154
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
155
116
pio_sm_set_enabled (self -> state_machine .pio , self -> state_machine .state_machine , false);
156
117
pio_sm_unclaim (self -> state_machine .pio , self -> state_machine .state_machine );
157
118
m_free (self -> buffer );
@@ -185,23 +146,12 @@ void common_hal_pulseio_pulsein_interrupt() {
185
146
}
186
147
}
187
148
}
188
- <<<<<<< HEAD
189
- == = == ==
190
- // clear interrupt
191
- irq_clear (self -> pio_interrupt );
192
- hw_clear_bits (& self -> state_machine .pio -> inte0 , 1u << self -> state_machine .state_machine );
193
- self -> state_machine .pio -> irq = 1u << self -> state_machine .state_machine ;
194
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
195
149
// check for a pulse thats too long (4000 us) or maxlen reached, and reset
196
150
if (( level_count > 4000 ) || (buf_index >= self -> maxlen )) {
197
151
pio_sm_set_enabled (self -> state_machine .pio , self -> state_machine .state_machine , false);
198
152
pio_sm_init (self -> state_machine .pio , self -> state_machine .state_machine , self -> state_machine .offset , & self -> state_machine .sm_config );
199
153
pio_sm_restart (self -> state_machine .pio ,self -> state_machine .state_machine );
200
154
pio_sm_set_enabled (self -> state_machine .pio , self -> state_machine .state_machine , true);
201
- <<<<<<< HEAD
202
- == = == ==
203
- irq_set_enabled (self -> pio_interrupt , true);
204
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
205
155
}
206
156
}
207
157
void common_hal_pulseio_pulsein_resume (pulseio_pulsein_obj_t * self ,
@@ -219,17 +169,10 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self,
219
169
gpio_put (self -> pin , !self -> idle_state );
220
170
common_hal_mcu_delay_us ((uint32_t )trigger_duration );
221
171
gpio_set_function (self -> pin ,GPIO_FUNC_PIO0 );
222
- <<<<<<< HEAD
223
172
common_hal_mcu_delay_us (225 );
224
173
}
225
174
226
175
// Reconfigure the pin for PIO
227
- = == == ==
228
- }
229
-
230
- // Reconfigure the pin for PIO
231
- common_hal_mcu_delay_us (200 );
232
- >>>>>>> a3c3e8a0fa5e06910747f1a95a12b899562a618d
233
176
gpio_set_function (self -> pin , GPIO_FUNC_PIO0 );
234
177
pio_sm_set_enabled (self -> state_machine .pio , self -> state_machine .state_machine , true);
235
178
}
0 commit comments