summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-04-08 13:36:05 +0700
committerhathach <[email protected]>2022-04-08 13:36:05 +0700
commitd5d4909c20f581ef2046932191f487c001d59ca3 (patch)
tree1a9e0023c867554886edc12bd694000ca9d937e4
parentd97c1546957059cfb3063b95d5287e2729f7f79a (diff)
proof of concpet that device pio-usb work with host pio-usb
-rw-r--r--examples/device/hid_boot_interface/src/main.c4
-rw-r--r--examples/device/hid_boot_interface/src/tusb_config.h3
-rw-r--r--examples/host/cdc_msc_hid/src/tusb_config.h1
-rw-r--r--hw/bsp/rp2040/family.cmake32
-rw-r--r--src/portable/raspberrypi/rp2040/dcd_rp2040.c2
-rw-r--r--src/tusb_option.h6
6 files changed, 27 insertions, 21 deletions
diff --git a/examples/device/hid_boot_interface/src/main.c b/examples/device/hid_boot_interface/src/main.c
index e5e2f6856..ed7f235b7 100644
--- a/examples/device/hid_boot_interface/src/main.c
+++ b/examples/device/hid_boot_interface/src/main.c
@@ -31,6 +31,8 @@
#include "tusb.h"
#include "usb_descriptors.h"
+#include "pio_usb.h"
+
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+
@@ -59,6 +61,8 @@ int main(void)
while (1)
{
+ pio_usb_device_task();
+
tud_task(); // tinyusb device task
led_blinking_task();
diff --git a/examples/device/hid_boot_interface/src/tusb_config.h b/examples/device/hid_boot_interface/src/tusb_config.h
index 1c8fa40b2..d4f67e7ba 100644
--- a/examples/device/hid_boot_interface/src/tusb_config.h
+++ b/examples/device/hid_boot_interface/src/tusb_config.h
@@ -39,6 +39,9 @@
#error CFG_TUSB_MCU must be defined
#endif
+// Use raspberry pio-usb for device
+#define CFG_TUD_RPI_PIO_USB 1
+
// RHPort number used for device can be defined by board.mk, default to port 0
#ifndef BOARD_DEVICE_RHPORT_NUM
#define BOARD_DEVICE_RHPORT_NUM 0
diff --git a/examples/host/cdc_msc_hid/src/tusb_config.h b/examples/host/cdc_msc_hid/src/tusb_config.h
index 80ee8cb01..9d083c771 100644
--- a/examples/host/cdc_msc_hid/src/tusb_config.h
+++ b/examples/host/cdc_msc_hid/src/tusb_config.h
@@ -39,6 +39,7 @@
#error CFG_TUSB_MCU must be defined
#endif
+// Use raspberry pio-usb for host
#define CFG_TUH_RPI_PIO_USB 1
//#define CFG_TUSB_RPI_PIO_INC_PATH 1
diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake
index 275ec9e6b..b186fc78e 100644
--- a/hw/bsp/rp2040/family.cmake
+++ b/hw/bsp/rp2040/family.cmake
@@ -29,12 +29,17 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
target_sources(tinyusb_common_base INTERFACE
${TOP}/src/tusb.c
${TOP}/src/common/tusb_fifo.c
+ ${TOP}/lib/Pico-PIO-USB/pio_usb.c
+ ${TOP}/lib/Pico-PIO-USB/pio_usb_host.c
+ ${TOP}/lib/Pico-PIO-USB/pio_usb_hw.c
+ ${TOP}/lib/Pico-PIO-USB/usb_crc.c
)
target_include_directories(tinyusb_common_base INTERFACE
${TOP}/src
${TOP}/src/common
${TOP}/hw
+ ${TOP}/lib/Pico-PIO-USB
)
target_link_libraries(tinyusb_common_base INTERFACE
@@ -42,6 +47,10 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
hardware_irq
hardware_resets
pico_sync
+ # for usb-pio
+ hardware_dma
+ hardware_pio
+ pico_multicore
)
set(TINYUSB_DEBUG_LEVEL 0)
@@ -60,6 +69,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
add_library(tinyusb_device_base INTERFACE)
target_sources(tinyusb_device_base INTERFACE
${TOP}/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+ ${TOP}/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c
${TOP}/src/portable/raspberrypi/rp2040/rp2040_usb.c
${TOP}/src/device/usbd.c
${TOP}/src/device/usbd_control.c
@@ -88,12 +98,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
${TOP}/src/class/hid/hid_host.c
${TOP}/src/class/msc/msc_host.c
${TOP}/src/class/vendor/vendor_host.c
-
- ${TOP}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
- ${TOP}/lib/Pico-PIO-USB/pio_usb.c
- ${TOP}/lib/Pico-PIO-USB/pio_usb_host.c
- ${TOP}/lib/Pico-PIO-USB/pio_usb_hw.c
- ${TOP}/lib/Pico-PIO-USB/usb_crc.c
+ ${TOP}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
)
# Sometimes have to do host specific actions in mostly common functions
@@ -101,17 +106,6 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
RP2040_USB_HOST_MODE=1
)
- # config for host pio
- target_link_libraries(tinyusb_host_base INTERFACE
- hardware_dma
- hardware_pio
- pico_multicore
- )
-
- target_include_directories(tinyusb_host_base INTERFACE
- ${TOP}/lib/Pico-PIO-USB
- )
-
add_library(tinyusb_bsp INTERFACE)
target_sources(tinyusb_bsp INTERFACE
${TOP}/hw/bsp/rp2040/family.c
@@ -166,8 +160,8 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
_family_initialize_project(${PROJECT} ${DIR})
enable_language(C CXX ASM)
pico_sdk_init()
- pico_generate_pio_header(tinyusb_host_base ${TOP}/lib/Pico-PIO-USB/usb_tx.pio)
- pico_generate_pio_header(tinyusb_host_base ${TOP}/lib/Pico-PIO-USB/usb_rx.pio)
+ pico_generate_pio_header(tinyusb_common_base ${TOP}/lib/Pico-PIO-USB/usb_tx.pio)
+ pico_generate_pio_header(tinyusb_common_base ${TOP}/lib/Pico-PIO-USB/usb_rx.pio)
endfunction()
# This method must be called from the project scope to suppress known warnings in TinyUSB source files
diff --git a/src/portable/raspberrypi/rp2040/dcd_rp2040.c b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
index 915822798..2d77ad4f9 100644
--- a/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
@@ -26,7 +26,7 @@
#include "tusb_option.h"
-#if CFG_TUD_ENABLED && CFG_TUSB_MCU == OPT_MCU_RP2040
+#if CFG_TUD_ENABLED && (CFG_TUSB_MCU == OPT_MCU_RP2040) && !CFG_TUD_RPI_PIO_USB
#include "pico.h"
#include "rp2040_usb.h"
diff --git a/src/tusb_option.h b/src/tusb_option.h
index 61cc283c4..5636b34fe 100644
--- a/src/tusb_option.h
+++ b/src/tusb_option.h
@@ -239,7 +239,7 @@
#define TUH_OPT_RHPORT -1
#endif
-#define CFG_TUH_ENABLED ( TUH_RHPORT_MODE & OPT_MODE_HOST )
+#define CFG_TUH_ENABLED (TUH_RHPORT_MODE & OPT_MODE_HOST)
// For backward compatible
#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED
@@ -398,6 +398,10 @@
#define CFG_TUH_RPI_PIO_USB 0
#endif
+#ifndef CFG_TUD_RPI_PIO_USB
+#define CFG_TUD_RPI_PIO_USB 0
+#endif
+
//------------------------------------------------------------------
// Configuration Validation