summaryrefslogtreecommitdiff
path: root/examples/host/bare_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/host/bare_api/src')
-rw-r--r--examples/host/bare_api/src/main.c6
-rw-r--r--examples/host/bare_api/src/tusb_config.h33
2 files changed, 28 insertions, 11 deletions
diff --git a/examples/host/bare_api/src/main.c b/examples/host/bare_api/src/main.c
index eb3f7d8d7..2cc05d34d 100644
--- a/examples/host/bare_api/src/main.c
+++ b/examples/host/bare_api/src/main.c
@@ -62,8 +62,10 @@ int main(void)
{
board_init();
- printf("TinyUSB Host HID Controller Example\r\n");
- tusb_init();
+ printf("TinyUSB Bare API Example\r\n");
+
+ // init host stack on configured roothub port
+ tuh_init(BOARD_TUH_RHPORT);
while (1)
{
diff --git a/examples/host/bare_api/src/tusb_config.h b/examples/host/bare_api/src/tusb_config.h
index 9b789290d..ed0aaf7da 100644
--- a/examples/host/bare_api/src/tusb_config.h
+++ b/examples/host/bare_api/src/tusb_config.h
@@ -30,27 +30,42 @@
extern "C" {
#endif
+//--------------------------------------------------------------------+
+// Board Specific Configuration
+//--------------------------------------------------------------------+
+
+// 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
//--------------------------------------------------------------------
// defined by compiler flags for flexibility
#ifndef CFG_TUSB_MCU
- #error CFG_TUSB_MCU must be defined
+#error CFG_TUSB_MCU must be defined
#endif
-#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX
- #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST | OPT_MODE_HIGH_SPEED)
-#else
- #define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST
+#ifndef CFG_TUSB_OS
+#define CFG_TUSB_OS OPT_OS_NONE
#endif
-#ifndef CFG_TUSB_OS
-#define CFG_TUSB_OS OPT_OS_NONE
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG 0
#endif
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG 0
+// Enable Host stack
+#define CFG_TUH_ENABLED 1
+
+// Default is max speed that hardware controller could support with on-chip PHY
+#define CFG_TUH_MAX_SPEED BOARD_TUH_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