summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-02-23 09:41:27 +0800
committerGitHub <[email protected]>2021-02-23 09:41:27 +0800
commitd9c3459e1108ab4111ead3b0c8d92cb0d8318bc9 (patch)
tree8bd579512f93660a0df73af473ec9a95eaee0a43 /components
parent6d3847b6bd3407172f7fdeb16d477260f7caaefa (diff)
parentb51c6339f0f16e5780482b32d020db4f18642e0f (diff)
Merge pull request #4295 from LeeChunHei/test_branch
添加imxrt的pulse encoder和usb host驅動
Diffstat (limited to 'components')
-rwxr-xr-xcomponents/drivers/Kconfig8
-rw-r--r--components/drivers/include/drivers/usb_host.h7
-rw-r--r--components/drivers/pm/debug.log0
-rw-r--r--components/drivers/usb/usbhost/class/hid.c130
-rw-r--r--components/drivers/usb/usbhost/class/hid.h10
-rw-r--r--components/drivers/usb/usbhost/class/umouse.c25
-rw-r--r--components/drivers/usb/usbhost/core/driver.c15
-rw-r--r--components/drivers/usb/usbhost/core/hub.c30
-rw-r--r--components/drivers/usb/usbhost/core/usbhost.c16
9 files changed, 151 insertions, 90 deletions
diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig
index 006497519f..b0caabc73c 100755
--- a/components/drivers/Kconfig
+++ b/components/drivers/Kconfig
@@ -642,6 +642,14 @@ menu "Using USB"
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
+ endif
endif
config RT_USING_USB_DEVICE
bool "Using USB device"
diff --git a/components/drivers/include/drivers/usb_host.h b/components/drivers/include/drivers/usb_host.h
index 2a68f4edb5..bd73c7d1d7 100644
--- a/components/drivers/include/drivers/usb_host.h
+++ b/components/drivers/include/drivers/usb_host.h
@@ -136,7 +136,8 @@ struct uhcd
struct rt_device parent;
uhcd_ops_t ops;
rt_uint8_t num_ports;
- uhub_t roothub;
+ uhub_t roothub;
+ struct rt_messagequeue *usb_mq;
};
typedef struct uhcd* uhcd_t;
@@ -163,7 +164,7 @@ struct uhost_msg
typedef struct uhost_msg* uhost_msg_t;
/* usb host system interface */
-rt_err_t rt_usb_host_init(void);
+rt_err_t rt_usb_host_init(const char *name);
void rt_usbh_hub_init(struct uhcd *hcd);
/* usb host core interface */
@@ -203,7 +204,7 @@ rt_err_t rt_usbh_hub_clear_port_feature(uhub_t uhub, rt_uint16_t port,
rt_err_t rt_usbh_hub_set_port_feature(uhub_t uhub, rt_uint16_t port,
rt_uint16_t feature);
rt_err_t rt_usbh_hub_reset_port(uhub_t uhub, rt_uint16_t port);
-rt_err_t rt_usbh_event_signal(struct uhost_msg* msg);
+rt_err_t rt_usbh_event_signal(uhcd_t uhcd, struct uhost_msg* msg);
void rt_usbh_root_hub_connect_handler(struct uhcd *hcd, rt_uint8_t port, rt_bool_t isHS);
diff --git a/components/drivers/pm/debug.log b/components/drivers/pm/debug.log
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/components/drivers/pm/debug.log
diff --git a/components/drivers/usb/usbhost/class/hid.c b/components/drivers/usb/usbhost/class/hid.c
index e16096877f..1abc82184f 100644
--- a/components/drivers/usb/usbhost/class/hid.c
+++ b/components/drivers/usb/usbhost/class/hid.c
@@ -26,7 +26,7 @@ static rt_list_t _protocal_list;
*
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_hid_set_idle(struct uintf* intf, int duration, int report_id)
+rt_err_t rt_usbh_hid_set_idle(struct uhintf* intf, int duration, int report_id)
{
struct urequest setup;
struct uinstance* device;
@@ -40,14 +40,15 @@ rt_err_t rt_usbh_hid_set_idle(struct uintf* intf, int duration, int report_id)
setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_INTERFACE;
- setup.request = USB_REQ_SET_IDLE;
- setup.index = 0;
- setup.length = 0;
- setup.value = (duration << 8 )| report_id;
+ setup.bRequest = USB_REQ_SET_IDLE;
+ setup.wIndex = 0;
+ setup.wLength = 0;
+ setup.wValue = (duration << 8 )| report_id;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, RT_NULL, 0,
- timeout) == 0) return RT_EOK;
- else return -RT_FALSE;
+ if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8)
+ return RT_EOK;
+ else
+ return -RT_FALSE;
}
/**
@@ -59,7 +60,7 @@ rt_err_t rt_usbh_hid_set_idle(struct uintf* intf, int duration, int report_id)
*
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_hid_get_report(struct uintf* intf, rt_uint8_t type,
+rt_err_t rt_usbh_hid_get_report(struct uhintf* intf, rt_uint8_t type,
rt_uint8_t id, rt_uint8_t *buffer, rt_size_t size)
{
struct urequest setup;
@@ -74,14 +75,24 @@ rt_err_t rt_usbh_hid_get_report(struct uintf* intf, rt_uint8_t type,
setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_INTERFACE;
- setup.request = USB_REQ_GET_REPORT;
- setup.index = intf->intf_desc->bInterfaceNumber;
- setup.length = size;
- setup.value = (type << 8 ) + id;
+ setup.bRequest = USB_REQ_GET_REPORT;
+ setup.wIndex = intf->intf_desc->bInterfaceNumber;
+ setup.wLength = size;
+ setup.wValue = (type << 8 ) + id;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
- timeout) == size) return RT_EOK;
- else return -RT_FALSE;
+ if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8)
+ {
+ if (rt_usb_hcd_pipe_xfer(device->hcd, device->pipe_ep0_in, buffer, size, timeout) == size)
+ {
+ if (rt_usb_hcd_pipe_xfer(device->hcd, device->pipe_ep0_out, RT_NULL, 0, timeout) == 0)
+ {
+ return RT_EOK;
+ }
+ }
+ }
+ else
+ return -RT_FALSE;
+ return -RT_FALSE;
}
/**
@@ -93,7 +104,7 @@ rt_err_t rt_usbh_hid_get_report(struct uintf* intf, rt_uint8_t type,
*
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_hid_set_report(struct uintf* intf, rt_uint8_t *buffer, rt_size_t size)
+rt_err_t rt_usbh_hid_set_report(struct uhintf* intf, rt_uint8_t *buffer, rt_size_t size)
{
struct urequest setup;
struct uinstance* device;
@@ -107,14 +118,15 @@ rt_err_t rt_usbh_hid_set_report(struct uintf* intf, rt_uint8_t *buffer, rt_size_
setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_INTERFACE;
- setup.request = USB_REQ_SET_REPORT;
- setup.index = intf->intf_desc->bInterfaceNumber;
- setup.length = size;
- setup.value = 0x02 << 8;
+ setup.bRequest = USB_REQ_SET_REPORT;
+ setup.wIndex = intf->intf_desc->bInterfaceNumber;
+ setup.wLength = size;
+ setup.wValue = 0x02 << 8;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
- timeout) == size) return RT_EOK;
- else return -RT_FALSE;
+ if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8)
+ return RT_EOK;
+ else
+ return -RT_FALSE;
}
/**
@@ -125,7 +137,7 @@ rt_err_t rt_usbh_hid_set_report(struct uintf* intf, rt_uint8_t *buffer, rt_size_
*
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_hid_set_protocal(struct uintf* intf, int protocol)
+rt_err_t rt_usbh_hid_set_protocal(struct uhintf* intf, int protocol)
{
struct urequest setup;
struct uinstance* device;
@@ -139,14 +151,15 @@ rt_err_t rt_usbh_hid_set_protocal(struct uintf* intf, int protocol)
setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_INTERFACE;
- setup.request = USB_REQ_SET_PROTOCOL;
- setup.index = 0;
- setup.length = 0;
- setup.value = protocol;
+ setup.bRequest = USB_REQ_SET_PROTOCOL;
+ setup.wIndex = 0;
+ setup.wLength = 0;
+ setup.wValue = protocol;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, RT_NULL, 0,
- timeout) == 0) return RT_EOK;
- else return -RT_FALSE;
+ if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8)
+ return RT_EOK;
+ else
+ return -RT_FALSE;
}
/**
@@ -159,7 +172,7 @@ rt_err_t rt_usbh_hid_set_protocal(struct uintf* intf, int protocol)
*
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_hid_get_report_descriptor(struct uintf* intf,
+rt_err_t rt_usbh_hid_get_report_descriptor(struct uhintf* intf,
rt_uint8_t *buffer, rt_size_t size)
{
struct urequest setup;
@@ -174,14 +187,24 @@ rt_err_t rt_usbh_hid_get_report_descriptor(struct uintf* intf,
setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD|
USB_REQ_TYPE_INTERFACE;
- setup.request = USB_REQ_GET_DESCRIPTOR;
- setup.index = 0;
- setup.length = size;
- setup.value = USB_DESC_TYPE_REPORT << 8;
+ setup.bRequest = USB_REQ_GET_DESCRIPTOR;
+ setup.wIndex = 0;
+ setup.wLength = size;
+ setup.wValue = USB_DESC_TYPE_REPORT << 8;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
- timeout) == size) return RT_EOK;
- else return -RT_FALSE;
+ if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8)
+ {
+ if (rt_usb_hcd_pipe_xfer(device->hcd, device->pipe_ep0_in, buffer, size, timeout) == size)
+ {
+ if (rt_usb_hcd_pipe_xfer(device->hcd, device->pipe_ep0_out, RT_NULL, 0, timeout) == 0)
+ {
+ return RT_EOK;
+ }
+ }
+ }
+ else
+ return -RT_FALSE;
+ return -RT_FALSE;
}
/**
@@ -220,16 +243,16 @@ static void rt_usbh_hid_callback(void* context)
RT_ASSERT(context != RT_NULL);
pipe = (upipe_t)context;
- hid = (struct uhid*)pipe->intf->user_data;
+ hid = (struct uhid*)((struct uhintf*)pipe->inst)->user_data;
/* invoke protocal callback function */
hid->protocal->callback((void*)hid);
/* parameter check */
- RT_ASSERT(pipe->intf->device->hcd != RT_NULL);
+ RT_ASSERT(((struct uhintf*)pipe->inst)->device->hcd != RT_NULL);
- rt_usb_hcd_int_xfer(pipe->intf->device->hcd, pipe, hid->buffer,
- pipe->ep.wMaxPacketSize, timeout);
+ rt_usb_hcd_pipe_xfer(((struct uhintf*)pipe->inst)->device->hcd, pipe,
+ hid->buffer, pipe->ep.wMaxPacketSize, timeout);
}
/**
@@ -268,9 +291,7 @@ static rt_err_t rt_usbh_hid_enable(void* arg)
int i = 0, pro_id;
uprotocal_t protocal;
struct uhid* hid;
- struct uintf* intf = (struct uintf*)arg;
- int timeout = USB_TIMEOUT_BASIC;
- upipe_t pipe;
+ struct uhintf* intf = (struct uhintf*)arg;
/* parameter check */
if(intf == RT_NULL)
@@ -319,19 +340,13 @@ static rt_err_t rt_usbh_hid_enable(void* arg)
if(!(ep_desc->bEndpointAddress & USB_DIR_IN)) continue;
ret = rt_usb_hcd_alloc_pipe(intf->device->hcd, &hid->pipe_in,
- intf, ep_desc, rt_usbh_hid_callback);
+ intf, ep_desc);
if(ret != RT_EOK) return ret;
}
/* initialize hid protocal */
- hid->protocal->init((void*)intf);
- pipe = hid->pipe_in;
+ hid->protocal->init((void*)intf);
- /* parameter check */
- RT_ASSERT(pipe->intf->device->hcd != RT_NULL);
-
- rt_usb_hcd_int_xfer(pipe->intf->device->hcd, hid->pipe_in,
- hid->buffer, hid->pipe_in->ep.wMaxPacketSize, timeout);
return RT_EOK;
}
@@ -346,7 +361,7 @@ static rt_err_t rt_usbh_hid_enable(void* arg)
static rt_err_t rt_usbh_hid_disable(void* arg)
{
struct uhid* hid;
- struct uintf* intf = (struct uintf*)arg;
+ struct uhintf* intf = (struct uhintf*)arg;
RT_ASSERT(intf != RT_NULL);
@@ -364,9 +379,6 @@ static rt_err_t rt_usbh_hid_disable(void* arg)
/* free the hid instance */
rt_free(hid);
}
-
- /* free the instance */
- rt_free(intf);
return RT_EOK;
}
diff --git a/components/drivers/usb/usbhost/class/hid.h b/components/drivers/usb/usbhost/class/hid.h
index 8e446c8cea..04c67aa42b 100644
--- a/components/drivers/usb/usbhost/class/hid.h
+++ b/components/drivers/usb/usbhost/class/hid.h
@@ -31,11 +31,11 @@ typedef struct uhid uhid_t;
#define USB_HID_KEYBOARD 1
#define USB_HID_MOUSE 2
-rt_err_t rt_usbh_hid_set_idle(struct uintf* intf, int duration, int report_id);
-rt_err_t rt_usbh_hid_get_report(struct uintf* intf, rt_uint8_t type, rt_uint8_t id, rt_uint8_t *buffer, rt_size_t size);
-rt_err_t rt_usbh_hid_set_report(struct uintf* intf, rt_uint8_t *buffer, rt_size_t size);
-rt_err_t rt_usbh_hid_set_protocal(struct uintf* intf, int protocol);
-rt_err_t rt_usbh_hid_get_report_descriptor(struct uintf* intf, rt_uint8_t *buffer, rt_size_t size);
+rt_err_t rt_usbh_hid_set_idle(struct uhintf* intf, int duration, int report_id);
+rt_err_t rt_usbh_hid_get_report(struct uhintf* intf, rt_uint8_t type, rt_uint8_t id, rt_uint8_t *buffer, rt_size_t size);
+rt_err_t rt_usbh_hid_set_report(struct uhintf* intf, rt_uint8_t *buffer, rt_size_t size);
+rt_err_t rt_usbh_hid_set_protocal(struct uhintf* intf, int protocol);
+rt_err_t rt_usbh_hid_get_report_descriptor(struct uhintf* intf, rt_uint8_t *buffer, rt_size_t size);
rt_err_t rt_usbh_hid_protocal_register(uprotocal_t protocal);
#endif
diff --git a/components/drivers/usb/usbhost/class/umouse.c b/components/drivers/usb/usbhost/class/umouse.c
index e769475a98..7f50c0451f 100644
--- a/components/drivers/usb/usbhost/class/umouse.c
+++ b/components/drivers/usb/usbhost/class/umouse.c
@@ -126,15 +126,36 @@ static rt_err_t rt_usbh_hid_mouse_callback(void* arg)
return RT_EOK;
}
+rt_thread_t mouse_thread;
+void mouse_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_mouse_callback(intf->user_data);
+ }
+}
+
+
static rt_err_t rt_usbh_hid_mouse_init(void* arg)
{
- struct uintf* intf = (struct uintf*)arg;
+ struct uhintf* intf = (struct uhintf*)arg;
RT_ASSERT(intf != RT_NULL);
rt_usbh_hid_set_protocal(intf, 0);
- rt_usbh_hid_set_idle(intf, 10, 0);
+ rt_usbh_hid_set_idle(intf, 0, 0);
+
+ mouse_thread = rt_thread_create("mouse0", mouse_task, intf, 500, 8, 100);
+ rt_thread_startup(mouse_thread);
RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb mouse\n"));
#ifdef RT_USING_RTGUI
diff --git a/components/drivers/usb/usbhost/core/driver.c b/components/drivers/usb/usbhost/core/driver.c
index 37327108c1..871a7b578a 100644
--- a/components/drivers/usb/usbhost/core/driver.c
+++ b/components/drivers/usb/usbhost/core/driver.c
@@ -13,6 +13,7 @@
#include <drivers/usb_host.h>
static rt_list_t _driver_list;
+static rt_bool_t _driver_list_created = RT_FALSE;
/**
* This function will initilize the usb class driver related data structure,
@@ -22,8 +23,11 @@ static rt_list_t _driver_list;
*/
rt_err_t rt_usbh_class_driver_init(void)
{
- rt_list_init(&_driver_list);
-
+ if (_driver_list_created == RT_FALSE)
+ {
+ rt_list_init(&_driver_list);
+ _driver_list_created = RT_TRUE;
+ }
return RT_EOK;
}
@@ -39,8 +43,11 @@ rt_err_t rt_usbh_class_driver_register(ucd_t drv)
{
if (drv == RT_NULL) return -RT_ERROR;
- /* insert class driver into driver list */
- rt_list_insert_after(&_driver_list, &(drv->list));
+ if (rt_usbh_class_driver_find(drv->class_code, drv->subclass_code) == RT_NULL)
+ {
+ /* insert class driver into driver list */
+ rt_list_insert_after(&_driver_list, &(drv->list));
+ }
return RT_EOK;
}
diff --git a/components/drivers/usb/usbhost/core/hub.c b/components/drivers/usb/usbhost/core/hub.c
index eefa571472..c0e025ba7e 100644
--- a/components/drivers/usb/usbhost/core/hub.c
+++ b/components/drivers/usb/usbhost/core/hub.c
@@ -13,9 +13,9 @@
#define USB_THREAD_STACK_SIZE 4096
-static struct rt_messagequeue *usb_mq;
+// static struct rt_messagequeue *usb_mq;
static struct uclass_driver hub_driver;
-static struct uhub root_hub;
+// static struct uhub root_hub;
static rt_err_t root_hub_ctrl(struct uhcd *hcd, rt_uint16_t port, rt_uint8_t cmd, void *args)
{
@@ -92,7 +92,7 @@ void rt_usbh_root_hub_connect_handler(struct uhcd *hcd, rt_uint8_t port, rt_bool
{
hcd->roothub->port_status[port - 1] |= PORT_LSDA;
}
- rt_usbh_event_signal(&msg);
+ rt_usbh_event_signal(hcd, &msg);
}
void rt_usbh_root_hub_disconnect_handler(struct uhcd *hcd, rt_uint8_t port)
@@ -102,7 +102,7 @@ void rt_usbh_root_hub_disconnect_handler(struct uhcd *hcd, rt_uint8_t port)
msg.content.hub = hcd->roothub;
hcd->roothub->port_status[port - 1] |= PORT_CCSC;
hcd->roothub->port_status[port - 1] &= ~PORT_CCS;
- rt_usbh_event_signal(&msg);
+ rt_usbh_event_signal(hcd, &msg);
}
/**
@@ -647,12 +647,13 @@ ucd_t rt_usbh_class_driver_hub(void)
*/
static void rt_usbh_hub_thread_entry(void* parameter)
{
+ uhcd_t hcd = (uhcd_t)parameter;
while(1)
{
struct uhost_msg msg;
/* receive message */
- if(rt_mq_recv(usb_mq, &msg, sizeof(struct uhost_msg), RT_WAITING_FOREVER)
+ if(rt_mq_recv(hcd->usb_mq, &msg, sizeof(struct uhost_msg), RT_WAITING_FOREVER)
!= RT_EOK ) continue;
//RT_DEBUG_LOG(RT_DEBUG_USB, ("msg type %d\n", msg.type));
@@ -679,12 +680,12 @@ static void rt_usbh_hub_thread_entry(void* parameter)
*
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_event_signal(struct uhost_msg* msg)
+rt_err_t rt_usbh_event_signal(uhcd_t hcd, struct uhost_msg* msg)
{
RT_ASSERT(msg != RT_NULL);
/* send message to usb message queue */
- rt_mq_send(usb_mq, (void*)msg, sizeof(struct uhost_msg));
+ rt_mq_send(hcd->usb_mq, (void*)msg, sizeof(struct uhost_msg));
return RT_EOK;
}
@@ -698,16 +699,17 @@ rt_err_t rt_usbh_event_signal(struct uhost_msg* msg)
void rt_usbh_hub_init(uhcd_t hcd)
{
rt_thread_t thread;
- /* link root hub to hcd */
- root_hub.is_roothub = RT_TRUE;
- hcd->roothub = &root_hub;
- root_hub.hcd = hcd;
- root_hub.num_ports = hcd->num_ports;
+ /* create root hub for hcd */
+ hcd->roothub = rt_malloc(sizeof(struct uhub));
+ rt_memset(hcd->roothub, 0, sizeof(struct uhub));
+ hcd->roothub->is_roothub = RT_TRUE;
+ hcd->roothub->hcd = hcd;
+ hcd->roothub->num_ports = hcd->num_ports;
/* create usb message queue */
- usb_mq = rt_mq_create("usbh", 32, 16, RT_IPC_FLAG_FIFO);
+ hcd->usb_mq = rt_mq_create(hcd->parent.parent.name, 32, 16, RT_IPC_FLAG_FIFO);
/* create usb hub thread */
- thread = rt_thread_create("usbh", rt_usbh_hub_thread_entry, RT_NULL,
+ thread = rt_thread_create(hcd->parent.parent.name, rt_usbh_hub_thread_entry, hcd,
USB_THREAD_STACK_SIZE, 8, 20);
if(thread != RT_NULL)
{
diff --git a/components/drivers/usb/usbhost/core/usbhost.c b/components/drivers/usb/usbhost/core/usbhost.c
index f0294238c4..b9e6a7a4b1 100644
--- a/components/drivers/usb/usbhost/core/usbhost.c
+++ b/components/drivers/usb/usbhost/core/usbhost.c
@@ -22,15 +22,15 @@
*
* @return none.
*/
-rt_err_t rt_usb_host_init(void)
+rt_err_t rt_usb_host_init(const char *name)
{
ucd_t drv;
rt_device_t uhc;
- uhc = rt_device_find(USB_HOST_CONTROLLER_NAME);
+ uhc = rt_device_find(name);
if(uhc == RT_NULL)
{
- rt_kprintf("can't find usb host controller %s\n", USB_HOST_CONTROLLER_NAME);
+ rt_kprintf("can't find usb host controller %s\n", name);
return -RT_ERROR;
}
@@ -45,6 +45,16 @@ rt_err_t rt_usb_host_init(void)
drv = rt_usbh_class_driver_storage();
rt_usbh_class_driver_register(drv);
#endif
+#ifdef RT_USBH_HID
+ /* 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);
+#endif
+#endif
/* register hub class driver */
drv = rt_usbh_class_driver_hub();