From 7eb2bcaaaef1729a765ec05aca8bb431e847baf2 Mon Sep 17 00:00:00 2001 From: Elizabeth Cray Date: Thu, 24 Jul 2025 19:58:49 -0400 Subject: [PATCH] Revert Project --- .gitmodules | 6 ------ CMakeLists.txt | 9 --------- README.md | 13 +++++++++++-- libs/Pico-PIO-USB | 1 - libs/pico-sdk | 1 - src/CMakeLists.txt | 31 +++++++++++++++++++++++++++---- src/config.h | 6 ++++++ src/hirsute.c | 25 ++++++++++++++++++------- src/tusb_config.h | 44 +++++++++++++++++++++++++++++++++----------- 9 files changed, 95 insertions(+), 41 deletions(-) delete mode 100644 CMakeLists.txt delete mode 160000 libs/Pico-PIO-USB delete mode 160000 libs/pico-sdk create mode 100644 src/config.h diff --git a/.gitmodules b/.gitmodules index f077854..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "libs/Pico-PIO-USB"] - path = libs/Pico-PIO-USB - url = https://github.com/sekigon-gonnoc/Pico-PIO-USB -[submodule "libs/pico-sdk"] - path = libs/pico-sdk - url = https://github.com/raspberrypi/pico-sdk diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 5e0c584..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.13) -set(PICO_SDK_PATH "${CMAKE_CURRENT_LIST_DIR}/libs/pico-sdk") -include ("${CMAKE_CURRENT_LIST_DIR}/libs/pico-sdk/external/pico_sdk_import.cmake") -project(hirsute) -pico_sdk_init() -set(PICO_PIO_USB_DIR "${CMAKE_CURRENT_LIST_DIR}/libs/Pico-PIO-USB") -add_subdirectory(${PICO_PIO_USB_DIR} pico_pio_usb) - -add_subdirectory(src) \ No newline at end of file diff --git a/README.md b/README.md index 6295524..ecc71c6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ### System Package Requirements -`cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib picotool` +`cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib picotool pioasm` ### Build Instructions @@ -18,4 +18,13 @@ mkdir build cd build cmake .. make -``` \ No newline at end of file +``` + +## Many Thanks + +These projects were crazy helpful in figuring out how to put this together. + +* [Pico Read USB Keyboard PIO](https://github.com/vruivo/pico_read_usb_keyboard_pio) +* [Pico-PIO-USB](https://github.com/sekigon-gonnoc/Pico-PIO-USB) +* [PS2 2 Plus](https://github.com/n055/ps22plus) +* [Macintosh Hardware Description](https://ia601206.us.archive.org/20/items/Mac_Hardware_Info_Mac_128K/Mac_Hardware_Info_Mac_128K.pdf) \ No newline at end of file diff --git a/libs/Pico-PIO-USB b/libs/Pico-PIO-USB deleted file mode 160000 index 3c1eec3..0000000 --- a/libs/Pico-PIO-USB +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3c1eec341a5232640e4c00628b889b641af34b28 diff --git a/libs/pico-sdk b/libs/pico-sdk deleted file mode 160000 index 9a4113f..0000000 --- a/libs/pico-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9a4113fbbae65ee82d8cd6537963bc3d3b14bcca diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 46909b2..5e55cfe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,17 +1,40 @@ +cmake_minimum_required(VERSION 3.13) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +set(PICO_SDK_PATH "${CMAKE_CURRENT_LIST_DIR}/../libs/pico-sdk") +include("${PICO_SDK_PATH}/external/pico_sdk_import.cmake") + +set(PICO_PIO_USB_DIR "${CMAKE_CURRENT_LIST_DIR}/../libs/pico-pio-hirsute") +add_subdirectory(${PICO_PIO_USB_DIR} pico_pio_usb) + set(target_name hirsute) -add_executable(${target_name}) + +project(${target_name} C CXX ASM) + +add_executable(${target_name} + hirsute.c + ) target_sources(${target_name} PRIVATE hirsute.c - ${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c - ${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c + ${PICO_SDK_PATH}/lib/tinyusb/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c + ${PICO_SDK_PATH}/lib/tinyusb/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c ) +pico_sdk_init() + +pico_enable_stdio_usb(${target_name} 0) +pico_enable_stdio_uart(${target_name} 1) + target_link_options(${target_name} PRIVATE -Xlinker --print-memory-usage) target_compile_options(${target_name} PRIVATE -Wall -Wextra) target_compile_definitions(${target_name} PRIVATE PIO_USB_USE_TINYUSB) target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries(${target_name} PRIVATE pico_stdlib pico_pio_usb tinyusb_device tinyusb_host) +target_link_libraries(${target_name} PRIVATE pico_stdlib pico_multicore pico_pio_usb tinyusb_host tinyusb_board) + +# Generate hex file pico_add_extra_outputs(${target_name}) diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..b3bea41 --- /dev/null +++ b/src/config.h @@ -0,0 +1,6 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#define BAUD_RATE 115200 + +#endif // CONFIG_H diff --git a/src/hirsute.c b/src/hirsute.c index 199778e..71ab81f 100644 --- a/src/hirsute.c +++ b/src/hirsute.c @@ -16,17 +16,22 @@ #include #include -#include "hardware/clocks.h" #include "pico/stdlib.h" #include "pico/multicore.h" #include "pico/bootrom.h" - #include "pio_usb.h" #include "tusb.h" +#include "bsp/board.h" +#include "hardware/uart.h" +#include "hardware/clocks.h" + +#include "config.h" + void core_one() { sleep_ms(10); pio_usb_configuration_t pio_config = PIO_USB_DEFAULT_CONFIG; + pio_config.pin_dp = 16; // USB D+ pin on GP16 tuh_configure(1, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_config); tuh_init(1); while (true) { @@ -35,14 +40,20 @@ void core_one() { } int main() { + board_init(); set_sys_clock_khz(120000, true); + uart_init(UART_ID, BAUD_RATE); + gpio_set_function(UART_TX_PIN, GPIO_FUNC_UART); + gpio_set_function(UART_RX_PIN, GPIO_FUNC_UART); sleep_ms(10); multicore_reset_core1(); - + multicore_launch_core1(core_one); + board_led_write(true); + while (true) { - tud_task(); - tud_cdc_write_flush(); + stdio_flush(); + sleep_us(10); } - + return 0; -} \ No newline at end of file +} diff --git a/src/tusb_config.h b/src/tusb_config.h index 1361296..716b9be 100644 --- a/src/tusb_config.h +++ b/src/tusb_config.h @@ -30,6 +30,28 @@ extern "C" { #endif +//--------------------------------------------------------------------+ +// Board Specific Configuration +//--------------------------------------------------------------------+ +#ifndef CFG_TUSB_MCU +#define CFG_TUSB_MCU OPT_MCU_RP2040 +#endif +#if CFG_TUSB_MCU == OPT_MCU_RP2040 +// change to 1 if using pico-pio-usb as host controller for raspberry rp2040 +#define CFG_TUH_RPI_PIO_USB 1 +#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB +#endif + +// RHPort number used for host can be defined by board.mk, default to port 0 +#ifndef BOARD_TUH_RHPORT +#define BOARD_TUH_RHPORT 0 +#endif + +// RHPort max operational speed can defined by board.mk +#ifndef BOARD_TUH_MAX_SPEED +#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED +#endif + //-------------------------------------------------------------------- // COMMON CONFIGURATION //-------------------------------------------------------------------- @@ -37,7 +59,7 @@ #define CFG_TUSB_OS OPT_OS_PICO // Enable device stack -#define CFG_TUD_ENABLED 1 +// #define CFG_TUD_ENABLED 1 // Enable host stack with pio-usb if Pico-PIO-USB library is available #define CFG_TUH_ENABLED 1 @@ -65,19 +87,19 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDPOINT0_SIZE -#define CFG_TUD_ENDPOINT0_SIZE 64 -#endif +// #ifndef CFG_TUD_ENDPOINT0_SIZE +// #define CFG_TUD_ENDPOINT0_SIZE 64 +// #endif -//------------- CLASS -------------// -#define CFG_TUD_CDC 1 +// //------------- CLASS -------------// +// #define CFG_TUD_CDC 1 -// CDC FIFO size of TX and RX -#define CFG_TUD_CDC_RX_BUFSIZE 256 -#define CFG_TUD_CDC_TX_BUFSIZE 256 +// // CDC FIFO size of TX and RX +// #define CFG_TUD_CDC_RX_BUFSIZE 256 +// #define CFG_TUD_CDC_TX_BUFSIZE 256 -// CDC Endpoint transfer buffer size, more is faster -#define CFG_TUD_CDC_EP_BUFSIZE 64 +// // CDC Endpoint transfer buffer size, more is faster +// #define CFG_TUD_CDC_EP_BUFSIZE 64 //-------------------------------------------------------------------- // HOST CONFIGURATION