Skip to content

Commit

Permalink
Merge pull request #4265 from DavePutz/pio_soft_reset
Browse files Browse the repository at this point in the history
Clear out PIOs and State Machines on RP2040 soft reset
  • Loading branch information
tannewt authored Mar 3, 2021
2 parents 55e41d4 + 8bf5dd9 commit 1d8933d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ports/raspberrypi/common-hal/rp2pio/StateMachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "src/rp2_common/hardware_dma/include/hardware/dma.h"
#include "src/rp2_common/hardware_pio/include/hardware/pio_instructions.h"
#include "src/rp2040/hardware_structs/include/hardware/structs/iobank0.h"
#include "src/rp2_common/hardware_irq/include/hardware/irq.h"

#include "lib/utils/interrupt_char.h"
#include "py/obj.h"
Expand Down Expand Up @@ -101,6 +102,13 @@ void reset_rp2pio_statemachine(void) {
_reset_statemachine(pio, j, false);
}
}
for (uint8_t irq=PIO0_IRQ_0; irq <= PIO1_IRQ_1; irq++) {
irq_handler_t int_handler = irq_get_exclusive_handler(irq);
if (int_handler > 0) {
irq_set_enabled (irq, false);
irq_remove_handler(irq,int_handler);
}
}
}

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

0 comments on commit 1d8933d

Please sign in to comment.