diff options
| author | Wayne <[email protected]> | 2022-09-23 11:23:28 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-09-22 23:23:28 -0400 |
| commit | dc9887913beb788a24f95c1b77483d5a50bea3f0 (patch) | |
| tree | abce22ce58274c93445eaefdaddcc69498e06ae8 | |
| parent | c38259d336852ddcc438e8d8540d438952b6a3cf (diff) | |
[usbhost] List keyboard option. (#6456)
* [bsp/nuvoton] Support NuMaker-M467HJ BSP and update drivers.
* Format files.
* [usbhost] List keyboard and update driver.
* Enlarge to reasonable thread stack size.
* Do indent..
* Keep private.
Co-authored-by: Wayne Lin <[email protected]>
| -rwxr-xr-x | components/drivers/Kconfig | 11 | ||||
| -rw-r--r-- | components/drivers/usb/usbhost/class/ukbd.c | 25 | ||||
| -rw-r--r-- | components/drivers/usb/usbhost/class/umouse.c | 6 | ||||
| -rw-r--r-- | components/drivers/usb/usbhost/core/usbhost.c | 14 |
4 files changed, 44 insertions, 12 deletions
diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig index 00c4a07998..481d9c68c1 100755 --- a/components/drivers/Kconfig +++ b/components/drivers/Kconfig @@ -682,16 +682,19 @@ menu "Using USB" default n if RT_USBH_MSTORAGE config UDISK_MOUNTPOINT - string "Udisk mount dir" - default "/" + string "Udisk mount dir" + default "/" endif config RT_USBH_HID bool "Enable HID Drivers" default n if RT_USBH_HID config RT_USBH_HID_MOUSE - bool "Enable HID mouse protocol" - default n + bool "Enable HID mouse protocol" + default n + config RT_USBH_HID_KEYBOARD + bool "Enable HID keyboard protocol" + default n endif endif config RT_USING_USB_DEVICE diff --git a/components/drivers/usb/usbhost/class/ukbd.c b/components/drivers/usb/usbhost/class/ukbd.c index c89d60cd36..313e62e0f3 100644 --- a/components/drivers/usb/usbhost/class/ukbd.c +++ b/components/drivers/usb/usbhost/class/ukbd.c @@ -34,9 +34,27 @@ static rt_err_t rt_usbh_hid_kbd_callback(void* arg) return RT_EOK; } +static rt_thread_t kbd_thread; +static void kbd_task(void* param) +{ + struct uhintf* intf = (struct uhintf*)param; + while (1) + { + if (rt_usb_hcd_pipe_xfer(intf->device->hcd, ((struct uhid*)intf->user_data)->pipe_in, + ((struct uhid*)intf->user_data)->buffer, ((struct uhid*)intf->user_data)->pipe_in->ep.wMaxPacketSize, + USB_TIMEOUT_BASIC) == 0) + { + break; + } + + rt_usbh_hid_kbd_callback(intf->user_data); + } +} + + static rt_err_t rt_usbh_hid_kbd_init(void* arg) { - struct uintf* intf = (struct uintf*)arg; + struct uhintf* intf = (struct uhintf*)arg; RT_ASSERT(intf != RT_NULL); @@ -44,7 +62,10 @@ static rt_err_t rt_usbh_hid_kbd_init(void* arg) rt_usbh_hid_set_idle(intf, 10, 0); - //RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb keyboard\n")); + RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb keyboard\n")); + + kbd_thread = rt_thread_create("kbd0", kbd_task, intf, 1024, 8, 100); + rt_thread_startup(kbd_thread); return RT_EOK; } diff --git a/components/drivers/usb/usbhost/class/umouse.c b/components/drivers/usb/usbhost/class/umouse.c index ae14cba22c..fdf69c8f16 100644 --- a/components/drivers/usb/usbhost/class/umouse.c +++ b/components/drivers/usb/usbhost/class/umouse.c @@ -126,8 +126,8 @@ static rt_err_t rt_usbh_hid_mouse_callback(void* arg) return RT_EOK; } -rt_thread_t mouse_thread; -void mouse_task(void* param) +static rt_thread_t mouse_thread; +static void mouse_task(void* param) { struct uhintf* intf = (struct uhintf*)param; while (1) @@ -154,7 +154,7 @@ static rt_err_t rt_usbh_hid_mouse_init(void* arg) rt_usbh_hid_set_idle(intf, 0, 0); - mouse_thread = rt_thread_create("mouse0", mouse_task, intf, 500, 8, 100); + mouse_thread = rt_thread_create("mouse0", mouse_task, intf, 1024, 8, 100); rt_thread_startup(mouse_thread); RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb mouse\n")); diff --git a/components/drivers/usb/usbhost/core/usbhost.c b/components/drivers/usb/usbhost/core/usbhost.c index 9a4c166acd..455c30cc70 100644 --- a/components/drivers/usb/usbhost/core/usbhost.c +++ b/components/drivers/usb/usbhost/core/usbhost.c @@ -47,13 +47,21 @@ rt_err_t rt_usb_host_init(const char *name) rt_usbh_class_driver_register(drv); #endif #ifdef RT_USBH_HID + extern ucd_t rt_usbh_class_driver_hid(void); /* register mass storage class driver */ drv = rt_usbh_class_driver_hid(); rt_usbh_class_driver_register(drv); #ifdef RT_USBH_HID_MOUSE - uprotocal_t protocal; - protocal = rt_usbh_hid_protocal_mouse(); - rt_usbh_hid_protocal_register(protocal); + { + extern uprotocal_t rt_usbh_hid_protocal_mouse(void); + rt_usbh_hid_protocal_register(rt_usbh_hid_protocal_mouse()); + } +#endif +#ifdef RT_USBH_HID_KEYBOARD + { + extern uprotocal_t rt_usbh_hid_protocal_kbd(void); + rt_usbh_hid_protocal_register(rt_usbh_hid_protocal_kbd()); + } #endif #endif |
