diff --git a/examples/DualRole/CDC/serial_host_bridge/usbh_helper.h b/examples/DualRole/CDC/serial_host_bridge/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/CDC/serial_host_bridge/usbh_helper.h +++ b/examples/DualRole/CDC/serial_host_bridge/usbh_helper.h @@ -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); } diff --git a/examples/DualRole/HID/hid_device_report/usbh_helper.h b/examples/DualRole/HID/hid_device_report/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/HID/hid_device_report/usbh_helper.h +++ b/examples/DualRole/HID/hid_device_report/usbh_helper.h @@ -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); } diff --git a/examples/DualRole/HID/hid_mouse_log_filter/usbh_helper.h b/examples/DualRole/HID/hid_mouse_log_filter/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/HID/hid_mouse_log_filter/usbh_helper.h +++ b/examples/DualRole/HID/hid_mouse_log_filter/usbh_helper.h @@ -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); } diff --git a/examples/DualRole/HID/hid_mouse_tremor_filter/usbh_helper.h b/examples/DualRole/HID/hid_mouse_tremor_filter/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/HID/hid_mouse_tremor_filter/usbh_helper.h +++ b/examples/DualRole/HID/hid_mouse_tremor_filter/usbh_helper.h @@ -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); } diff --git a/examples/DualRole/HID/hid_remapper/usbh_helper.h b/examples/DualRole/HID/hid_remapper/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/HID/hid_remapper/usbh_helper.h +++ b/examples/DualRole/HID/hid_remapper/usbh_helper.h @@ -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); } diff --git a/examples/DualRole/MassStorage/msc_data_logger/usbh_helper.h b/examples/DualRole/MassStorage/msc_data_logger/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/MassStorage/msc_data_logger/usbh_helper.h +++ b/examples/DualRole/MassStorage/msc_data_logger/usbh_helper.h @@ -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); } diff --git a/examples/DualRole/MassStorage/msc_file_explorer/usbh_helper.h b/examples/DualRole/MassStorage/msc_file_explorer/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/MassStorage/msc_file_explorer/usbh_helper.h +++ b/examples/DualRole/MassStorage/msc_file_explorer/usbh_helper.h @@ -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); } diff --git a/examples/DualRole/Simple/device_info/usbh_helper.h b/examples/DualRole/Simple/device_info/usbh_helper.h index fc0cd8ed..29c1a6ac 100644 --- a/examples/DualRole/Simple/device_info/usbh_helper.h +++ b/examples/DualRole/Simple/device_info/usbh_helper.h @@ -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); } diff --git a/examples/MassStorage/msc_external_flash_sdcard/msc_external_flash_sdcard.ino b/examples/MassStorage/msc_external_flash_sdcard/msc_external_flash_sdcard.ino index e61a1635..27eccd02 100644 --- a/examples/MassStorage/msc_external_flash_sdcard/msc_external_flash_sdcard.ino +++ b/examples/MassStorage/msc_external_flash_sdcard/msc_external_flash_sdcard.ino @@ -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 diff --git a/examples/MassStorage/msc_sdfat/msc_sdfat.ino b/examples/MassStorage/msc_sdfat/msc_sdfat.ino index 3045c198..1dd1c541 100644 --- a/examples/MassStorage/msc_sdfat/msc_sdfat.ino +++ b/examples/MassStorage/msc_sdfat/msc_sdfat.ino @@ -35,7 +35,6 @@ #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 @@ -43,6 +42,14 @@ #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 diff --git a/tools/update-usbh_helper.py b/tools/update-usbh_helper.py index c27b47e2..d017d68e 100644 --- a/tools/update-usbh_helper.py +++ b/tools/update-usbh_helper.py @@ -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)