From 3a7d1cfead0d3147425c305d778723a505900d48 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 4 Mar 2022 17:26:21 +0700 Subject: [PATCH] minor cleanup --- examples/host/libusb_api/src/main.c | 10 +++++++--- src/host/usbh.c | 13 +++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/host/libusb_api/src/main.c b/examples/host/libusb_api/src/main.c index 810f8e762..07dae1dc6 100644 --- a/examples/host/libusb_api/src/main.c +++ b/examples/host/libusb_api/src/main.c @@ -40,9 +40,6 @@ //--------------------------------------------------------------------+ void led_blinking_task(void); -extern void cdc_task(void); -extern void hid_app_task(void); - /*------------- MAIN -------------*/ int main(void) { @@ -67,10 +64,17 @@ int main(void) // TinyUSB Callbacks //--------------------------------------------------------------------+ +void print_device_descriptor(uint8_t dev_addr) +{ + printf("Device Descriptor:\r\n"); + +} + // Invoked when device is mounted (configured) void tuh_mount_cb (uint8_t dev_addr) { printf("Device attached, address = %d\r\n", dev_addr); + print_device_descriptor(dev_addr); } /// Invoked when device is unmounted (bus reset/unplugged) diff --git a/src/host/usbh.c b/src/host/usbh.c index a61f40910..d655ee7ca 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -37,11 +37,6 @@ // USBH Configuration //--------------------------------------------------------------------+ -// TODO remove,update -#ifndef CFG_TUH_EP_MAX -#define CFG_TUH_EP_MAX 9 -#endif - #ifndef CFG_TUH_TASK_QUEUE_SZ #define CFG_TUH_TASK_QUEUE_SZ 16 #endif @@ -72,7 +67,7 @@ typedef struct } usbh_dev0_t; typedef struct { - // port + // port, must be same layout as usbh_dev0_t uint8_t rhport; uint8_t hub_addr; uint8_t hub_port; @@ -102,7 +97,7 @@ typedef struct { volatile uint8_t state; // device state, value from enum tusbh_device_state_t uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) - uint8_t ep2drv[CFG_TUH_EP_MAX][2]; // map endpoint to driver ( 0xff is invalid ) + uint8_t ep2drv[CFG_TUH_ENDPOINT_MAX][2]; // map endpoint to driver ( 0xff is invalid ) struct TU_ATTR_PACKED { @@ -111,7 +106,7 @@ typedef struct { volatile bool claimed : 1; // TODO merge ep2drv here, 4-bit should be sufficient - }ep_status[CFG_TUH_EP_MAX][2]; + }ep_status[CFG_TUH_ENDPOINT_MAX][2]; // Mutex for claiming endpoint, only needed when using with preempted RTOS #if CFG_TUSB_OS != OPT_OS_NONE @@ -344,6 +339,8 @@ bool tuh_init(uint8_t rhport) TU_LOG2("USBH init\r\n"); + TU_LOG2_INT(sizeof(usbh_device_t)); + tu_memclr(_usbh_devices, sizeof(_usbh_devices)); tu_memclr(&_dev0, sizeof(_dev0));