Changed reset_rp2pio_statemachine to clean up any PIO interrupts.

This commit is contained in:
root 2021-02-26 22:28:50 -06:00
parent f8eb5bc275
commit 6374408c06
4 changed files with 13 additions and 12 deletions

View File

@ -34,13 +34,3 @@
// Pins aren't actually defined here. They are in the board specific directory // Pins aren't actually defined here. They are in the board specific directory
// such as boards/arduino_zero/pins.c. // such as boards/arduino_zero/pins.c.
// routine to reset both pios
void board_reset_pio() {
for ( uint8_t sm = 0; sm < 4; sm++) {
pio_sm_init (pio0, sm, 0, NULL);
pio_sm_init (pio1, sm, 0, NULL);
}
pio_clear_instruction_memory(pio0);
pio_clear_instruction_memory(pio1);
}

View File

@ -34,6 +34,7 @@
#include "src/rp2_common/hardware_dma/include/hardware/dma.h" #include "src/rp2_common/hardware_dma/include/hardware/dma.h"
#include "src/rp2_common/hardware_pio/include/hardware/pio_instructions.h" #include "src/rp2_common/hardware_pio/include/hardware/pio_instructions.h"
#include "src/rp2040/hardware_structs/include/hardware/structs/iobank0.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 "lib/utils/interrupt_char.h"
#include "py/obj.h" #include "py/obj.h"
@ -101,6 +102,13 @@ void reset_rp2pio_statemachine(void) {
_reset_statemachine(pio, j, false); _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) { STATIC uint32_t _check_pins_free(const mcu_pin_obj_t * first_pin, uint8_t pin_count, bool exclusive_pin_use) {

View File

@ -45,6 +45,10 @@
#include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h"
#endif #endif
#if CIRCUITPY_RP2PIO
#include "bindings/rp2pio/StateMachine.h"
#endif
#if BOARD_I2C #if BOARD_I2C
// Statically allocate the I2C object so it can live past the end of the heap and into the next VM. // Statically allocate the I2C object so it can live past the end of the heap and into the next VM.
// That way it can be used by built-in I2CDisplay displays and be accessible through board.I2C(). // That way it can be used by built-in I2CDisplay displays and be accessible through board.I2C().
@ -181,6 +185,6 @@ void reset_board_busses(void) {
MP_STATE_VM(shared_uart_bus) = NULL; MP_STATE_VM(shared_uart_bus) = NULL;
#endif #endif
#if CIRCUITPY_RP2PIO #if CIRCUITPY_RP2PIO
board_reset_pio(); reset_rp2pio_statemachine();
#endif #endif
} }

View File

@ -28,6 +28,5 @@
#define MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H #define MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H
void reset_board_busses(void); void reset_board_busses(void);
void board_reset_pio(void);
#endif // MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H #endif // MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H