Quellcode durchsuchen

proof of concpet that device pio-usb work with host pio-usb

hathach vor 3 Jahren
Ursprung
Commit
d5d4909c20

+ 4 - 0
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();
 

+ 3 - 0
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

+ 1 - 0
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
 

+ 13 - 19
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

+ 1 - 1
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"

+ 5 - 1
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