summaryrefslogtreecommitdiff
path: root/examples/host/hid_controller/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-06-06 23:16:49 +0700
committerhathach <[email protected]>2022-06-06 23:16:49 +0700
commit7c8278303bc14770ea9fcd9f6e4a9dbba32572e3 (patch)
treedddfac5e4042638632d7187835733cde2a911029 /examples/host/hid_controller/src
parent9794a2b865df81e667b464481bb9b1c70587e64b (diff)
update all host examples
Diffstat (limited to 'examples/host/hid_controller/src')
-rw-r--r--examples/host/hid_controller/src/main.c5
-rw-r--r--examples/host/hid_controller/src/tusb_config.h33
2 files changed, 27 insertions, 11 deletions
diff --git a/examples/host/hid_controller/src/main.c b/examples/host/hid_controller/src/main.c
index b9b37a4d2..299a3ff10 100644
--- a/examples/host/hid_controller/src/main.c
+++ b/examples/host/hid_controller/src/main.c
@@ -49,9 +49,10 @@ int main(void)
board_init();
printf("TinyUSB Host HID Controller Example\r\n");
- printf("Note: Events only displayed for explictly supported controllers\r\n");
+ printf("Note: Events only displayed for explicit supported controllers\r\n");
- tusb_init();
+ // init host stack on configured roothub port
+ tuh_init(BOARD_TUH_RHPORT);
while (1)
{
diff --git a/examples/host/hid_controller/src/tusb_config.h b/examples/host/hid_controller/src/tusb_config.h
index 74b471ae4..475b9ca8f 100644
--- a/examples/host/hid_controller/src/tusb_config.h
+++ b/examples/host/hid_controller/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