Skip to content

Update example #536

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 2 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
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 examples/DualRole/CDC/serial_host_bridge/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/DualRole/HID/hid_device_report/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/DualRole/HID/hid_mouse_log_filter/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/DualRole/HID/hid_mouse_tremor_filter/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/DualRole/HID/hid_remapper/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/DualRole/MassStorage/msc_data_logger/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/DualRole/MassStorage/msc_file_explorer/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/DualRole/Simple/device_info/usbh_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void rp2040_configure_pio_usb(void) {
//while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");

// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
// Check for CPU frequency, must be multiple of 12 Mhz for bit-banging USB
uint32_t cpu_hz = clock_get_hz(clk_sys);
if (cpu_hz != 120000000UL && cpu_hz != 240000000UL) {
if (cpu_hz % 12000000UL) {
while (!Serial) {
delay(10); // wait for native usb
}
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 12 Mhz\r\n", cpu_hz);
Serial.printf("Change your CPU Clock to 12*n Mhz in Menu->CPU Speed \r\n");
while (1) {
delay(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ Adafruit_SPIFlash flash(&flashTransport);
#define SDCARD_DETECT 40
#define SDCARD_DETECT_ACTIVE LOW

#elif defined(ARDUINO_ADAFRUIT_FRUITJAM_RP2350)
#define SDIO_CLK_PIN 34
#define SDIO_CMD_PIN 35 // MOSI
#define SDIO_DAT0_PIN 36 // DAT1: 37, DAT2: 38, DAT3: 39

#define SDCARD_DETECT 33
#define SDCARD_DETECT_ACTIVE LOW

#else
// Use SPI, no detect
#define SDCARD_CS 10
Expand Down
9 changes: 8 additions & 1 deletion examples/MassStorage/msc_sdfat/msc_sdfat.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@
#define SDCARD_DETECT_ACTIVE LOW

#elif defined(ARDUINO_ADAFRUIT_METRO_RP2350)
// Note: not working yet (need troubleshoot later)
#define SDIO_CLK_PIN 34
#define SDIO_CMD_PIN 35 // MOSI
#define SDIO_DAT0_PIN 36 // DAT1: 37, DAT2: 38, DAT3: 39

#define SDCARD_DETECT 40
#define SDCARD_DETECT_ACTIVE LOW

#elif defined(ARDUINO_ADAFRUIT_FRUITJAM_RP2350)
#define SDIO_CLK_PIN 34
#define SDIO_CMD_PIN 35 // MOSI
#define SDIO_DAT0_PIN 36 // DAT1: 37, DAT2: 38, DAT3: 39

#define SDCARD_DETECT 33
#define SDCARD_DETECT_ACTIVE LOW

#else
// Use SPI, no detect
#define SDCARD_CS 10
Expand Down
23 changes: 12 additions & 11 deletions tools/update-usbh_helper.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
from pathlib import Path
import click
import argparse
import sys
import shutil

@click.command()
@click.argument('dir', type=click.Path(), required=True)
def main(dir):
def main():
"""
This script takes a mandatory 'dir' argument, which is a path to pivot example to update for all DualRole's examples
"""
sample_dir = Path(dir)
parser = argparse.ArgumentParser()
parser.add_argument('dpath', help='path to folder containing usbh_helper.h to copy from')
args = parser.parse_args()

dpath = args.dpath

sample_dir = Path(dpath)
if not sample_dir.is_dir():
# add examples/DualRoles to the path
sample_dir = Path('examples/DualRole') / sample_dir
if not sample_dir.is_dir():
click.echo(f"The specified dir '{dir}' does not exist or is not a valid dir.")
sys.exit(1)
print(f"The specified dir '{dir}' does not exist or is not a valid dir.")
sys.exit(1)

sample_file = sample_dir / 'usbh_helper.h'
f_list = sorted(Path('examples/DualRole').glob('**/usbh_helper.h'))
for f in f_list:
if f != sample_file:
click.echo(f"Updating {f}")
print(f"Updating {f}")
shutil.copy(sample_file, f)


Expand Down