summaryrefslogtreecommitdiff
path: root/examples/device/uac2_headset/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-06-06 22:41:04 +0700
committerhathach <[email protected]>2022-06-06 22:41:04 +0700
commit9794a2b865df81e667b464481bb9b1c70587e64b (patch)
tree1efc9a14f8077844357e69e306bd2796d090caf0 /examples/device/uac2_headset/src
parentf4c80dd218240d934a28cb21d8ddd6a0e3a33fe5 (diff)
more example update
Diffstat (limited to 'examples/device/uac2_headset/src')
-rw-r--r--examples/device/uac2_headset/src/main.c3
-rw-r--r--examples/device/uac2_headset/src/tusb_config.h37
2 files changed, 28 insertions, 12 deletions
diff --git a/examples/device/uac2_headset/src/main.c b/examples/device/uac2_headset/src/main.c
index bbaacd975..a8d204eaa 100644
--- a/examples/device/uac2_headset/src/main.c
+++ b/examples/device/uac2_headset/src/main.c
@@ -102,7 +102,8 @@ int main(void)
{
board_init();
- tusb_init();
+ // init device stack on configured roothub port
+ tud_init(BOARD_TUD_RHPORT);
TU_LOG1("Headset running\r\n");
diff --git a/examples/device/uac2_headset/src/tusb_config.h b/examples/device/uac2_headset/src/tusb_config.h
index 2a1189a79..1a3e23e95 100644
--- a/examples/device/uac2_headset/src/tusb_config.h
+++ b/examples/device/uac2_headset/src/tusb_config.h
@@ -31,30 +31,45 @@
extern "C" {
#endif
+#include "usb_descriptors.h"
+
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
+
+// RHPort number used for device can be defined by board.mk, default to port 0
+#ifndef BOARD_TUD_RHPORT
+#define BOARD_TUD_RHPORT 0
+#endif
+
+// RHPort max operational speed can defined by board.mk
+#ifndef BOARD_TUD_MAX_SPEED
+#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
+#endif
+
//--------------------------------------------------------------------
-// COMMON CONFIGURATION
+// Common Configuration
//--------------------------------------------------------------------
-#include "usb_descriptors.h"
-
// defined by compiler flags for flexibility
#ifndef CFG_TUSB_MCU
#error CFG_TUSB_MCU must be defined
#endif
-#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
-
#ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS OPT_OS_NONE
+#define CFG_TUSB_OS OPT_OS_NONE
#endif
#ifndef CFG_TUSB_DEBUG
-// Can be set during compilation i.e.: make LOG=<value for CFG_TUSB_DEBUG> BOARD=<bsp>
-// Keep in mind that enabling logs when data is streaming can disrupt data flow.
-// It can be very helpful though when audio unit requests are tested/debugged.
-#define CFG_TUSB_DEBUG 0
+#define CFG_TUSB_DEBUG 0
#endif
+// Enable Device stack
+#define CFG_TUD_ENABLED 1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
+
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put
* into those specific section.
@@ -67,7 +82,7 @@ extern "C" {
#endif
#ifndef CFG_TUSB_MEM_ALIGN
-#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
+#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
#endif
//--------------------------------------------------------------------