summaryrefslogtreecommitdiff
path: root/components/drivers/usb/usbhost/class
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/usb/usbhost/class')
-rw-r--r--components/drivers/usb/usbhost/class/adk.c2
-rw-r--r--components/drivers/usb/usbhost/class/adk.h4
-rw-r--r--components/drivers/usb/usbhost/class/hid.c136
-rw-r--r--components/drivers/usb/usbhost/class/hid.h6
-rw-r--r--components/drivers/usb/usbhost/class/mass.c178
-rw-r--r--components/drivers/usb/usbhost/class/mass.h10
-rw-r--r--components/drivers/usb/usbhost/class/udisk.c2
-rw-r--r--components/drivers/usb/usbhost/class/ukbd.c20
-rw-r--r--components/drivers/usb/usbhost/class/umouse.c2
9 files changed, 180 insertions, 180 deletions
diff --git a/components/drivers/usb/usbhost/class/adk.c b/components/drivers/usb/usbhost/class/adk.c
index 2425de7bba..492a2f9bb7 100644
--- a/components/drivers/usb/usbhost/class/adk.c
+++ b/components/drivers/usb/usbhost/class/adk.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
diff --git a/components/drivers/usb/usbhost/class/adk.h b/components/drivers/usb/usbhost/class/adk.h
index c582ad7f17..aebe7de705 100644
--- a/components/drivers/usb/usbhost/class/adk.h
+++ b/components/drivers/usb/usbhost/class/adk.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -19,7 +19,7 @@ struct uadkinst
upipe_t pipe_out;
struct rt_device device;
-};
+};
typedef struct uadkinst* uadk_t;
#define USB_ACCESSORY_VENDOR_ID 0x18D1
diff --git a/components/drivers/usb/usbhost/class/hid.c b/components/drivers/usb/usbhost/class/hid.c
index e16096877f..4038d3b321 100644
--- a/components/drivers/usb/usbhost/class/hid.c
+++ b/components/drivers/usb/usbhost/class/hid.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -23,31 +23,31 @@ static rt_list_t _protocal_list;
* @param intf the interface instance.
* @duration the idle period of requesting data.
* @report_id the report id
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hid_set_idle(struct uintf* intf, int duration, int report_id)
{
struct urequest setup;
- struct uinstance* device;
+ struct uinstance* device;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(intf != RT_NULL);
RT_ASSERT(intf->device != RT_NULL);
device = intf->device;
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
+ 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;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, RT_NULL, 0,
+ if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, RT_NULL, 0,
timeout) == 0) return RT_EOK;
- else return -RT_FALSE;
+ else return -RT_FALSE;
}
/**
@@ -56,32 +56,32 @@ rt_err_t rt_usbh_hid_set_idle(struct uintf* intf, int duration, int report_id)
* @param intf the interface instance.
* @buffer the data buffer to save usb report descriptor.
* @param nbytes the size of buffer
- *
+ *
* @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 uintf* intf, rt_uint8_t type,
rt_uint8_t id, rt_uint8_t *buffer, rt_size_t size)
{
struct urequest setup;
struct uinstance* device;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(intf != RT_NULL);
RT_ASSERT(intf->device != RT_NULL);
device = intf->device;
- setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS |
+ 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;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
+ if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
timeout) == size) return RT_EOK;
- else return -RT_FALSE;
+ else return -RT_FALSE;
}
/**
@@ -90,31 +90,31 @@ rt_err_t rt_usbh_hid_get_report(struct uintf* intf, rt_uint8_t type,
* @param intf the interface instance.
* @buffer the data buffer to save usb report descriptor.
* @param nbytes the size of buffer
- *
+ *
* @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)
{
struct urequest setup;
- struct uinstance* device;
+ struct uinstance* device;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(intf != RT_NULL);
RT_ASSERT(intf->device != RT_NULL);
-
+
device = intf->device;
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
+ 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;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
+ if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
timeout) == size) return RT_EOK;
- else return -RT_FALSE;
+ else return -RT_FALSE;
}
/**
@@ -122,7 +122,7 @@ rt_err_t rt_usbh_hid_set_report(struct uintf* intf, rt_uint8_t *buffer, rt_size_
*
* @param intf the interface instance.
* @param protocol the protocol id.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hid_set_protocal(struct uintf* intf, int protocol)
@@ -130,56 +130,56 @@ rt_err_t rt_usbh_hid_set_protocal(struct uintf* intf, int protocol)
struct urequest setup;
struct uinstance* device;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(intf != RT_NULL);
RT_ASSERT(intf->device != RT_NULL);
-
+
device = intf->device;
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
+ 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;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, RT_NULL, 0,
+ if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, RT_NULL, 0,
timeout) == 0) return RT_EOK;
- else return -RT_FALSE;
+ else return -RT_FALSE;
}
/**
- * This function will do USB_REQ_GET_DESCRIPTOR request for the device instance
+ * This function will do USB_REQ_GET_DESCRIPTOR request for the device instance
* to set feature of the hub port.
*
* @param intf the interface instance.
* @buffer the data buffer to save usb report descriptor.
* @param nbytes the size of buffer
- *
+ *
* @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 uintf* intf,
rt_uint8_t *buffer, rt_size_t size)
{
struct urequest setup;
- struct uinstance* device;
+ struct uinstance* device;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(intf != RT_NULL);
RT_ASSERT(intf->device != RT_NULL);
-
+
device = intf->device;
- setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD|
+ 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;
- if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
+ if(rt_usb_hcd_control_xfer(device->hcd, device, &setup, buffer, size,
timeout) == size) return RT_EOK;
else return -RT_FALSE;
}
@@ -188,7 +188,7 @@ rt_err_t rt_usbh_hid_get_report_descriptor(struct uintf* intf,
* This function will register specified hid protocal to protocal list
*
* @param protocal the specified protocal.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hid_protocal_register(uprotocal_t protocal)
@@ -199,26 +199,26 @@ rt_err_t rt_usbh_hid_protocal_register(uprotocal_t protocal)
/* insert class driver into driver list */
rt_list_insert_after(&_protocal_list, &(protocal->list));
-
- return RT_EOK;
+
+ return RT_EOK;
}
/**
* This function is the callback function of hid's int endpoint, it is invoked when data comes.
*
* @param context the context of the callback function.
- *
+ *
* @return none.
*/
static void rt_usbh_hid_callback(void* context)
{
- upipe_t pipe;
+ upipe_t pipe;
struct uhid* hid;
int timeout = USB_TIMEOUT_LONG;
/* parameter check */
RT_ASSERT(context != RT_NULL);
-
+
pipe = (upipe_t)context;
hid = (struct uhid*)pipe->intf->user_data;
@@ -228,7 +228,7 @@ static void rt_usbh_hid_callback(void* context)
/* parameter check */
RT_ASSERT(pipe->intf->device->hcd != RT_NULL);
- rt_usb_hcd_int_xfer(pipe->intf->device->hcd, pipe, hid->buffer,
+ rt_usb_hcd_int_xfer(pipe->intf->device->hcd, pipe, hid->buffer,
pipe->ep.wMaxPacketSize, timeout);
}
@@ -236,7 +236,7 @@ static void rt_usbh_hid_callback(void* context)
* This function will find specified hid protocal from protocal list
*
* @param pro_id the protocal id.
- *
+ *
* @return the found protocal or RT_NULL if there is no this protocal.
*/
static uprotocal_t rt_usbh_hid_protocal_find(int pro_id)
@@ -246,7 +246,7 @@ static uprotocal_t rt_usbh_hid_protocal_find(int pro_id)
/* try to find protocal object */
for (node = _protocal_list.next; node != &_protocal_list; node = node->next)
{
- uprotocal_t protocal =
+ uprotocal_t protocal =
(uprotocal_t)rt_list_entry(node, struct uprotocal, list);
if (protocal->pro_id == pro_id) return protocal;
}
@@ -260,18 +260,18 @@ static uprotocal_t rt_usbh_hid_protocal_find(int pro_id)
* as a hid class device, it will continue the enumulate process.
*
* @param arg the argument.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
static rt_err_t rt_usbh_hid_enable(void* arg)
{
int i = 0, pro_id;
- uprotocal_t protocal;
+ uprotocal_t protocal;
struct uhid* hid;
struct uintf* intf = (struct uintf*)arg;
int timeout = USB_TIMEOUT_BASIC;
upipe_t pipe;
-
+
/* parameter check */
if(intf == RT_NULL)
{
@@ -282,65 +282,65 @@ static rt_err_t rt_usbh_hid_enable(void* arg)
pro_id = intf->intf_desc->bInterfaceProtocol;
RT_DEBUG_LOG(RT_DEBUG_USB,
- ("HID device enable, protocal id %d\n", pro_id));
+ ("HID device enable, protocal id %d\n", pro_id));
- protocal = rt_usbh_hid_protocal_find(pro_id);
+ protocal = rt_usbh_hid_protocal_find(pro_id);
if(protocal == RT_NULL)
{
rt_kprintf("can't find hid protocal %d\n", pro_id);
- intf->user_data = RT_NULL;
+ intf->user_data = RT_NULL;
return -RT_ERROR;
}
-
+
hid = rt_malloc(sizeof(struct uhid));
RT_ASSERT(hid != RT_NULL);
- /* initilize the data structure */
+ /* initilize the data structure */
rt_memset(hid, 0, sizeof(struct uhid));
intf->user_data = (void*)hid;
hid->protocal = protocal;
-
+
for(i=0; i<intf->intf_desc->bNumEndpoints; i++)
- {
+ {
rt_err_t ret;
uep_desc_t ep_desc;
- /* get endpoint descriptor */
+ /* get endpoint descriptor */
rt_usbh_get_endpoint_descriptor(intf->intf_desc, i, &ep_desc);
if(ep_desc == RT_NULL)
{
rt_kprintf("rt_usbh_get_endpoint_descriptor error\n");
return -RT_ERROR;
}
-
- if(USB_EP_ATTR(ep_desc->bmAttributes) != USB_EP_ATTR_INT)
+
+ if(USB_EP_ATTR(ep_desc->bmAttributes) != USB_EP_ATTR_INT)
continue;
-
+
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);
+ ret = rt_usb_hcd_alloc_pipe(intf->device->hcd, &hid->pipe_in,
+ intf, ep_desc, rt_usbh_hid_callback);
if(ret != RT_EOK) return ret;
}
/* initialize hid protocal */
- hid->protocal->init((void*)intf);
+ hid->protocal->init((void*)intf);
pipe = hid->pipe_in;
/* parameter check */
RT_ASSERT(pipe->intf->device->hcd != RT_NULL);
-
- rt_usb_hcd_int_xfer(pipe->intf->device->hcd, hid->pipe_in,
+
+ rt_usb_hcd_int_xfer(pipe->intf->device->hcd, hid->pipe_in,
hid->buffer, hid->pipe_in->ep.wMaxPacketSize, timeout);
return RT_EOK;
}
/**
- * This function will be invoked when usb device plug out is detected and it would clean
+ * This function will be invoked when usb device plug out is detected and it would clean
* and release all hub class related resources.
*
* @param arg the argument.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
static rt_err_t rt_usbh_hid_disable(void* arg)
@@ -361,10 +361,10 @@ static rt_err_t rt_usbh_hid_disable(void* arg)
rt_usb_hcd_free_pipe(intf->device->hcd, hid->pipe_in);
}
- /* free the hid instance */
+ /* free the hid instance */
rt_free(hid);
}
-
+
/* free the instance */
rt_free(intf);
@@ -374,7 +374,7 @@ static rt_err_t rt_usbh_hid_disable(void* arg)
/**
* This function will register hid class driver to the usb class driver manager.
* and it should be invoked in the usb system initialization.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
ucd_t rt_usbh_class_driver_hid(void)
@@ -382,7 +382,7 @@ ucd_t rt_usbh_class_driver_hid(void)
rt_list_init(&_protocal_list);
hid_driver.class_code = USB_CLASS_HID;
-
+
hid_driver.enable = rt_usbh_hid_enable;
hid_driver.disable = rt_usbh_hid_disable;
diff --git a/components/drivers/usb/usbhost/class/hid.h b/components/drivers/usb/usbhost/class/hid.h
index 8e446c8cea..10d3c6ee4d 100644
--- a/components/drivers/usb/usbhost/class/hid.h
+++ b/components/drivers/usb/usbhost/class/hid.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -18,7 +18,7 @@ struct uhid
upipe_t pipe_in;
rt_uint8_t buffer[8];
uprotocal_t protocal;
-};
+};
typedef struct uhid uhid_t;
#define USB_REQ_GET_REPORT 0x01
@@ -28,7 +28,7 @@ typedef struct uhid uhid_t;
#define USB_REQ_SET_IDLE 0x0a
#define USB_REQ_SET_PROTOCOL 0x0b
-#define USB_HID_KEYBOARD 1
+#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);
diff --git a/components/drivers/usb/usbhost/class/mass.c b/components/drivers/usb/usbhost/class/mass.c
index 20048873f5..abd89a5efc 100644
--- a/components/drivers/usb/usbhost/class/mass.c
+++ b/components/drivers/usb/usbhost/class/mass.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -24,29 +24,29 @@ static struct uclass_driver storage_driver;
*
* @param intf the interface instance.
* @param max_lun the buffer to save max_lun.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe)
{
- struct uinstance* device;
+ struct uinstance* device;
rt_err_t ret;
ustor_t stor;
- int size = 0;
+ int size = 0;
struct ustorage_csw csw;
if(intf == RT_NULL || pipe == RT_NULL)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
+ }
- /* get usb device instance from the interface instance */
- device = intf->device;
+ /* get usb device instance from the interface instance */
+ device = intf->device;
- /* get storage instance from the interface instance */
+ /* get storage instance from the interface instance */
stor = (ustor_t)intf->user_data;
-
+
/* check pipe status */
if(pipe->status == UPIPE_STATUS_OK) return RT_EOK;
@@ -58,11 +58,11 @@ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe)
if(pipe->status == UPIPE_STATUS_STALL)
{
/* clear the pipe stall status */
- ret = rt_usbh_clear_feature(device, pipe->ep.bEndpointAddress,
+ ret = rt_usbh_clear_feature(device, pipe->ep.bEndpointAddress,
USB_FEATURE_ENDPOINT_HALT);
if(ret != RT_EOK) return ret;
}
-
+
rt_thread_delay(50);
@@ -73,14 +73,14 @@ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe)
RT_DEBUG_LOG(RT_DEBUG_USB, ("clean storage in pipe stall\n"));
/* it should receive csw after clear the stall feature */
- size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd,
+ size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd,
stor->pipe_in, &csw, SIZEOF_CSW, 100);
- if(size != SIZEOF_CSW)
+ if(size != SIZEOF_CSW)
{
rt_kprintf("receive the csw after stall failed\n");
return -RT_EIO;
}
-
+
return -RT_ERROR;
}
@@ -89,35 +89,35 @@ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe)
*
* @param intf the interface instance.
* @param max_lun the buffer to save max_lun.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf,
+static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf,
ustorage_cbw_t cmd, rt_uint8_t* buffer, int timeout)
{
rt_size_t size;
- rt_err_t ret;
+ rt_err_t ret;
upipe_t pipe;
struct ustorage_csw csw;
ustor_t stor;
- RT_ASSERT(cmd != RT_NULL);
+ RT_ASSERT(cmd != RT_NULL);
if(intf == RT_NULL)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
}
-
- /* get storage instance from the interface instance */
+
+ /* get storage instance from the interface instance */
stor = (ustor_t)intf->user_data;
do
{
/* send the cbw */
- size = rt_usb_hcd_pipe_xfer(stor->pipe_out->inst->hcd, stor->pipe_out,
+ size = rt_usb_hcd_pipe_xfer(stor->pipe_out->inst->hcd, stor->pipe_out,
cmd, SIZEOF_CBW, timeout);
- if(size != SIZEOF_CBW)
+ if(size != SIZEOF_CBW)
{
rt_kprintf("CBW size error\n");
return -RT_EIO;
@@ -126,20 +126,20 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf,
{
pipe = (cmd->dflags == CBWFLAGS_DIR_IN) ? stor->pipe_in :
stor->pipe_out;
- size = rt_usb_hcd_pipe_xfer(pipe->inst->hcd, pipe, (void*)buffer,
+ size = rt_usb_hcd_pipe_xfer(pipe->inst->hcd, pipe, (void*)buffer,
cmd->xfer_len, timeout);
if(size != cmd->xfer_len)
{
- rt_kprintf("request size %d, transfer size %d\n",
+ rt_kprintf("request size %d, transfer size %d\n",
cmd->xfer_len, size);
break;
- }
+ }
}
-
+
/* receive the csw */
- size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd, stor->pipe_in,
+ size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd, stor->pipe_in,
&csw, SIZEOF_CSW, timeout);
- if(size != SIZEOF_CSW)
+ if(size != SIZEOF_CSW)
{
rt_kprintf("csw size error\n");
return -RT_EIO;
@@ -148,12 +148,12 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf,
/* check in pipes status */
ret = _pipe_check(intf, stor->pipe_in);
- if(ret != RT_EOK)
+ if(ret != RT_EOK)
{
rt_kprintf("in pipe error\n");
return ret;
}
-
+
/* check out pipes status */
ret = _pipe_check(intf, stor->pipe_out);
if(ret != RT_EOK)
@@ -161,20 +161,20 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf,
rt_kprintf("out pipe error\n");
return ret;
}
-
+
/* check csw status */
if(csw.signature != CSW_SIGNATURE || csw.tag != CBW_TAG_VALUE)
{
rt_kprintf("csw signature error\n");
return -RT_EIO;
}
-
+
if(csw.status != 0)
{
//rt_kprintf("csw status error:%d\n",csw.status);
return -RT_ERROR;
}
-
+
return RT_EOK;
}
@@ -183,12 +183,12 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf,
*
* @param intf the interface instance.
* @param max_lun the buffer to save max_lun.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun)
{
- struct uinstance* device;
+ struct uinstance* device;
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
@@ -196,17 +196,17 @@ rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
+ }
/* parameter check */
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_get_max_lun\n"));
- /* get usb device instance from the interface instance */
- device = intf->device;
+ /* get usb device instance from the interface instance */
+ device = intf->device;
/* construct the request */
- setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS |
+ setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_INTERFACE;
setup.bRequest = USBREQ_GET_MAX_LUN;
setup.wValue = intf->intf_desc->bInterfaceNumber;
@@ -233,13 +233,13 @@ rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun)
* This function will do USBREQ_MASS_STORAGE_RESET request for the usb interface instance.
*
* @param intf the interface instance.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_storage_reset(struct uhintf* intf)
{
struct urequest setup;
- struct uinstance* device;
+ struct uinstance* device;
int timeout = USB_TIMEOUT_BASIC;
/* parameter check */
@@ -247,16 +247,16 @@ rt_err_t rt_usbh_storage_reset(struct uhintf* intf)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
+ }
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_reset\n"));
- /* get usb device instance from the interface instance */
- device = intf->device;
+ /* get usb device instance from the interface instance */
+ device = intf->device;
/* construct the request */
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
+ setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_INTERFACE;
setup.bRequest = USBREQ_MASS_STORAGE_RESET;
setup.wIndex = intf->intf_desc->bInterfaceNumber;
@@ -279,12 +279,12 @@ rt_err_t rt_usbh_storage_reset(struct uhintf* intf)
*
* @param intf the interface instance.
* @param buffer the data buffer to save read data
- * @param sector the start sector address to read.
+ * @param sector the start sector address to read.
* @param sector the sector count to read.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer,
+rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer,
rt_uint32_t sector, rt_size_t count, int timeout)
{
struct ustorage_cbw cmd;
@@ -294,8 +294,8 @@ rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer,
{
rt_kprintf("interface is not available\n");
return -RT_EIO;
- }
-
+ }
+
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_read10\n"));
@@ -325,12 +325,12 @@ rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer,
*
* @param intf the interface instance.
* @param buffer the data buffer to save write data
- * @param sector the start sector address to write.
+ * @param sector the start sector address to write.
* @param sector the sector count to write.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
+rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
rt_uint32_t sector, rt_size_t count, int timeout)
{
struct ustorage_cbw cmd;
@@ -340,8 +340,8 @@ rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
-
+ }
+
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_write10\n"));
@@ -371,7 +371,7 @@ rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
*
* @param intf the interface instance.
* @param buffer the data buffer to save sense data
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer)
@@ -384,12 +384,12 @@ rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
-
+ }
+
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_request_sense\n"));
- /* construct the command block wrapper */
+ /* construct the command block wrapper */
rt_memset(&cmd, 0, sizeof(struct ustorage_cbw));
cmd.signature = CBW_SIGNATURE;
cmd.tag = CBW_TAG_VALUE;
@@ -407,7 +407,7 @@ rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer)
* This function will execute SCSI_TEST_UNIT_READY command to get unit ready status.
*
* @param intf the interface instance.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf)
@@ -420,8 +420,8 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
-
+ }
+
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_test_unit_ready\n"));
@@ -434,7 +434,7 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf)
cmd.lun = 0;
cmd.cb_len = 12;
cmd.cb[0] = SCSI_TEST_UNIT_READY;
-
+
return rt_usb_bulk_only_xfer(intf, &cmd, RT_NULL, timeout);
}
@@ -443,21 +443,21 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf)
*
* @param intf the interface instance.
* @param buffer the data buffer to save inquiry data
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_storage_inquiry(struct uhintf* intf, rt_uint8_t* buffer)
{
struct ustorage_cbw cmd;
int timeout = USB_TIMEOUT_LONG;
-
+
/* parameter check */
if(intf == RT_NULL)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
-
+ }
+
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_inquiry\n"));
@@ -480,7 +480,7 @@ rt_err_t rt_usbh_storage_inquiry(struct uhintf* intf, rt_uint8_t* buffer)
*
* @param intf the interface instance.
* @param buffer the data buffer to save capacity data
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_storage_get_capacity(struct uhintf* intf, rt_uint8_t* buffer)
@@ -493,7 +493,7 @@ rt_err_t rt_usbh_storage_get_capacity(struct uhintf* intf, rt_uint8_t* buffer)
{
rt_kprintf("the interface is not available\n");
return -RT_EIO;
- }
+ }
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_get_capacity\n"));
@@ -513,17 +513,17 @@ rt_err_t rt_usbh_storage_get_capacity(struct uhintf* intf, rt_uint8_t* buffer)
/**
* This function will run mass storage class driver when usb device is detected
- * and identified as a mass storage class device, it will continue to do the enumulate
+ * and identified as a mass storage class device, it will continue to do the enumulate
* process.
*
* @param arg the argument.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
static rt_err_t rt_usbh_storage_enable(void* arg)
{
int i = 0;
- rt_err_t ret;
+ rt_err_t ret;
ustor_t stor;
struct uhintf* intf = (struct uhintf*)arg;
@@ -534,25 +534,25 @@ static rt_err_t rt_usbh_storage_enable(void* arg)
return -RT_EIO;
}
- RT_DEBUG_LOG(RT_DEBUG_USB, ("subclass %d, protocal %d\n",
+ RT_DEBUG_LOG(RT_DEBUG_USB, ("subclass %d, protocal %d\n",
intf->intf_desc->bInterfaceSubClass,
intf->intf_desc->bInterfaceProtocol));
-
+
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_run\n"));
/* only support SCSI subclass and bulk only protocal */
-
+
stor = rt_malloc(sizeof(struct ustor));
RT_ASSERT(stor != RT_NULL);
/* initilize the data structure */
- rt_memset(stor, 0, sizeof(struct ustor));
+ rt_memset(stor, 0, sizeof(struct ustor));
intf->user_data = (void*)stor;
for(i=0; i<intf->intf_desc->bNumEndpoints; i++)
- {
+ {
uep_desc_t ep_desc;
-
+
/* get endpoint descriptor from interface descriptor */
rt_usbh_get_endpoint_descriptor(intf->intf_desc, i, &ep_desc);
if(ep_desc == RT_NULL)
@@ -560,11 +560,11 @@ static rt_err_t rt_usbh_storage_enable(void* arg)
rt_kprintf("rt_usb_get_endpoint_descriptor error\n");
return -RT_ERROR;
}
-
- /* the endpoint type of mass storage class should be BULK */
+
+ /* the endpoint type of mass storage class should be BULK */
if((ep_desc->bmAttributes & USB_EP_ATTR_TYPE_MASK) != USB_EP_ATTR_BULK)
continue;
-
+
/* allocate pipes according to the endpoint type */
if(ep_desc->bEndpointAddress & USB_DIR_IN)
{
@@ -572,7 +572,7 @@ static rt_err_t rt_usbh_storage_enable(void* arg)
stor->pipe_in = rt_usb_instance_find_pipe(intf->device,ep_desc->bEndpointAddress);
}
else
- {
+ {
/* alloc an output pipe for the storage instance */
stor->pipe_out = rt_usb_instance_find_pipe(intf->device,ep_desc->bEndpointAddress);
}
@@ -583,8 +583,8 @@ static rt_err_t rt_usbh_storage_enable(void* arg)
{
rt_kprintf("pipe error, unsupported device\n");
return -RT_ERROR;
- }
-
+ }
+
/* should implement as callback */
ret = rt_udisk_run(intf);
if(ret != RT_EOK) return ret;
@@ -593,11 +593,11 @@ static rt_err_t rt_usbh_storage_enable(void* arg)
}
/**
- * This function will be invoked when usb device plug out is detected and it would clean
+ * This function will be invoked when usb device plug out is detected and it would clean
* and release all mass storage class related resources.
*
* @param arg the argument.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
static rt_err_t rt_usbh_storage_disable(void* arg)
@@ -617,7 +617,7 @@ static rt_err_t rt_usbh_storage_disable(void* arg)
rt_udisk_stop(intf);
-
+
/* free storage instance */
if(stor != RT_NULL) rt_free(stor);
return RT_EOK;
@@ -626,13 +626,13 @@ static rt_err_t rt_usbh_storage_disable(void* arg)
/**
* This function will register mass storage class driver to the usb class driver manager.
* and it should be invoked in the usb system initialization.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
ucd_t rt_usbh_class_driver_storage(void)
{
storage_driver.class_code = USB_CLASS_MASS_STORAGE;
-
+
storage_driver.enable = rt_usbh_storage_enable;
storage_driver.disable = rt_usbh_storage_disable;
diff --git a/components/drivers/usb/usbhost/class/mass.h b/components/drivers/usb/usbhost/class/mass.h
index 770e64a03f..2578fb54c7 100644
--- a/components/drivers/usb/usbhost/class/mass.h
+++ b/components/drivers/usb/usbhost/class/mass.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -30,17 +30,17 @@ struct ustor
upipe_t pipe_in;
upipe_t pipe_out;
rt_uint32_t capicity[2];
-
+
struct rt_device dev[MAX_PARTITION_COUNT];
rt_uint8_t dev_cnt;
-};
+};
typedef struct ustor* ustor_t;
rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun);
rt_err_t rt_usbh_storage_reset(struct uhintf* intf);
-rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer,
+rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer,
rt_uint32_t sector, rt_size_t count, int timeout);
-rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
+rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
rt_uint32_t sector, rt_size_t count, int timeout);
rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer);
rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf);
diff --git a/components/drivers/usb/usbhost/class/udisk.c b/components/drivers/usb/usbhost/class/udisk.c
index 6c8030b29a..8be311e657 100644
--- a/components/drivers/usb/usbhost/class/udisk.c
+++ b/components/drivers/usb/usbhost/class/udisk.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
diff --git a/components/drivers/usb/usbhost/class/ukbd.c b/components/drivers/usb/usbhost/class/ukbd.c
index 7d608de259..c89d60cd36 100644
--- a/components/drivers/usb/usbhost/class/ukbd.c
+++ b/components/drivers/usb/usbhost/class/ukbd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -14,13 +14,13 @@
#if defined(RT_USBH_HID) && defined(RT_USBH_HID_KEYBOARD)
-static struct uprotocal kbd_protocal;
+static struct uprotocal kbd_protocal;
static rt_err_t rt_usbh_hid_kbd_callback(void* arg)
{
int int1, int2;
- struct uhid* hid;
-
+ struct uhid* hid;
+
hid = (struct uhid*)arg;
int1 = *(rt_uint32_t*)hid->buffer;
@@ -28,9 +28,9 @@ static rt_err_t rt_usbh_hid_kbd_callback(void* arg)
if(int1 != 0 || int2 != 0)
{
- RT_DEBUG_LOG(RT_DEBUG_USB, ("key down 0x%x, 0x%x\n", int1, int2));
+ RT_DEBUG_LOG(RT_DEBUG_USB, ("key down 0x%x, 0x%x\n", int1, int2));
}
-
+
return RT_EOK;
}
@@ -38,20 +38,20 @@ static rt_err_t rt_usbh_hid_kbd_init(void* arg)
{
struct uintf* intf = (struct uintf*)arg;
- RT_ASSERT(intf != RT_NULL);
-
+ RT_ASSERT(intf != RT_NULL);
+
rt_usbh_hid_set_protocal(intf, 0);
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"));
return RT_EOK;
}
/**
* This function will define the hid keyboard protocal, it will be register to the protocal list.
- *
+ *
* @return the keyboard protocal structure.
*/
uprotocal_t rt_usbh_hid_protocal_kbd(void)
diff --git a/components/drivers/usb/usbhost/class/umouse.c b/components/drivers/usb/usbhost/class/umouse.c
index e769475a98..94fca210bb 100644
--- a/components/drivers/usb/usbhost/class/umouse.c
+++ b/components/drivers/usb/usbhost/class/umouse.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*