Skip to content

Swap PIO allocation of USB Host for better Pico W compatibility #8922

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

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all 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
8 changes: 4 additions & 4 deletions ports/raspberrypi/common-hal/usb_host/Port.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ usb_host_port_obj_t *common_hal_usb_host_port_construct(const mcu_pin_obj_t *dp,
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
pio_cfg.skip_alarm_pool = true;
pio_cfg.pin_dp = dp->number;
pio_cfg.pio_tx_num = 0;
pio_cfg.pio_rx_num = 1;
// PIO with room for 22 instructions
// PIO with room for 31 instructions and two free SM.
// Allocating the peripherals like this works on Pico W, where the
// "preferred PIO" for the cyw43 wifi chip is PIO 1.
pio_cfg.pio_tx_num = 1; // uses 22 instructions and 1 SM
pio_cfg.pio_rx_num = 0; // uses 31 instructions and 2 SM.
if (!_has_program_room(pio_cfg.pio_tx_num, 22) || _sm_free_count(pio_cfg.pio_tx_num) < 1 ||
!_has_program_room(pio_cfg.pio_rx_num, 31) || _sm_free_count(pio_cfg.pio_rx_num) < 2) {
mp_raise_RuntimeError(MP_ERROR_TEXT("All state machines in use"));
Expand Down