Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear out PIOs and State Machines on RP2040 soft reset #4265

Merged
merged 6 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ports/raspberrypi/common-hal/board/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "common-hal/microcontroller/Pin.h"
#include "src/rp2_common/hardware_pio/include/hardware/pio.h"
#include "shared-module/board/__init__.h"

// Pins aren't actually defined here. They are in the board specific directory
// 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);
}
4 changes: 4 additions & 0 deletions shared-module/board/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "supervisor/shared/translate.h"
#include "mpconfigboard.h"
#include "py/runtime.h"
#include "shared-module/board/__init__.h"

#if CIRCUITPY_BUSIO
#include "shared-bindings/busio/I2C.h"
Expand Down Expand Up @@ -179,4 +180,7 @@ void reset_board_busses(void) {
#if BOARD_UART
MP_STATE_VM(shared_uart_bus) = NULL;
#endif
#if CIRCUITPY_RP2PIO
board_reset_pio();
#endif
}
1 change: 1 addition & 0 deletions shared-module/board/__init__.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
#define MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H

void reset_board_busses(void);
void board_reset_pio(void);

#endif // MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H