Skip to content

Commit 1d8933d

Browse files
authored
Merge pull request #4265 from DavePutz/pio_soft_reset
Clear out PIOs and State Machines on RP2040 soft reset
2 parents 55e41d4 + 8bf5dd9 commit 1d8933d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ports/raspberrypi/common-hal/rp2pio/StateMachine.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "src/rp2_common/hardware_dma/include/hardware/dma.h"
3535
#include "src/rp2_common/hardware_pio/include/hardware/pio_instructions.h"
3636
#include "src/rp2040/hardware_structs/include/hardware/structs/iobank0.h"
37+
#include "src/rp2_common/hardware_irq/include/hardware/irq.h"
3738

3839
#include "lib/utils/interrupt_char.h"
3940
#include "py/obj.h"
@@ -101,6 +102,13 @@ void reset_rp2pio_statemachine(void) {
101102
_reset_statemachine(pio, j, false);
102103
}
103104
}
105+
for (uint8_t irq=PIO0_IRQ_0; irq <= PIO1_IRQ_1; irq++) {
106+
irq_handler_t int_handler = irq_get_exclusive_handler(irq);
107+
if (int_handler > 0) {
108+
irq_set_enabled (irq, false);
109+
irq_remove_handler(irq,int_handler);
110+
}
111+
}
104112
}
105113

106114
STATIC uint32_t _check_pins_free(const mcu_pin_obj_t * first_pin, uint8_t pin_count, bool exclusive_pin_use) {

0 commit comments

Comments
 (0)