summaryrefslogtreecommitdiff
path: root/components/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/usb')
-rw-r--r--components/drivers/usb/usbdevice/class/audio_mic.c2
-rw-r--r--components/drivers/usb/usbdevice/class/audio_speaker.c2
-rw-r--r--components/drivers/usb/usbdevice/class/cdc.h16
-rw-r--r--components/drivers/usb/usbdevice/class/cdc_vcom.c74
-rw-r--r--components/drivers/usb/usbdevice/class/ecm.c26
-rw-r--r--components/drivers/usb/usbdevice/class/hid.c18
-rw-r--r--components/drivers/usb/usbdevice/class/hid.h2
-rw-r--r--components/drivers/usb/usbdevice/class/mstorage.c248
-rw-r--r--components/drivers/usb/usbdevice/class/mstorage.h6
-rw-r--r--components/drivers/usb/usbdevice/class/ndis.h84
-rw-r--r--components/drivers/usb/usbdevice/class/rndis.c20
-rw-r--r--components/drivers/usb/usbdevice/class/rndis.h196
-rw-r--r--components/drivers/usb/usbdevice/class/winusb.c16
-rw-r--r--components/drivers/usb/usbdevice/class/winusb.h2
-rw-r--r--components/drivers/usb/usbdevice/core/usbdevice.c4
-rw-r--r--components/drivers/usb/usbdevice/core/usbdevice_core.c150
-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
-rw-r--r--components/drivers/usb/usbhost/core/driver.c22
-rw-r--r--components/drivers/usb/usbhost/core/hub.c186
-rw-r--r--components/drivers/usb/usbhost/core/usbhost.c6
-rw-r--r--components/drivers/usb/usbhost/core/usbhost_core.c126
29 files changed, 783 insertions, 783 deletions
diff --git a/components/drivers/usb/usbdevice/class/audio_mic.c b/components/drivers/usb/usbdevice/class/audio_mic.c
index 23ade2d9b6..760c055d10 100644
--- a/components/drivers/usb/usbdevice/class/audio_mic.c
+++ b/components/drivers/usb/usbdevice/class/audio_mic.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2019, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
diff --git a/components/drivers/usb/usbdevice/class/audio_speaker.c b/components/drivers/usb/usbdevice/class/audio_speaker.c
index e9a3ffaf40..c8bbb9cb5e 100644
--- a/components/drivers/usb/usbdevice/class/audio_speaker.c
+++ b/components/drivers/usb/usbdevice/class/audio_speaker.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2019, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
diff --git a/components/drivers/usb/usbdevice/class/cdc.h b/components/drivers/usb/usbdevice/class/cdc.h
index 4e07f16266..a4616a956b 100644
--- a/components/drivers/usb/usbdevice/class/cdc.h
+++ b/components/drivers/usb/usbdevice/class/cdc.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
*
@@ -8,7 +8,7 @@
* 2012-10-03 Yi Qiu first version
* 2012-12-12 heyuanjie87 add CDC endpoints collection
*/
-
+
#ifndef __CDC_H__
#define __CDC_H__
@@ -96,7 +96,7 @@ struct ucdc_header_descriptor
rt_uint8_t length;
rt_uint8_t type;
rt_uint8_t subtype;
- rt_uint16_t bcd;
+ rt_uint16_t bcd;
};
typedef struct ucdc_header_descriptor* ucdc_hdr_desc_t;
@@ -114,7 +114,7 @@ struct ucdc_call_mgmt_descriptor
rt_uint8_t length;
rt_uint8_t type;
rt_uint8_t subtype;
- rt_uint8_t capabilties;
+ rt_uint8_t capabilties;
rt_uint8_t data_interface;
};
typedef struct ucdc_call_mgmt_descriptor* ucdc_call_mgmt_desc_t;
@@ -136,9 +136,9 @@ struct ucdc_comm_descriptor
#endif
struct uinterface_descriptor intf_desc;
struct ucdc_header_descriptor hdr_desc;
- struct ucdc_call_mgmt_descriptor call_mgmt_desc;
- struct ucdc_acm_descriptor acm_desc;
- struct ucdc_union_descriptor union_desc;
+ struct ucdc_call_mgmt_descriptor call_mgmt_desc;
+ struct ucdc_acm_descriptor acm_desc;
+ struct ucdc_union_descriptor union_desc;
struct uendpoint_descriptor ep_desc;
};
typedef struct ucdc_comm_descriptor* ucdc_comm_desc_t;
@@ -170,7 +170,7 @@ typedef struct ucdc_eth_descriptor* ucdc_eth_desc_t;
struct ucdc_data_descriptor
{
struct uinterface_descriptor intf_desc;
- struct uendpoint_descriptor ep_out_desc;
+ struct uendpoint_descriptor ep_out_desc;
struct uendpoint_descriptor ep_in_desc;
};
typedef struct ucdc_data_descriptor* ucdc_data_desc_t;
diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c
index ca9576ed2e..73a6629a66 100644
--- a/components/drivers/usb/usbdevice/class/cdc_vcom.c
+++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2012-10-02 Yi Qiu first version
- * 2012-12-12 heyuanjie87 change endpoints and function handler
+ * 2012-12-12 heyuanjie87 change endpoints and function handler
* 2013-06-25 heyuanjie87 remove SOF mechinism
* 2013-07-20 Yi Qiu do more test
* 2016-02-01 Urey Fix some error
@@ -142,23 +142,23 @@ const static struct ucdc_comm_descriptor _comm_desc =
USB_DESC_LENGTH_INTERFACE,
USB_DESC_TYPE_INTERFACE,
USB_DYNAMIC,
- 0x00,
+ 0x00,
0x01,
USB_CDC_CLASS_COMM,
USB_CDC_SUBCLASS_ACM,
USB_CDC_PROTOCOL_V25TER,
0x00,
},
- /* Header Functional Descriptor */
+ /* Header Functional Descriptor */
{
- 0x05,
+ 0x05,
USB_CDC_CS_INTERFACE,
USB_CDC_SCS_HEADER,
0x0110,
},
- /* Call Management Functional Descriptor */
+ /* Call Management Functional Descriptor */
{
- 0x05,
+ 0x05,
USB_CDC_CS_INTERFACE,
USB_CDC_SCS_CALL_MGMT,
0x00,
@@ -171,7 +171,7 @@ const static struct ucdc_comm_descriptor _comm_desc =
USB_CDC_SCS_ACM,
0x02,
},
- /* Union Functional Descriptor */
+ /* Union Functional Descriptor */
{
0x05,
USB_CDC_CS_INTERFACE,
@@ -179,7 +179,7 @@ const static struct ucdc_comm_descriptor _comm_desc =
USB_DYNAMIC,
USB_DYNAMIC,
},
- /* Endpoint Descriptor */
+ /* Endpoint Descriptor */
{
USB_DESC_LENGTH_ENDPOINT,
USB_DESC_TYPE_ENDPOINT,
@@ -200,27 +200,27 @@ const static struct ucdc_data_descriptor _data_desc =
USB_DESC_TYPE_INTERFACE,
USB_DYNAMIC,
0x00,
- 0x02,
+ 0x02,
USB_CDC_CLASS_DATA,
- 0x00,
- 0x00,
- 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
},
/* endpoint, bulk out */
{
- USB_DESC_LENGTH_ENDPOINT,
+ USB_DESC_LENGTH_ENDPOINT,
USB_DESC_TYPE_ENDPOINT,
USB_DYNAMIC | USB_DIR_OUT,
- USB_EP_ATTR_BULK,
+ USB_EP_ATTR_BULK,
USB_CDC_BUFSIZE,
- 0x00,
+ 0x00,
},
/* endpoint, bulk in */
{
USB_DESC_LENGTH_ENDPOINT,
USB_DESC_TYPE_ENDPOINT,
USB_DYNAMIC | USB_DIR_IN,
- USB_EP_ATTR_BULK,
+ USB_EP_ATTR_BULK,
USB_CDC_BUFSIZE,
0x00,
},
@@ -249,11 +249,11 @@ static void _vcom_reset_state(ufunction_t func)
{
struct vcom* data;
int lvl;
-
+
RT_ASSERT(func != RT_NULL)
data = (struct vcom*)func->user_data;
-
+
lvl = rt_hw_interrupt_disable();
data->connected = RT_FALSE;
data->in_sending = RT_FALSE;
@@ -295,9 +295,9 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
return RT_EOK;
}
-
+
rt_completion_done(&data->wait);
-
+
return RT_EOK;
}
@@ -392,7 +392,7 @@ static rt_err_t _cdc_set_line_coding_callback(udevice_t device, rt_size_t size)
RT_DEBUG_LOG(RT_DEBUG_USB, ("_cdc_set_line_coding_callback\n"));
dcd_ep0_send_status(device->dcd);
-
+
return RT_EOK;
}
@@ -434,7 +434,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
RT_ASSERT(setup != RT_NULL);
data = (struct vcom*)func->user_data;
-
+
switch(setup->bRequest)
{
case CDC_SEND_ENCAPSULATED_COMMAND:
@@ -484,17 +484,17 @@ static rt_err_t _function_enable(ufunction_t func)
RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc function enable\n"));
_vcom_reset_state(func);
-
+
data = (struct vcom*)func->user_data;
data->ep_out->buffer = rt_malloc(CDC_RX_BUFSIZE);
RT_ASSERT(data->ep_out->buffer != RT_NULL);
data->ep_out->request.buffer = data->ep_out->buffer;
data->ep_out->request.size = EP_MAXPACKET(data->ep_out);
-
+
data->ep_out->request.req_type = UIO_REQUEST_READ_BEST;
rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request);
-
+
return RT_EOK;
}
@@ -519,7 +519,7 @@ static rt_err_t _function_disable(ufunction_t func)
if(data->ep_out->buffer != RT_NULL)
{
rt_free(data->ep_out->buffer);
- data->ep_out->buffer = RT_NULL;
+ data->ep_out->buffer = RT_NULL;
}
return RT_EOK;
@@ -540,7 +540,7 @@ static struct ufunction_ops ops =
*
* @return RT_EOK on successful.
*/
-static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm,
+static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm,
rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr)
{
comm->call_mgmt_desc.data_interface = dintf_nr;
@@ -580,19 +580,19 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
}
/* set usb device string description */
rt_usbd_device_set_string(device, _ustring);
-
+
/* create a cdc function */
func = rt_usbd_function_new(device, &dev_desc, &ops);
-
+
/* support HS */
rt_usbd_device_set_qualifier(device, &dev_qualifier);
-
+
/* allocate memory for cdc vcom data */
data = (struct vcom*)rt_malloc(sizeof(struct vcom));
RT_ASSERT(data != RT_NULL);
rt_memset(data, 0, sizeof(struct vcom));
func->user_data = (void*)data;
-
+
/* initilize vcom */
rt_usb_vcom_init(func);
@@ -642,7 +642,7 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
/* add the cdc data interface to cdc function */
rt_usbd_function_add_interface(func, intf_data);
-
+
return func;
}
@@ -678,7 +678,7 @@ static int _vcom_getc(struct rt_serial_device *serial)
rt_uint32_t level;
struct ufunction *func;
struct vcom *data;
-
+
func = (struct ufunction*)serial->parent.user_data;
data = (struct vcom*)func->user_data;
@@ -914,7 +914,7 @@ static void rt_usb_vcom_init(struct ufunction *func)
rt_err_t result = RT_EOK;
struct serial_configure config;
struct vcom *data = (struct vcom*)func->user_data;
-
+
/* initialize ring buffer */
rt_ringbuffer_init(&data->rx_ringbuffer, data->rx_rbp, CDC_RX_BUFSIZE);
rt_ringbuffer_init(&data->tx_ringbuffer, data->tx_rbp, CDC_TX_BUFSIZE);
@@ -948,9 +948,9 @@ static void rt_usb_vcom_init(struct ufunction *func)
vcom_thread_stack, VCOM_TASK_STK_SIZE,
16, 20);
result = rt_thread_startup(&vcom_thread);
- RT_ASSERT(result == RT_EOK);
+ RT_ASSERT(result == RT_EOK);
}
-struct udclass vcom_class =
+struct udclass vcom_class =
{
.rt_usbd_function_create = rt_usbd_function_cdc_create
};
diff --git a/components/drivers/usb/usbdevice/class/ecm.c b/components/drivers/usb/usbdevice/class/ecm.c
index 36557dad74..1550f8e1e2 100644
--- a/components/drivers/usb/usbdevice/class/ecm.c
+++ b/components/drivers/usb/usbdevice/class/ecm.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
*
@@ -44,9 +44,9 @@ struct rt_ecm_eth
ALIGN(4)
char rx_buffer[USB_ETH_MTU];
char tx_buffer[USB_ETH_MTU];
-
+
struct rt_semaphore tx_buffer_free;
-
+
};
typedef struct rt_ecm_eth * rt_ecm_eth_t;
@@ -207,7 +207,7 @@ static rt_err_t _cdc_send_notifi(ufunction_t func,ucdc_notification_code_t notif
_notifi.bNotificatinCode = notifi;
_notifi.wValue = wValue;
_notifi.wLength = wLength;
-
+
eps->ep_cmd->request.buffer = (void *)&_notifi;
eps->ep_cmd->request.size = 8;
eps->ep_cmd->request.req_type = UIO_REQUEST_WRITE;
@@ -220,7 +220,7 @@ static rt_err_t _ecm_set_eth_packet_filter(ufunction_t func, ureq_t setup)
{
rt_ecm_eth_t _ecm_eth = (rt_ecm_eth_t)func->user_data;
dcd_ep0_send_status(func->device->dcd);
-
+
/* send link up. */
eth_device_linkchange(&_ecm_eth->parent, RT_TRUE);
_cdc_send_notifi(func, UCDC_NOTIFI_NETWORK_CONNECTION, 1, 0);
@@ -292,7 +292,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
ecm_device->rx_size = ecm_device->rx_offset;
ecm_device->rx_offset = 0;
eth_device_ready(&ecm_device->parent);
-
+
}else
{
ecm_device->eps.ep_out->request.buffer = ecm_device->eps.ep_out->buffer;
@@ -427,7 +427,7 @@ rt_err_t rt_ecm_eth_tx(rt_device_t dev, struct pbuf* p)
rt_sem_release(&ecm_eth_dev->tx_buffer_free);
return result;
}
-
+
pbuffer = (char *)&ecm_eth_dev->tx_buffer;
for (q = p; q != NULL; q = q->next)
{
@@ -480,7 +480,7 @@ static rt_err_t _function_enable(ufunction_t func)
/* reset eth rx tx */
ecm_device->rx_size = 0;
ecm_device->rx_offset = 0;
-
+
eps->ep_out->request.buffer = (void *)eps->ep_out->buffer;
eps->ep_out->request.size = EP_MAXPACKET(eps->ep_out);
eps->ep_out->request.req_type = UIO_REQUEST_READ_BEST;
@@ -555,7 +555,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
ualtsetting_t comm_setting, data_setting;
ucdc_data_desc_t data_desc;
ucdc_eth_desc_t comm_desc;
-
+
/* parameter check */
RT_ASSERT(device != RT_NULL);
@@ -600,7 +600,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
rt_usbd_set_altsetting(intf_comm, 0);
/* add the communication interface to the cdc class */
rt_usbd_function_add_interface(cdc, intf_comm);
-
+
/* create a bulk in and a bulk out endpoint */
data_desc = (ucdc_data_desc_t)data_setting->desc;
eps->ep_out = rt_usbd_endpoint_new(&data_desc->ep_out_desc, _ep_out_handler);
@@ -648,14 +648,14 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
_ecm_eth->parent.eth_tx = rt_ecm_eth_tx;
/* register eth device */
eth_device_init(&_ecm_eth->parent, "u0");
-
+
/* send link up. */
eth_device_linkchange(&_ecm_eth->parent, RT_FALSE);
-
+
return cdc;
}
-struct udclass ecm_class =
+struct udclass ecm_class =
{
.rt_usbd_function_create = rt_usbd_function_ecm_create
};
diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c
index 52e50296a4..fae45bb0ea 100644
--- a/components/drivers/usb/usbdevice/class/hid.c
+++ b/components/drivers/usb/usbdevice/class/hid.c
@@ -3,7 +3,7 @@
* COPYRIGHT (C) 2008 - 2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Change Logs:
* Date Author Notes
* 2017-03-13 Urey the first version
@@ -621,12 +621,12 @@ static void hid_thread_entry(void* parameter)
struct hid_report report;
struct hid_s *hiddev;
hiddev = (struct hid_s *)parameter;
- while(1)
- {
- if(rt_mq_recv(&hiddev->hid_mq, &report, sizeof(report),RT_WAITING_FOREVER) != RT_EOK )
+ while(1)
+ {
+ if(rt_mq_recv(&hiddev->hid_mq, &report, sizeof(report),RT_WAITING_FOREVER) != RT_EOK )
continue;
- HID_Report_Received(&report);
- }
+ HID_Report_Received(&report);
+ }
}
#ifdef RT_USING_DEVICE_OPS
@@ -658,7 +658,7 @@ static void rt_usb_hid_init(struct ufunction *func)
rt_device_register(&hiddev->parent, "hidd", RT_DEVICE_FLAG_RDWR);
rt_mq_init(&hiddev->hid_mq, "hiddmq", hid_mq_pool, sizeof(struct hid_report),
sizeof(hid_mq_pool), RT_IPC_FLAG_FIFO);
-
+
rt_thread_init(&hid_thread, "hidd", hid_thread_entry, hiddev,
hid_thread_stack, sizeof(hid_thread_stack), RT_USBD_THREAD_PRIO, 20);
rt_thread_startup(&hid_thread);
@@ -689,7 +689,7 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
/* create a cdc function */
func = rt_usbd_function_new(device, &_dev_desc, &ops);
-
+
/* For high speed mode supporting */
rt_usbd_device_set_qualifier(device, &dev_qualifier);
@@ -730,7 +730,7 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
rt_usb_hid_init(func);
return func;
}
-struct udclass hid_class =
+struct udclass hid_class =
{
.rt_usbd_function_create = rt_usbd_function_hid_create
};
diff --git a/components/drivers/usb/usbdevice/class/hid.h b/components/drivers/usb/usbdevice/class/hid.h
index 4d0f314a11..2b6a4ad90a 100644
--- a/components/drivers/usb/usbdevice/class/hid.h
+++ b/components/drivers/usb/usbdevice/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
*
diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c
index 0cee2c3e16..89be813ad1 100644
--- a/components/drivers/usb/usbdevice/class/mstorage.c
+++ b/components/drivers/usb/usbdevice/class/mstorage.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
*
@@ -7,7 +7,7 @@
* Date Author Notes
* 2012-10-01 Yi Qiu first version
* 2012-11-25 Heyuanjie87 reduce the memory consumption
- * 2012-12-09 Heyuanjie87 change function and endpoint handler
+ * 2012-12-09 Heyuanjie87 change function and endpoint handler
* 2013-07-25 Yi Qiu update for USB CV test
*/
@@ -20,10 +20,10 @@
enum STAT
{
STAT_CBW,
- STAT_CMD,
+ STAT_CMD,
STAT_CSW,
STAT_RECEIVE,
- STAT_SEND,
+ STAT_SEND,
};
typedef enum
@@ -45,7 +45,7 @@ typedef rt_size_t (*cbw_handler)(ufunction_t func, ustorage_cbw_t cbw);
struct scsi_cmd
{
rt_uint16_t cmd;
- cbw_handler handler;
+ cbw_handler handler;
rt_size_t cmd_len;
CB_SIZE_TYPE type;
rt_size_t data_size;
@@ -53,10 +53,10 @@ struct scsi_cmd
};
struct mstorage
-{
+{
struct ustorage_csw csw_response;
uep_t ep_in;
- uep_t ep_out;
+ uep_t ep_out;
int status;
rt_uint32_t cb_data_size;
rt_device_t disk;
@@ -64,7 +64,7 @@ struct mstorage
rt_int32_t count;
rt_int32_t size;
struct scsi_cmd* processing;
- struct rt_device_blk_geometry geometry;
+ struct rt_device_blk_geometry geometry;
};
ALIGN(4)
@@ -179,9 +179,9 @@ static struct scsi_cmd cmd_data[] =
{SCSI_REQUEST_SENSE, _request_sense, 6, COUNT, 0, DIR_IN},
{SCSI_INQUIRY_CMD, _inquiry_cmd, 6, COUNT, 0, DIR_IN},
{SCSI_ALLOW_REMOVAL, _allow_removal, 6, FIXED, 0, DIR_NONE},
- {SCSI_MODE_SENSE_6, _mode_sense_6, 6, COUNT, 0, DIR_IN},
- {SCSI_START_STOP, _start_stop, 6, FIXED, 0, DIR_NONE},
- {SCSI_READ_CAPACITIES, _read_capacities, 10, COUNT, 0, DIR_NONE},
+ {SCSI_MODE_SENSE_6, _mode_sense_6, 6, COUNT, 0, DIR_IN},
+ {SCSI_START_STOP, _start_stop, 6, FIXED, 0, DIR_NONE},
+ {SCSI_READ_CAPACITIES, _read_capacities, 10, COUNT, 0, DIR_NONE},
{SCSI_READ_CAPACITY, _read_capacity, 10, FIXED, 8, DIR_IN},
{SCSI_READ_10, _read_10, 10, BLOCK_COUNT, 0, DIR_IN},
{SCSI_WRITE_10, _write_10, 10, BLOCK_COUNT, 0, DIR_OUT},
@@ -196,9 +196,9 @@ static void _send_status(ufunction_t func)
RT_DEBUG_LOG(RT_DEBUG_USB, ("_send_status\n"));
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
data->ep_in->request.buffer = (rt_uint8_t*)&data->csw_response;
- data->ep_in->request.size = SIZEOF_CSW;
+ data->ep_in->request.size = SIZEOF_CSW;
data->ep_in->request.req_type = UIO_REQUEST_WRITE;
rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request);
data->status = STAT_CSW;
@@ -209,13 +209,13 @@ static rt_size_t _test_unit_ready(ufunction_t func, ustorage_cbw_t cbw)
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_test_unit_ready\n"));
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
-
+
return 0;
}
@@ -224,7 +224,7 @@ static rt_size_t _allow_removal(ufunction_t func, ustorage_cbw_t cbw)
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_allow_removal\n"));
@@ -237,7 +237,7 @@ static rt_size_t _allow_removal(ufunction_t func, ustorage_cbw_t cbw)
/**
* This function will handle inquiry command request.
*
- * @param func the usb function object.
+ * @param func the usb function object.
* @param cbw the command block wrapper.
*
* @return RT_EOK on successful.
@@ -249,12 +249,12 @@ static rt_size_t _inquiry_cmd(ufunction_t func, ustorage_cbw_t cbw)
rt_uint8_t *buf;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_inquiry_cmd\n"));
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
*(rt_uint32_t*)&buf[0] = 0x0 | (0x80 << 8);
@@ -277,7 +277,7 @@ static rt_size_t _inquiry_cmd(ufunction_t func, ustorage_cbw_t cbw)
/**
* This function will handle sense request.
*
- * @param func the usb function object.
+ * @param func the usb function object.
* @param cbw the command block wrapper.
*
* @return RT_EOK on successful.
@@ -288,12 +288,12 @@ static rt_size_t _request_sense(ufunction_t func, ustorage_cbw_t cbw)
struct request_sense_data *buf;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_request_sense\n"));
-
- data = (struct mstorage*)func->user_data;
+
+ data = (struct mstorage*)func->user_data;
buf = (struct request_sense_data *)data->ep_in->buffer;
buf->ErrorCode = 0x70;
@@ -321,7 +321,7 @@ static rt_size_t _request_sense(ufunction_t func, ustorage_cbw_t cbw)
* This function will handle mode_sense_6 request.
*
* @param func the usb function object.
- * @param cbw the command block wrapper.
+ * @param cbw the command block wrapper.
*
* @return RT_EOK on successful.
*/
@@ -331,12 +331,12 @@ static rt_size_t _mode_sense_6(ufunction_t func, ustorage_cbw_t cbw)
rt_uint8_t *buf;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_mode_sense_6\n"));
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
buf[0] = 3;
buf[1] = 0;
@@ -356,7 +356,7 @@ static rt_size_t _mode_sense_6(ufunction_t func, ustorage_cbw_t cbw)
/**
* This function will handle read_capacities request.
*
- * @param func the usb function object.
+ * @param func the usb function object.
* @param cbw the command block wrapper.
*
* @return RT_EOK on successful.
@@ -368,12 +368,12 @@ static rt_size_t _read_capacities(ufunction_t func, ustorage_cbw_t cbw)
rt_uint32_t sector_count, sector_size;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacities\n"));
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
sector_count = data->geometry.sector_count;
sector_size = data->geometry.bytes_per_sector;
@@ -401,7 +401,7 @@ static rt_size_t _read_capacities(ufunction_t func, ustorage_cbw_t cbw)
/**
* This function will handle read_capacity request.
*
- * @param func the usb function object.
+ * @param func the usb function object.
* @param cbw the command block wapper.
*
* @return RT_EOK on successful.
@@ -414,13 +414,13 @@ static rt_size_t _read_capacity(ufunction_t func, ustorage_cbw_t cbw)
rt_uint32_t sector_count, sector_size;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacity\n"));
- data = (struct mstorage*)func->user_data;
- buf = data->ep_in->buffer;
+ data = (struct mstorage*)func->user_data;
+ buf = data->ep_in->buffer;
sector_count = data->geometry.sector_count - 1; /* Last Logical Block Address */
sector_size = data->geometry.bytes_per_sector;
@@ -455,19 +455,19 @@ static rt_size_t _read_10(ufunction_t func, ustorage_cbw_t cbw)
{
struct mstorage *data;
rt_size_t size;
-
+
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
data->block = cbw->cb[2]<<24 | cbw->cb[3]<<16 | cbw->cb[4]<<8 |
cbw->cb[5]<<0;
data->count = cbw->cb[7]<<8 | cbw->cb[8]<<0;
RT_ASSERT(data->count < data->geometry.sector_count);
- data->csw_response.data_reside = data->cb_data_size;
+ data->csw_response.data_reside = data->cb_data_size;
size = rt_device_read(data->disk, data->block, data->ep_in->buffer, 1);
if(size == 0)
{
@@ -475,11 +475,11 @@ static rt_size_t _read_10(ufunction_t func, ustorage_cbw_t cbw)
}
data->ep_in->request.buffer = data->ep_in->buffer;
- data->ep_in->request.size = data->geometry.bytes_per_sector;
- data->ep_in->request.req_type = UIO_REQUEST_WRITE;
+ data->ep_in->request.size = data->geometry.bytes_per_sector;
+ data->ep_in->request.req_type = UIO_REQUEST_WRITE;
rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request);
data->status = STAT_SEND;
-
+
return data->geometry.bytes_per_sector;
}
@@ -499,7 +499,7 @@ static rt_size_t _write_10(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
data->block = cbw->cb[2]<<24 | cbw->cb[3]<<16 | cbw->cb[4]<<8 |
cbw->cb[5]<<0;
@@ -511,13 +511,13 @@ static rt_size_t _write_10(ufunction_t func, ustorage_cbw_t cbw)
data->count, data->block, data->geometry.sector_count));
data->csw_response.data_reside = data->cb_data_size;
-
+
data->ep_out->request.buffer = data->ep_out->buffer;
- data->ep_out->request.size = data->geometry.bytes_per_sector;
+ data->ep_out->request.size = data->geometry.bytes_per_sector;
data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request);
data->status = STAT_RECEIVE;
-
+
return data->geometry.bytes_per_sector;
}
@@ -533,42 +533,42 @@ static rt_size_t _verify_10(ufunction_t func, ustorage_cbw_t cbw)
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_verify_10\n"));
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
-
+
return 0;
}
-static rt_size_t _start_stop(ufunction_t func,
+static rt_size_t _start_stop(ufunction_t func,
ustorage_cbw_t cbw)
{
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_start_stop\n"));
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
-
+
return 0;
}
static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
{
struct mstorage *data;
-
+
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_in_handler\n"));
-
- data = (struct mstorage*)func->user_data;
+
+ data = (struct mstorage*)func->user_data;
switch(data->status)
{
@@ -576,15 +576,15 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
if(data->ep_in->request.size != SIZEOF_CSW)
{
rt_kprintf("Size of csw command error\n");
- rt_usbd_ep_set_stall(func->device, data->ep_in);
+ rt_usbd_ep_set_stall(func->device, data->ep_in);
}
else
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("return to cbw status\n"));
data->ep_out->request.buffer = data->ep_out->buffer;
data->ep_out->request.size = SIZEOF_CBW;
- data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
- rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request);
+ data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
+ rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request);
data->status = STAT_CBW;
}
break;
@@ -597,47 +597,47 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
{
data->csw_response.data_reside -= data->ep_in->request.size;
if(data->csw_response.data_reside != 0)
- {
- RT_DEBUG_LOG(RT_DEBUG_USB, ("data_reside %d, request %d\n",
+ {
+ RT_DEBUG_LOG(RT_DEBUG_USB, ("data_reside %d, request %d\n",
data->csw_response.data_reside, data->ep_in->request.size));
if(data->processing->dir == DIR_OUT)
{
rt_usbd_ep_set_stall(func->device, data->ep_out);
}
else
- {
+ {
//rt_kprintf("warning:in stall path but not stall\n");
-
+
/* FIXME: Disable the operation or the disk cannot work. */
- //rt_usbd_ep_set_stall(func->device, data->ep_in);
+ //rt_usbd_ep_set_stall(func->device, data->ep_in);
}
data->csw_response.data_reside = 0;
}
}
_send_status(func);
break;
- case STAT_SEND:
+ case STAT_SEND:
data->csw_response.data_reside -= data->ep_in->request.size;
- data->count--;
- data->block++;
+ data->count--;
+ data->block++;
if(data->count > 0 && data->csw_response.data_reside > 0)
{
if(rt_device_read(data->disk, data->block, data->ep_in->buffer, 1) == 0)
{
rt_kprintf("disk read error\n");
rt_usbd_ep_set_stall(func->device, data->ep_in);
- return -RT_ERROR;
+ return -RT_ERROR;
}
data->ep_in->request.buffer = data->ep_in->buffer;
- data->ep_in->request.size = data->geometry.bytes_per_sector;
- data->ep_in->request.req_type = UIO_REQUEST_WRITE;
- rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request);
+ data->ep_in->request.size = data->geometry.bytes_per_sector;
+ data->ep_in->request.req_type = UIO_REQUEST_WRITE;
+ rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request);
}
else
{
- _send_status(func);
- }
+ _send_status(func);
+ }
break;
}
@@ -667,7 +667,7 @@ static struct scsi_cmd* _find_cbw_command(rt_uint16_t cmd)
{
if(cmd_data[i].cmd == cmd)
return &cmd_data[i];
- }
+ }
return RT_NULL;
}
@@ -681,7 +681,7 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd,
RT_ASSERT(cmd != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
if(cmd->cmd_len == 6)
{
switch(cmd->type)
@@ -695,9 +695,9 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd,
case FIXED:
data->cb_data_size = cmd->data_size;
break;
- default:
+ default:
break;
- }
+ }
}
else if(cmd->cmd_len == 10)
{
@@ -707,32 +707,32 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd,
data->cb_data_size = cbw->cb[7]<<8 | cbw->cb[8];
break;
case BLOCK_COUNT:
- data->cb_data_size = (cbw->cb[7]<<8 | cbw->cb[8]) *
+ data->cb_data_size = (cbw->cb[7]<<8 | cbw->cb[8]) *
data->geometry.bytes_per_sector;
break;
case FIXED:
data->cb_data_size = cmd->data_size;
break;
- default:
+ default:
break;
}
}
-
+
//workaround: for stability in full-speed mode
else if(cmd->cmd_len == 12)
{
switch(cmd->type)
{
case COUNT:
- data->cb_data_size = cbw->cb[4];
+ data->cb_data_size = cbw->cb[4];
break;
- default:
+ default:
break;
}
}
else
{
- rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
+ rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
}
}
@@ -745,7 +745,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
RT_ASSERT(cbw != RT_NULL);
RT_ASSERT(func != RT_NULL);
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
if(cmd->cmd_len != cbw->cb_len)
{
rt_kprintf("cb_len error\n");
@@ -776,7 +776,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
rt_kprintf("xfer_len > data_size\n");
return RT_FALSE;
}
-
+
if(cbw->xfer_len < data->cb_data_size)
{
rt_kprintf("xfer_len < data_size\n");
@@ -784,18 +784,18 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
data->csw_response.status = 1;
}
- return RT_TRUE;
+ return RT_TRUE;
}
static rt_size_t _cbw_handler(ufunction_t func, struct scsi_cmd* cmd,
ustorage_cbw_t cbw)
-{
+{
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_ASSERT(cmd->handler != RT_NULL);
-
+
data = (struct mstorage*)func->user_data;
data->processing = cmd;
return cmd->handler(func, cbw);
@@ -815,21 +815,21 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
struct scsi_cmd* cmd;
rt_size_t len;
struct ustorage_cbw* cbw;
-
+
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size));
-
+
data = (struct mstorage*)func->user_data;
- cbw = (struct ustorage_cbw*)data->ep_out->buffer;
+ cbw = (struct ustorage_cbw*)data->ep_out->buffer;
if(data->status == STAT_CBW)
{
/* dump cbw information */
if(cbw->signature != CBW_SIGNATURE || size != SIZEOF_CBW)
{
goto exit;
- }
+ }
data->csw_response.signature = CSW_SIGNATURE;
data->csw_response.tag = cbw->tag;
@@ -837,33 +837,33 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
data->csw_response.status = 0;
RT_DEBUG_LOG(RT_DEBUG_USB, ("ep_out reside %d\n", data->csw_response.data_reside));
-
+
cmd = _find_cbw_command(cbw->cb[0]);
if(cmd == RT_NULL)
{
rt_kprintf("can't find cbw command\n");
goto exit;
- }
+ }
_cb_len_calc(func, cmd, cbw);
if(!_cbw_verify(func, cmd, cbw))
{
goto exit;
}
-
+
len = _cbw_handler(func, cmd, cbw);
if(len == 0)
{
_send_status(func);
- }
-
- return RT_EOK;
+ }
+
+ return RT_EOK;
}
else if(data->status == STAT_RECEIVE)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("\nwrite size %d block 0x%x oount 0x%x\n",
size, data->block, data->size));
-
+
data->size -= size;
data->csw_response.data_reside -= size;
@@ -872,10 +872,10 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
if(data->csw_response.data_reside != 0)
{
data->ep_out->request.buffer = data->ep_out->buffer;
- data->ep_out->request.size = data->geometry.bytes_per_sector;
- data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
+ data->ep_out->request.size = data->geometry.bytes_per_sector;
+ data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request);
- data->block ++;
+ data->block ++;
}
else
{
@@ -900,7 +900,7 @@ exit:
}
data->csw_response.status = 1;
_send_status(func);
-
+
return -RT_ERROR;
}
@@ -915,21 +915,21 @@ exit:
static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
{
rt_uint8_t lun = 0;
-
+
RT_ASSERT(func != RT_NULL);
- RT_ASSERT(func->device != RT_NULL);
+ RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("mstorage_interface_handler\n"));
switch(setup->bRequest)
{
- case USBREQ_GET_MAX_LUN:
-
+ case USBREQ_GET_MAX_LUN:
+
RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_GET_MAX_LUN\n"));
-
+
if(setup->wValue || setup->wLength != 1)
- {
+ {
rt_usbd_ep0_set_stall(func->device);
}
else
@@ -940,14 +940,14 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
case USBREQ_MASS_STORAGE_RESET:
RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_MASS_STORAGE_RESET\n"));
-
+
if(setup->wValue || setup->wLength != 0)
{
rt_usbd_ep0_set_stall(func->device);
}
else
- {
- dcd_ep0_send_status(func->device->dcd);
+ {
+ dcd_ep0_send_status(func->device->dcd);
}
break;
default:
@@ -984,14 +984,14 @@ static rt_err_t _function_enable(ufunction_t func)
rt_kprintf("disk open error\n");
return -RT_ERROR;
}
-
- if(rt_device_control(data->disk, RT_DEVICE_CTRL_BLK_GETGEOME,
+
+ if(rt_device_control(data->disk, RT_DEVICE_CTRL_BLK_GETGEOME,
(void*)&data->geometry) != RT_EOK)
{
rt_kprintf("get disk info error\n");
return -RT_ERROR;
}
-
+
data->ep_in->buffer = (rt_uint8_t*)rt_malloc(data->geometry.bytes_per_sector);
if(data->ep_in->buffer == RT_NULL)
{
@@ -1004,14 +1004,14 @@ static rt_err_t _function_enable(ufunction_t func)
rt_free(data->ep_in->buffer);
rt_kprintf("no memory\n");
return -RT_ENOMEM;
- }
-
+ }
+
/* prepare to read CBW request */
data->ep_out->request.buffer = data->ep_out->buffer;
- data->ep_out->request.size = SIZEOF_CBW;
- data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
+ data->ep_out->request.size = SIZEOF_CBW;
+ data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request);
-
+
return RT_EOK;
}
@@ -1029,11 +1029,11 @@ static rt_err_t _function_disable(ufunction_t func)
RT_DEBUG_LOG(RT_DEBUG_USB, ("Mass storage function disabled\n"));
- data = (struct mstorage*)func->user_data;
+ data = (struct mstorage*)func->user_data;
if(data->ep_in->buffer != RT_NULL)
{
rt_free(data->ep_in->buffer);
- data->ep_in->buffer = RT_NULL;
+ data->ep_in->buffer = RT_NULL;
}
if(data->ep_out->buffer != RT_NULL)
@@ -1046,9 +1046,9 @@ static rt_err_t _function_disable(ufunction_t func)
rt_device_close(data->disk);
data->disk = RT_NULL;
}
-
+
data->status = STAT_CBW;
-
+
return RT_EOK;
}
@@ -1087,11 +1087,11 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
/* set usb device string description */
rt_usbd_device_set_string(device, _ustring);
-
+
/* create a mass storage function */
func = rt_usbd_function_new(device, &dev_desc, &ops);
device->dev_qualifier = &dev_qualifier;
-
+
/* allocate memory for mass storage function data */
data = (struct mstorage*)rt_malloc(sizeof(struct mstorage));
rt_memset(data, 0, sizeof(struct mstorage));
@@ -1102,7 +1102,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
/* create an alternate setting object */
setting = rt_usbd_altsetting_new(sizeof(struct umass_descriptor));
-
+
/* config desc in alternate setting */
rt_usbd_altsetting_config_descriptor(setting, &_mass_desc, (rt_off_t)&((umass_desc_t)0)->intf_desc);
@@ -1127,7 +1127,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
return func;
}
-struct udclass msc_class =
+struct udclass msc_class =
{
.rt_usbd_function_create = rt_usbd_function_mstorage_create
};
diff --git a/components/drivers/usb/usbdevice/class/mstorage.h b/components/drivers/usb/usbdevice/class/mstorage.h
index 254038195b..6c81809ef2 100644
--- a/components/drivers/usb/usbdevice/class/mstorage.h
+++ b/components/drivers/usb/usbdevice/class/mstorage.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
*
@@ -8,7 +8,7 @@
* 2012-10-01 Yi Qiu first version
* 2012-12-12 heyuanjie87 add MASS endpoints collection
*/
-
+
#ifndef __MSTORAGE_H__
#define __MSTORAGE_H__
@@ -23,7 +23,7 @@ struct umass_descriptor
#endif
struct uinterface_descriptor intf_desc;
struct uendpoint_descriptor ep_out_desc;
- struct uendpoint_descriptor ep_in_desc;
+ struct uendpoint_descriptor ep_in_desc;
};
typedef struct umass_descriptor* umass_desc_t;
diff --git a/components/drivers/usb/usbdevice/class/ndis.h b/components/drivers/usb/usbdevice/class/ndis.h
index 6d6943366e..b83f3c78ec 100644
--- a/components/drivers/usb/usbdevice/class/ndis.h
+++ b/components/drivers/usb/usbdevice/class/ndis.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
*
@@ -7,14 +7,14 @@
* Date Author Notes
*/
/*
- * ndis.h
- *
+ * ndis.h
+ *
* Modified by Colin O'Flynn <[email protected]>
* ntddndis.h modified by Benedikt Spranger <[email protected]>
- *
- * Thanks to the cygwin development team,
+ *
+ * Thanks to the cygwin development team,
* espacially to Casper S. Hornstrup <[email protected]>
- *
+ *
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
@@ -30,7 +30,7 @@
#ifndef __NDIS_H__
#define __NDIS_H__
-#define NDIS_STATUS_MULTICAST_FULL 0xC0010009
+#define NDIS_STATUS_MULTICAST_FULL 0xC0010009
#define NDIS_STATUS_MULTICAST_EXISTS 0xC001000A
#define NDIS_STATUS_MULTICAST_NOT_FOUND 0xC001000B
@@ -42,21 +42,21 @@
#define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
#define OID_PNP_ENABLE_WAKE_UP 0xFD010106
-enum NDIS_DEVICE_POWER_STATE
+enum NDIS_DEVICE_POWER_STATE
{
- NdisDeviceStateUnspecified = 0,
- NdisDeviceStateD0,
- NdisDeviceStateD1,
- NdisDeviceStateD2,
- NdisDeviceStateD3,
- NdisDeviceStateMaximum
+ NdisDeviceStateUnspecified = 0,
+ NdisDeviceStateD0,
+ NdisDeviceStateD1,
+ NdisDeviceStateD2,
+ NdisDeviceStateD3,
+ NdisDeviceStateMaximum
};
struct NDIS_PM_WAKE_UP_CAPABILITIES
{
- enum NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp;
- enum NDIS_DEVICE_POWER_STATE MinPatternWakeUp;
- enum NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp;
+ enum NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp;
+ enum NDIS_DEVICE_POWER_STATE MinPatternWakeUp;
+ enum NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp;
};
/* NDIS_PNP_CAPABILITIES.Flags constants */
@@ -194,36 +194,36 @@ struct NDIS_PM_WAKE_UP_CAPABILITIES
#define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS 0x00800000
#define NDIS_MINIPORT_64BITS_DMA 0x01000000
-#define NDIS_MEDIUM_802_3 0x00000000
-#define NDIS_MEDIUM_802_5 0x00000001
-#define NDIS_MEDIUM_FDDI 0x00000002
-#define NDIS_MEDIUM_WAN 0x00000003
-#define NDIS_MEDIUM_LOCAL_TALK 0x00000004
-#define NDIS_MEDIUM_DIX 0x00000005
+#define NDIS_MEDIUM_802_3 0x00000000
+#define NDIS_MEDIUM_802_5 0x00000001
+#define NDIS_MEDIUM_FDDI 0x00000002
+#define NDIS_MEDIUM_WAN 0x00000003
+#define NDIS_MEDIUM_LOCAL_TALK 0x00000004
+#define NDIS_MEDIUM_DIX 0x00000005
#define NDIS_MEDIUM_ARCENT_RAW 0x00000006
#define NDIS_MEDIUM_ARCENT_878_2 0x00000007
-#define NDIS_MEDIUM_ATM 0x00000008
+#define NDIS_MEDIUM_ATM 0x00000008
#define NDIS_MEDIUM_WIRELESS_LAN 0x00000009
-#define NDIS_MEDIUM_IRDA 0x0000000A
-#define NDIS_MEDIUM_BPC 0x0000000B
-#define NDIS_MEDIUM_CO_WAN 0x0000000C
-#define NDIS_MEDIUM_1394 0x0000000D
+#define NDIS_MEDIUM_IRDA 0x0000000A
+#define NDIS_MEDIUM_BPC 0x0000000B
+#define NDIS_MEDIUM_CO_WAN 0x0000000C
+#define NDIS_MEDIUM_1394 0x0000000D
-#define NDIS_PACKET_TYPE_DIRECTED 0x00000001
-#define NDIS_PACKET_TYPE_MULTICAST 0x00000002
-#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
-#define NDIS_PACKET_TYPE_BROADCAST 0x00000008
-#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
-#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
-#define NDIS_PACKET_TYPE_SMT 0x00000040
-#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
-#define NDIS_PACKET_TYPE_GROUP 0x00000100
-#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
-#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
-#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
+#define NDIS_PACKET_TYPE_DIRECTED 0x00000001
+#define NDIS_PACKET_TYPE_MULTICAST 0x00000002
+#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
+#define NDIS_PACKET_TYPE_BROADCAST 0x00000008
+#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
+#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
+#define NDIS_PACKET_TYPE_SMT 0x00000040
+#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
+#define NDIS_PACKET_TYPE_GROUP 0x00000100
+#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
+#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
+#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
-#define NDIS_MEDIA_STATE_CONNECTED 0x00000000
-#define NDIS_MEDIA_STATE_DISCONNECTED 0x00000001
+#define NDIS_MEDIA_STATE_CONNECTED 0x00000000
+#define NDIS_MEDIA_STATE_DISCONNECTED 0x00000001
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002
diff --git a/components/drivers/usb/usbdevice/class/rndis.c b/components/drivers/usb/usbdevice/class/rndis.c
index 93e0ba6ae2..391924dba0 100644
--- a/components/drivers/usb/usbdevice/class/rndis.c
+++ b/components/drivers/usb/usbdevice/class/rndis.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
*
@@ -215,7 +215,7 @@ const static char* _ustring[] =
};
ALIGN(4)
-struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
+struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
{
.bFirstInterfaceNumber = USB_DYNAMIC,
.reserved1 = 0x01,
@@ -347,7 +347,7 @@ static rt_err_t _rndis_init_response(ufunction_t func, rndis_init_msg_t msg)
rt_list_insert_before(&((rt_rndis_eth_t)func->user_data)->response_list, &response->list);
rt_hw_interrupt_enable(level);
}
-
+
return RT_EOK;
}
@@ -764,7 +764,7 @@ static rt_err_t send_encapsulated_command_done(udevice_t device, rt_size_t size)
}
//#error here have bug ep 0x82 send failed
static rt_err_t _rndis_send_encapsulated_command(ufunction_t func, ureq_t setup)
-{
+{
RT_ASSERT(setup->wLength <= sizeof(rndis_message_buffer));
function = func;
rt_usbd_ep0_read(func->device,rndis_message_buffer,setup->wLength,send_encapsulated_command_done);
@@ -808,7 +808,7 @@ static rt_err_t _rndis_get_encapsulated_response(ufunction_t func, ureq_t setup)
data[1] = 0;
((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.buffer = ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->buffer;
((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.size = 8;
- ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.req_type = UIO_REQUEST_WRITE;
+ ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.req_type = UIO_REQUEST_WRITE;
rt_usbd_io_request(func->device, ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd, &((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request);
}
else
@@ -983,7 +983,7 @@ static rt_err_t _function_enable(ufunction_t func)
((rt_rndis_eth_t)func->user_data)->need_notify = RT_TRUE;
rt_hw_interrupt_enable(level);
}
-
+
return RT_EOK;
}
@@ -1022,7 +1022,7 @@ static rt_err_t _function_disable(ufunction_t func)
rt_hw_interrupt_enable(level);
}
-
+
/* link down. */
eth_device_linkchange(&((rt_rndis_eth_t)func->user_data)->parent, RT_FALSE);
@@ -1323,7 +1323,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
/* create a cdc class */
cdc = rt_usbd_function_new(device, &_dev_desc, &ops);
rt_usbd_device_set_qualifier(device, &dev_qualifier);
- _rndis= rt_malloc(sizeof(struct rt_rndis_eth));
+ _rndis= rt_malloc(sizeof(struct rt_rndis_eth));
rt_memset(_rndis, 0, sizeof(struct rt_rndis_eth));
cdc->user_data = _rndis;
@@ -1357,7 +1357,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
rt_usbd_set_altsetting(intf_comm, 0);
/* add the communication interface to the cdc class */
rt_usbd_function_add_interface(cdc, intf_comm);
-
+
/* create a bulk in and a bulk out endpoint */
data_desc = (ucdc_data_desc_t)data_setting->desc;
eps->ep_out = rt_usbd_endpoint_new(&data_desc->ep_out_desc, _ep_out_handler);
@@ -1434,7 +1434,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
return cdc;
}
-struct udclass rndis_class =
+struct udclass rndis_class =
{
.rt_usbd_function_create = rt_usbd_function_rndis_create
};
diff --git a/components/drivers/usb/usbdevice/class/rndis.h b/components/drivers/usb/usbdevice/class/rndis.h
index fcdd249984..f25ae4931c 100644
--- a/components/drivers/usb/usbdevice/class/rndis.h
+++ b/components/drivers/usb/usbdevice/class/rndis.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
*
@@ -13,43 +13,43 @@
#include <rtthread.h>
-#define USB_ETH_MTU 1500+14
+#define USB_ETH_MTU 1500+14
#define RNDIS_MESSAGE_BUFFER_SIZE 128
#define RESPONSE_AVAILABLE 0x00000001
/* Remote NDIS version numbers */
-#define RNDIS_MAJOR_VERSION 1
+#define RNDIS_MAJOR_VERSION 1
#define RNDIS_MINOR_VERSION 0
/* common status values */
-#define RNDIS_STATUS_SUCCESS 0X00000000
-#define RNDIS_STATUS_FAILURE 0XC0000001
-#define RNDIS_STATUS_INVALID_DATA 0XC0010015
-#define RNDIS_STATUS_NOT_SUPPORTED 0XC00000BB
-#define RNDIS_STATUS_MEDIA_CONNECT 0X4001000B
-#define RNDIS_STATUS_MEDIA_DISCONNECT 0X4001000C
+#define RNDIS_STATUS_SUCCESS 0X00000000
+#define RNDIS_STATUS_FAILURE 0XC0000001
+#define RNDIS_STATUS_INVALID_DATA 0XC0010015
+#define RNDIS_STATUS_NOT_SUPPORTED 0XC00000BB
+#define RNDIS_STATUS_MEDIA_CONNECT 0X4001000B
+#define RNDIS_STATUS_MEDIA_DISCONNECT 0X4001000C
/* Remote NDIS message types */
-#define REMOTE_NDIS_PACKET_MSG 0x00000001
-#define REMOTE_NDIS_INITIALIZE_MSG 0X00000002
-#define REMOTE_NDIS_HALT_MSG 0X00000003
-#define REMOTE_NDIS_QUERY_MSG 0X00000004
-#define REMOTE_NDIS_SET_MSG 0X00000005
-#define REMOTE_NDIS_RESET_MSG 0X00000006
+#define REMOTE_NDIS_PACKET_MSG 0x00000001
+#define REMOTE_NDIS_INITIALIZE_MSG 0X00000002
+#define REMOTE_NDIS_HALT_MSG 0X00000003
+#define REMOTE_NDIS_QUERY_MSG 0X00000004
+#define REMOTE_NDIS_SET_MSG 0X00000005
+#define REMOTE_NDIS_RESET_MSG 0X00000006
#define REMOTE_NDIS_INDICATE_STATUS_MSG 0X00000007
-#define REMOTE_NDIS_KEEPALIVE_MSG 0X00000008
-#define REMOTE_NDIS_INITIALIZE_CMPLT 0X80000002
-#define REMOTE_NDIS_QUERY_CMPLT 0X80000004
-#define REMOTE_NDIS_SET_CMPLT 0X80000005
-#define REMOTE_NDIS_RESET_CMPLT 0X80000006
-#define REMOTE_NDIS_KEEPALIVE_CMPLT 0X80000008
+#define REMOTE_NDIS_KEEPALIVE_MSG 0X00000008
+#define REMOTE_NDIS_INITIALIZE_CMPLT 0X80000002
+#define REMOTE_NDIS_QUERY_CMPLT 0X80000004
+#define REMOTE_NDIS_SET_CMPLT 0X80000005
+#define REMOTE_NDIS_RESET_CMPLT 0X80000006
+#define REMOTE_NDIS_KEEPALIVE_CMPLT 0X80000008
/* device flags */
-#define RNDIS_DF_CONNECTIONLESS 0x00000001
-#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
+#define RNDIS_DF_CONNECTIONLESS 0x00000001
+#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
/* mediums */
-#define RNDIS_MEDIUM_802_3 0x00000000
+#define RNDIS_MEDIUM_802_3 0x00000000
struct ucls_rndis
{
@@ -64,24 +64,24 @@ struct ucls_rndis
/* Remote NDIS generic message type */
struct rndis_gen_msg
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
};
typedef struct rndis_gen_msg* rndis_gen_msg_t;
struct rndis_packet_msg
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t DataOffset;
- rt_uint32_t DataLength;
- rt_uint32_t OOBDataOffset;
- rt_uint32_t OOBDataLength;
- rt_uint32_t NumOOBDataElements;
- rt_uint32_t PerPacketInfoOffset;
- rt_uint32_t PerPacketInfoLength;
- rt_uint32_t VcHandle;
- rt_uint32_t Reserved;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t DataOffset;
+ rt_uint32_t DataLength;
+ rt_uint32_t OOBDataOffset;
+ rt_uint32_t OOBDataLength;
+ rt_uint32_t NumOOBDataElements;
+ rt_uint32_t PerPacketInfoOffset;
+ rt_uint32_t PerPacketInfoLength;
+ rt_uint32_t VcHandle;
+ rt_uint32_t Reserved;
};
typedef struct rndis_packet_msg* rndis_packet_msg_t;
@@ -89,132 +89,132 @@ typedef struct rndis_packet_msg* rndis_packet_msg_t;
struct rndis_init_msg
{
rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
- rt_uint32_t MajorVersion;
- rt_uint32_t MinorVersion;
- rt_uint32_t MaxTransferSize;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
+ rt_uint32_t MajorVersion;
+ rt_uint32_t MinorVersion;
+ rt_uint32_t MaxTransferSize;
};
typedef struct rndis_init_msg* rndis_init_msg_t;
/* Response */
struct rndis_init_cmplt
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
- rt_uint32_t Status;
- rt_uint32_t MajorVersion;
- rt_uint32_t MinorVersion;
- rt_uint32_t DeviceFlags;
- rt_uint32_t Medium;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
+ rt_uint32_t Status;
+ rt_uint32_t MajorVersion;
+ rt_uint32_t MinorVersion;
+ rt_uint32_t DeviceFlags;
+ rt_uint32_t Medium;
rt_uint32_t MaxPacketsPerTransfer;
- rt_uint32_t MaxTransferSize;
+ rt_uint32_t MaxTransferSize;
rt_uint32_t PacketAlignmentFactor;
- rt_uint32_t AfListOffset;
- rt_uint32_t AfListSize;
+ rt_uint32_t AfListOffset;
+ rt_uint32_t AfListSize;
};
typedef struct rndis_init_cmplt* rndis_init_cmplt_t;
/* Remote NDIS Halt Message */
struct rndis_halt_msg
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
};
/* Remote NDIS Query Message */
struct rndis_query_msg
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
- rt_uint32_t Oid;
- rt_uint32_t InformationBufferLength;
- rt_uint32_t InformationBufferOffset;
- rt_uint32_t DeviceVcHandle;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
+ rt_uint32_t Oid;
+ rt_uint32_t InformationBufferLength;
+ rt_uint32_t InformationBufferOffset;
+ rt_uint32_t DeviceVcHandle;
};
typedef struct rndis_query_msg* rndis_query_msg_t;
/* Response */
struct rndis_query_cmplt
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
- rt_uint32_t Status;
- rt_uint32_t InformationBufferLength;
- rt_uint32_t InformationBufferOffset;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
+ rt_uint32_t Status;
+ rt_uint32_t InformationBufferLength;
+ rt_uint32_t InformationBufferOffset;
};
typedef struct rndis_query_cmplt* rndis_query_cmplt_t;
/* Remote NDIS Set Message */
struct rndis_set_msg
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
- rt_uint32_t Oid;
- rt_uint32_t InformationBufferLength;
- rt_uint32_t InformationBufferOffset;
- rt_uint32_t DeviceVcHandle;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
+ rt_uint32_t Oid;
+ rt_uint32_t InformationBufferLength;
+ rt_uint32_t InformationBufferOffset;
+ rt_uint32_t DeviceVcHandle;
};
typedef struct rndis_set_msg* rndis_set_msg_t;
/* Response */
struct rndis_set_cmplt
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
- rt_uint32_t Status;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
+ rt_uint32_t Status;
};
typedef struct rndis_set_cmplt* rndis_set_cmplt_t;
/* Remote NDIS Soft Reset Message */
struct rndis_reset_msg
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t Reserved;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t Reserved;
};
/* Remote NDIS Soft Reset Response */
struct rndis_reset_cmplt
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t Status;
- rt_uint32_t AddressingReset;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t Status;
+ rt_uint32_t AddressingReset;
};
/* Remote NDIS Indicate Status Message */
struct rndis_indicate_status_msg
{
rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t Status;
- rt_uint32_t StatusBufferLength;
- rt_uint32_t StatusBufferOffset;
+ rt_uint32_t MessageLength;
+ rt_uint32_t Status;
+ rt_uint32_t StatusBufferLength;
+ rt_uint32_t StatusBufferOffset;
};
typedef struct rndis_indicate_status_msg* rndis_indicate_status_msg_t;
struct rndis_keepalive_msg
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestID;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestID;
};
typedef struct rndis_keepalive_msg* rndis_keepalive_msg_t;
/* Response: */
struct rndis_keepalive_cmplt
{
- rt_uint32_t MessageType;
- rt_uint32_t MessageLength;
- rt_uint32_t RequestId;
- rt_uint32_t Status;
+ rt_uint32_t MessageType;
+ rt_uint32_t MessageLength;
+ rt_uint32_t RequestId;
+ rt_uint32_t Status;
};
typedef struct rndis_keepalive_cmplt* rndis_keepalive_cmplt_t;
diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c
index 4af6dba3cf..0db3de794a 100644
--- a/components/drivers/usb/usbdevice/class/winusb.c
+++ b/components/drivers/usb/usbdevice/class/winusb.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
*
@@ -57,7 +57,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
};
ALIGN(4)
-struct winusb_descriptor _winusb_desc =
+struct winusb_descriptor _winusb_desc =
{
#ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */
@@ -117,13 +117,13 @@ const static char* _ustring[] =
};
ALIGN(4)
-struct usb_os_proerty winusb_proerty[] =
+struct usb_os_proerty winusb_proerty[] =
{
USB_OS_PROPERTY_DESC(USB_OS_PROPERTY_TYPE_REG_SZ,"DeviceInterfaceGUID",RT_WINUSB_GUID),
};
ALIGN(4)
-struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc =
+struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc =
{
.bFirstInterfaceNumber = USB_DYNAMIC,
.reserved1 = 0x01,
@@ -155,7 +155,7 @@ static ufunction_t cmd_func = RT_NULL;
static rt_err_t _ep0_cmd_handler(udevice_t device, rt_size_t size)
{
winusb_device_t winusb_device;
-
+
if(cmd_func != RT_NULL)
{
winusb_device = (winusb_device_t)cmd_func->user_data;
@@ -191,7 +191,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
_ep0_cmd_read(func, setup);
break;
}
-
+
return RT_EOK;
}
static rt_err_t _function_enable(ufunction_t func)
@@ -291,7 +291,7 @@ static rt_err_t rt_usb_winusb_init(ufunction_t func)
winusb_device->parent.user_data = func;
-
+
return rt_device_register(&winusb_device->parent, "winusb", RT_DEVICE_FLAG_RDWR);
}
@@ -352,7 +352,7 @@ ufunction_t rt_usbd_function_winusb_create(udevice_t device)
return func;
}
-struct udclass winusb_class =
+struct udclass winusb_class =
{
.rt_usbd_function_create = rt_usbd_function_winusb_create
};
diff --git a/components/drivers/usb/usbdevice/class/winusb.h b/components/drivers/usb/usbdevice/class/winusb.h
index b5f87b4e56..43fec34b6a 100644
--- a/components/drivers/usb/usbdevice/class/winusb.h
+++ b/components/drivers/usb/usbdevice/class/winusb.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
*
diff --git a/components/drivers/usb/usbdevice/core/usbdevice.c b/components/drivers/usb/usbdevice/core/usbdevice.c
index 2455bd8017..246b3f5aef 100644
--- a/components/drivers/usb/usbdevice/core/usbdevice.c
+++ b/components/drivers/usb/usbdevice/core/usbdevice.c
@@ -3,7 +3,7 @@
* COPYRIGHT (C) 2008 - 2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Change Logs:
* Date Author Notes
* 2012-10-02 Yi Qiu first version
@@ -62,7 +62,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
};
#endif
-struct usb_os_comp_id_descriptor usb_comp_id_desc =
+struct usb_os_comp_id_descriptor usb_comp_id_desc =
{
//head section
{
diff --git a/components/drivers/usb/usbdevice/core/usbdevice_core.c b/components/drivers/usb/usbdevice/core/usbdevice_core.c
index ef569d7bf2..fd205ad37f 100644
--- a/components/drivers/usb/usbdevice/core/usbdevice_core.c
+++ b/components/drivers/usb/usbdevice/core/usbdevice_core.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
*
@@ -238,7 +238,7 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup)
rt_uint8_t value;
uintf_t intf;
ufunction_t func;
-
+
/* parameter check */
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
@@ -262,7 +262,7 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup)
{
intf->handler(func, setup);
}
-
+
return RT_EOK;
}
@@ -293,7 +293,7 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup)
rt_usbd_ep0_set_stall(device);
return -RT_ERROR;
}
-
+
/* find the specified interface */
intf = rt_usbd_find_interface(device, setup->wIndex & 0xFF, &func);
@@ -309,12 +309,12 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup)
dcd_ep_enable(device->dcd, ep);
}
dcd_ep0_send_status(device->dcd);
-
+
if (intf->handler)
{
intf->handler(func, setup);
}
-
+
return RT_EOK;
}
@@ -336,7 +336,7 @@ static rt_err_t _get_config(struct udevice* device, ureq_t setup)
RT_ASSERT(device->curr_cfg != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_config\n"));
-
+
if (device->state == USB_STATE_CONFIGURED)
{
/* get current configuration */
@@ -443,7 +443,7 @@ static rt_err_t _set_address(struct udevice* device, ureq_t setup)
dcd_ep0_send_status(device->dcd);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_set_address\n"));
-
+
device->state = USB_STATE_ADDRESS;
return RT_EOK;
@@ -479,7 +479,7 @@ static rt_err_t _request_interface(struct udevice* device, ureq_t setup)
{
ret = -RT_ERROR;
}
-
+
return ret;
}
@@ -564,9 +564,9 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
case USB_REQ_GET_STATUS:
{
uep_t ep;
-
+
ep = rt_usbd_find_endpoint(device, RT_NULL, setup->wIndex);
- value = ep->stalled;
+ value = ep->stalled;
rt_usbd_ep0_write(device, &value, 2);
}
break;
@@ -581,13 +581,13 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
{
rt_usbd_clear_feature(device, setup->wValue, setup->wIndex);
dcd_ep0_send_status(dcd);
- ep->stalled = RT_FALSE;
+ ep->stalled = RT_FALSE;
for (node = ep->request_list.next; node != &ep->request_list; node = node->next)
{
- req = (uio_request_t)rt_list_entry(node, struct uio_request, list);
+ req = (uio_request_t)rt_list_entry(node, struct uio_request, list);
rt_usbd_io_request(device, ep, req);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("fired a request\n"));
+ RT_DEBUG_LOG(RT_DEBUG_USB, ("fired a request\n"));
}
rt_list_init(&ep->request_list);
@@ -601,10 +601,10 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
if(USB_EP_HALT == setup->wValue)
{
ep = rt_usbd_find_endpoint(device, RT_NULL, setup->wIndex);
- ep->stalled = RT_TRUE;
+ ep->stalled = RT_TRUE;
rt_usbd_set_feature(device, setup->wValue, setup->wIndex);
dcd_ep0_send_status(dcd);
- }
+ }
}
break;
case USB_REQ_SYNCH_FRAME:
@@ -698,7 +698,7 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup)
{
rt_uint8_t * pusb_comp_id_desc;
rt_list_t *p;
- usb_comp_id_desc_size = sizeof(struct usb_os_header_comp_id_descriptor) +
+ usb_comp_id_desc_size = sizeof(struct usb_os_header_comp_id_descriptor) +
(sizeof(struct usb_os_function_comp_id_descriptor)-sizeof(rt_list_t))*rt_list_len(&device->os_comp_id_desc->func_desc);
usb_comp_id_desc = (rt_uint8_t *)rt_malloc(usb_comp_id_desc_size);
@@ -707,7 +707,7 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup)
pusb_comp_id_desc = usb_comp_id_desc;
rt_memcpy((void *)pusb_comp_id_desc,(void *)&device->os_comp_id_desc->head_desc,sizeof(struct usb_os_header_comp_id_descriptor));
pusb_comp_id_desc += sizeof(struct usb_os_header_comp_id_descriptor);
-
+
for (p = device->os_comp_id_desc->func_desc.next; p != &device->os_comp_id_desc->func_desc; p = p->next)
{
func_comp_id_desc = rt_list_entry(p,struct usb_os_function_comp_id_descriptor,list);
@@ -726,7 +726,7 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup)
}
break;
}
-
+
break;
}
return RT_EOK;
@@ -784,7 +784,7 @@ static rt_err_t _setup_request(udevice_t device, ureq_t setup)
/**
* This function will hanle data notify event.
*
- * @param device the usb device object.
+ * @param device the usb device object.
* @param ep_msg the endpoint message.
*
* @return RT_EOK.
@@ -794,18 +794,18 @@ static rt_err_t _data_notify(udevice_t device, struct ep_msg* ep_msg)
uep_t ep;
ufunction_t func;
rt_size_t size = 0;
-
+
RT_ASSERT(device != RT_NULL);
RT_ASSERT(ep_msg != RT_NULL);
-
+
if (device->state != USB_STATE_CONFIGURED)
{
return -RT_ERROR;
}
-
+
ep = rt_usbd_find_endpoint(device, &func, ep_msg->ep_addr);
if(ep == RT_NULL)
- {
+ {
rt_kprintf("invalid endpoint\n");
return -RT_ERROR;
}
@@ -817,7 +817,7 @@ static rt_err_t _data_notify(udevice_t device, struct ep_msg* ep_msg)
{
dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer, EP_MAXPACKET(ep));
ep->request.remain_size -= EP_MAXPACKET(ep);
- ep->request.buffer += EP_MAXPACKET(ep);
+ ep->request.buffer += EP_MAXPACKET(ep);
}
else if(ep->request.remain_size > 0)
{
@@ -834,9 +834,9 @@ static rt_err_t _data_notify(udevice_t device, struct ep_msg* ep_msg)
size = ep_msg->size;
if(ep->request.remain_size == 0)
{
- return RT_EOK;
+ return RT_EOK;
}
-
+
if(size == 0)
{
size = dcd_ep_read(device->dcd, EP_ADDRESS(ep), ep->request.buffer);
@@ -865,9 +865,9 @@ static rt_err_t _ep0_out_notify(udevice_t device, struct ep_msg* ep_msg)
{
uep_t ep0;
rt_size_t size;
-
+
RT_ASSERT(device != RT_NULL);
- RT_ASSERT(ep_msg != RT_NULL);
+ RT_ASSERT(ep_msg != RT_NULL);
RT_ASSERT(device->dcd != RT_NULL);
ep0 = &device->dcd->ep0;
@@ -875,18 +875,18 @@ static rt_err_t _ep0_out_notify(udevice_t device, struct ep_msg* ep_msg)
if(ep0->request.remain_size == 0)
{
- return RT_EOK;
- }
+ return RT_EOK;
+ }
if(size == 0)
{
size = dcd_ep_read(device->dcd, EP0_OUT_ADDR, ep0->request.buffer);
if(size == 0)
{
return RT_EOK;
- }
+ }
}
- ep0->request.remain_size -= size;
+ ep0->request.remain_size -= size;
ep0->request.buffer += size;
if(ep0->request.remain_size == 0)
{
@@ -894,7 +894,7 @@ static rt_err_t _ep0_out_notify(udevice_t device, struct ep_msg* ep_msg)
if(ep0->rx_indicate != RT_NULL)
{
ep0->rx_indicate(device, size);
- }
+ }
}
else
{
@@ -959,10 +959,10 @@ static rt_err_t _stop_notify(udevice_t device)
static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_size_t size)
{
rt_uint16_t maxpacket;
-
- RT_ASSERT(device != RT_NULL);
+
+ RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->dcd != RT_NULL);
- RT_ASSERT(ep != RT_NULL);
+ RT_ASSERT(ep != RT_NULL);
rt_enter_critical();
maxpacket = EP_MAXPACKET(ep);
@@ -970,11 +970,11 @@ static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_s
{
dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer, maxpacket);
ep->request.remain_size -= maxpacket;
- ep->request.buffer += maxpacket;
+ ep->request.buffer += maxpacket;
}
else
{
- dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer,
+ dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer,
ep->request.remain_size);
ep->request.remain_size = 0;
}
@@ -984,9 +984,9 @@ static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_s
static rt_size_t rt_usbd_ep_read_prepare(udevice_t device, uep_t ep, void *buffer, rt_size_t size)
{
- RT_ASSERT(device != RT_NULL);
+ RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->dcd != RT_NULL);
- RT_ASSERT(ep != RT_NULL);
+ RT_ASSERT(ep != RT_NULL);
RT_ASSERT(buffer != RT_NULL);
RT_ASSERT(ep->ep_desc != RT_NULL);
@@ -1705,7 +1705,7 @@ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value)
device->curr_cfg = cfg;
dcd_set_config(device->dcd, value);
-
+
return RT_TRUE;
}
@@ -1713,7 +1713,7 @@ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value)
* This function will bRequest an IO transaction.
*
* @param device the usb device object.
- * @param ep the endpoint object.
+ * @param ep the endpoint object.
* @param req IO bRequest.
*
* @return RT_EOK.
@@ -1721,7 +1721,7 @@ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value)
rt_size_t rt_usbd_io_request(udevice_t device, uep_t ep, uio_request_t req)
{
rt_size_t size = 0;
-
+
RT_ASSERT(device != RT_NULL);
RT_ASSERT(req != RT_NULL);
@@ -1747,7 +1747,7 @@ rt_size_t rt_usbd_io_request(udevice_t device, uep_t ep, uio_request_t req)
{
rt_list_insert_before(&ep->request_list, &req->list);
RT_DEBUG_LOG(RT_DEBUG_USB, ("suspend a request\n"));
- }
+ }
return size;
}
@@ -1770,10 +1770,10 @@ rt_err_t rt_usbd_set_feature(udevice_t device, rt_uint16_t value, rt_uint16_t in
}
else if (value == USB_FEATURE_ENDPOINT_HALT)
{
- RT_DEBUG_LOG(RT_DEBUG_USB, ("set feature stall\n"));
+ RT_DEBUG_LOG(RT_DEBUG_USB, ("set feature stall\n"));
dcd_ep_set_stall(device->dcd, (rt_uint32_t)(index & 0xFF));
}
-
+
return RT_EOK;
}
@@ -1798,38 +1798,38 @@ rt_err_t rt_usbd_clear_feature(udevice_t device, rt_uint16_t value, rt_uint16_t
RT_DEBUG_LOG(RT_DEBUG_USB, ("clear feature stall\n"));
dcd_ep_clear_stall(device->dcd, (rt_uint32_t)(index & 0xFF));
}
-
+
return RT_EOK;
}
rt_err_t rt_usbd_ep0_set_stall(udevice_t device)
{
RT_ASSERT(device != RT_NULL);
-
+
return dcd_ep_set_stall(device->dcd, 0);
}
rt_err_t rt_usbd_ep0_clear_stall(udevice_t device)
{
RT_ASSERT(device != RT_NULL);
-
+
return dcd_ep_clear_stall(device->dcd, 0);
}
rt_err_t rt_usbd_ep_set_stall(udevice_t device, uep_t ep)
{
rt_err_t ret;
-
+
RT_ASSERT(device != RT_NULL);
RT_ASSERT(ep != RT_NULL);
- RT_ASSERT(ep->ep_desc != RT_NULL);
+ RT_ASSERT(ep->ep_desc != RT_NULL);
ret = dcd_ep_set_stall(device->dcd, EP_ADDRESS(ep));
if(ret == RT_EOK)
{
ep->stalled = RT_TRUE;
}
-
+
return ret;
}
@@ -1846,44 +1846,44 @@ rt_err_t rt_usbd_ep_clear_stall(udevice_t device, uep_t ep)
{
ep->stalled = RT_FALSE;
}
-
+
return ret;
}
static rt_err_t rt_usbd_ep_assign(udevice_t device, uep_t ep)
{
int i = 0;
-
+
RT_ASSERT(device != RT_NULL);
- RT_ASSERT(device->dcd != RT_NULL);
- RT_ASSERT(device->dcd->ep_pool != RT_NULL);
+ RT_ASSERT(device->dcd != RT_NULL);
+ RT_ASSERT(device->dcd->ep_pool != RT_NULL);
RT_ASSERT(ep != RT_NULL);
RT_ASSERT(ep->ep_desc != RT_NULL);
while(device->dcd->ep_pool[i].addr != 0xFF)
{
- if(device->dcd->ep_pool[i].status == ID_UNASSIGNED &&
+ if(device->dcd->ep_pool[i].status == ID_UNASSIGNED &&
ep->ep_desc->bmAttributes == device->dcd->ep_pool[i].type && (EP_ADDRESS(ep) & 0x80) == device->dcd->ep_pool[i].dir)
{
EP_ADDRESS(ep) |= device->dcd->ep_pool[i].addr;
ep->id = &device->dcd->ep_pool[i];
device->dcd->ep_pool[i].status = ID_ASSIGNED;
- RT_DEBUG_LOG(RT_DEBUG_USB, ("assigned %d\n", device->dcd->ep_pool[i].addr));
+ RT_DEBUG_LOG(RT_DEBUG_USB, ("assigned %d\n", device->dcd->ep_pool[i].addr));
return RT_EOK;
}
-
+
i++;
}
-
+
return -RT_ERROR;
}
rt_err_t rt_usbd_ep_unassign(udevice_t device, uep_t ep)
{
RT_ASSERT(device != RT_NULL);
- RT_ASSERT(device->dcd != RT_NULL);
- RT_ASSERT(device->dcd->ep_pool != RT_NULL);
+ RT_ASSERT(device->dcd != RT_NULL);
+ RT_ASSERT(device->dcd->ep_pool != RT_NULL);
RT_ASSERT(ep != RT_NULL);
RT_ASSERT(ep->ep_desc != RT_NULL);
@@ -1911,8 +1911,8 @@ rt_err_t rt_usbd_ep0_setup_handler(udcd_t dcd, struct urequest* setup)
else
{
rt_memcpy((void*)&msg.content.setup, (void*)setup, sizeof(struct urequest));
- }
-
+ }
+
msg.type = USB_MSG_SETUP_NOTIFY;
msg.dcd = dcd;
rt_usbd_event_signal(&msg);
@@ -2011,7 +2011,7 @@ rt_err_t rt_usbd_reset_handler(udcd_t dcd)
struct udev_msg msg;
RT_ASSERT(dcd != RT_NULL);
-
+
msg.type = USB_MSG_RESET;
msg.dcd = dcd;
rt_usbd_event_signal(&msg);
@@ -2024,7 +2024,7 @@ rt_err_t rt_usbd_connect_handler(udcd_t dcd)
struct udev_msg msg;
RT_ASSERT(dcd != RT_NULL);
-
+
msg.type = USB_MSG_PLUG_IN;
msg.dcd = dcd;
rt_usbd_event_signal(&msg);
@@ -2037,7 +2037,7 @@ rt_err_t rt_usbd_disconnect_handler(udcd_t dcd)
struct udev_msg msg;
RT_ASSERT(dcd != RT_NULL);
-
+
msg.type = USB_MSG_PLUG_OUT;
msg.dcd = dcd;
rt_usbd_event_signal(&msg);
@@ -2050,7 +2050,7 @@ rt_err_t rt_usbd_sof_handler(udcd_t dcd)
struct udev_msg msg;
RT_ASSERT(dcd != RT_NULL);
-
+
msg.type = USB_MSG_SOF;
msg.dcd = dcd;
rt_usbd_event_signal(&msg);
@@ -2063,7 +2063,7 @@ rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size)
uep_t ep0;
rt_size_t sent_size = 0;
- RT_ASSERT(device != RT_NULL);
+ RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->dcd != RT_NULL);
RT_ASSERT(buffer != RT_NULL);
RT_ASSERT(size > 0);
@@ -2085,7 +2085,7 @@ rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size)
return dcd_ep_write(device->dcd, EP0_IN_ADDR, ep0->request.buffer, sent_size);
}
-rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size,
+rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size,
rt_err_t (*rx_ind)(udevice_t device, rt_size_t size))
{
uep_t ep0;
@@ -2096,7 +2096,7 @@ rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size,
RT_ASSERT(buffer != RT_NULL);
ep0 = &device->dcd->ep0;
- ep0->request.buffer = (rt_uint8_t *)buffer;
+ ep0->request.buffer = (rt_uint8_t *)buffer;
ep0->request.remain_size = size;
ep0->rx_indicate = rx_ind;
if(size >= ep0->id->maxpacket)
@@ -2143,7 +2143,7 @@ static void rt_usbd_thread_entry(void* parameter)
}
RT_DEBUG_LOG(RT_DEBUG_USB, ("message type %d\n", msg.type));
-
+
switch (msg.type)
{
case USB_MSG_SOF:
@@ -2160,7 +2160,7 @@ static void rt_usbd_thread_entry(void* parameter)
case USB_MSG_EP0_OUT:
_ep0_out_notify(device, &msg.content.ep_msg);
break;
- case USB_MSG_RESET:
+ case USB_MSG_RESET:
RT_DEBUG_LOG(RT_DEBUG_USB, ("reset %d\n", device->state));
if (device->state == USB_STATE_ADDRESS || device->state == USB_STATE_CONFIGURED)
_stop_notify(device);
@@ -2170,7 +2170,7 @@ static void rt_usbd_thread_entry(void* parameter)
device->state = USB_STATE_ATTACHED;
break;
case USB_MSG_PLUG_OUT:
- device->state = USB_STATE_NOTATTACHED;
+ device->state = USB_STATE_NOTATTACHED;
_stop_notify(device);
break;
default:
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
*
diff --git a/components/drivers/usb/usbhost/core/driver.c b/components/drivers/usb/usbhost/core/driver.c
index 37327108c1..6dad1409a0 100644
--- a/components/drivers/usb/usbhost/core/driver.c
+++ b/components/drivers/usb/usbhost/core/driver.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
*
@@ -17,21 +17,21 @@ static rt_list_t _driver_list;
/**
* This function will initilize the usb class driver related data structure,
* and it should be invoked in the usb system initialization.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_class_driver_init(void)
{
rt_list_init(&_driver_list);
- return RT_EOK;
+ return RT_EOK;
}
/**
* This function will register an usb class driver to the class driver manager.
*
* @param drv the pointer of the usb class driver.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
@@ -41,15 +41,15 @@ rt_err_t rt_usbh_class_driver_register(ucd_t drv)
/* insert class driver into driver list */
rt_list_insert_after(&_driver_list, &(drv->list));
-
- return RT_EOK;
+
+ return RT_EOK;
}
/**
* This function will removes a previously registed usb class driver.
*
* @param drv the pointer of the usb class driver structure.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_class_driver_unregister(ucd_t drv)
@@ -67,7 +67,7 @@ rt_err_t rt_usbh_class_driver_unregister(ucd_t drv)
*
* @param drv the pointer of usb class driver.
* @param args the parameter of run function.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_class_driver_enable(ucd_t drv, void* args)
@@ -85,7 +85,7 @@ rt_err_t rt_usbh_class_driver_enable(ucd_t drv, void* args)
*
* @param drv the pointer of usb class driver structure.
* @param args the argument of the stop function.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_class_driver_disable(ucd_t drv, void* args)
@@ -102,7 +102,7 @@ rt_err_t rt_usbh_class_driver_disable(ucd_t drv, void* args)
/**
* This function finds a usb class driver by specified class code and subclass code.
*
- * @param class_code the usb class driver's class code.
+ * @param class_code the usb class driver's class code.
* @param subclass_code the usb class driver's sub class code.
*
* @return the registered usb class driver on successful, or RT_NULL on failure.
@@ -118,7 +118,7 @@ ucd_t rt_usbh_class_driver_find(int class_code, int subclass_code)
/* try to find driver object */
for (node = _driver_list.next; node != &_driver_list; node = node->next)
{
- ucd_t drv =
+ ucd_t drv =
(ucd_t)rt_list_entry(node, struct uclass_driver, list);
if (drv->class_code == class_code)
{
diff --git a/components/drivers/usb/usbhost/core/hub.c b/components/drivers/usb/usbhost/core/hub.c
index eefa571472..b6381ec300 100644
--- a/components/drivers/usb/usbhost/core/hub.c
+++ b/components/drivers/usb/usbhost/core/hub.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
*
@@ -77,7 +77,7 @@ static rt_err_t root_hub_ctrl(struct uhcd *hcd, rt_uint16_t port, rt_uint8_t cmd
return RT_ERROR;
}
return RT_EOK;
-}
+}
void rt_usbh_root_hub_connect_handler(struct uhcd *hcd, rt_uint8_t port, rt_bool_t isHS)
{
struct uhost_msg msg;
@@ -106,23 +106,23 @@ void rt_usbh_root_hub_disconnect_handler(struct uhcd *hcd, rt_uint8_t port)
}
/**
- * This function will do USB_REQ_GET_DESCRIPTOR bRequest for the device instance
+ * This function will do USB_REQ_GET_DESCRIPTOR bRequest for the device instance
* to get usb hub descriptor.
*
* @param intf the interface instance.
* @buffer the data buffer to save usb hub descriptor.
* @param nbytes the size of buffer
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer, rt_size_t nbytes)
{
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(device != RT_NULL);
-
+
setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_DEVICE;
setup.bRequest = USB_REQ_GET_DESCRIPTOR;
setup.wIndex = 0;
@@ -135,24 +135,24 @@ rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer
{
return RT_EOK;
}
- }
- return -RT_FALSE;
+ }
+ return -RT_FALSE;
}
/**
- * This function will do USB_REQ_GET_STATUS bRequest for the device instance
+ * This function will do USB_REQ_GET_STATUS bRequest for the device instance
* to get usb hub status.
*
* @param intf the interface instance.
* @buffer the data buffer to save usb hub status.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint32_t* buffer)
{
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(device != RT_NULL);
@@ -168,31 +168,31 @@ rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint32_t* buffer)
return RT_EOK;
}
}
- return -RT_FALSE;
+ return -RT_FALSE;
}
/**
- * This function will do USB_REQ_GET_STATUS bRequest for the device instance
+ * This function will do USB_REQ_GET_STATUS bRequest for the device instance
* to get hub port status.
*
* @param intf the interface instance.
* @port the hub port to get status.
* @buffer the data buffer to save usb hub status.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hub_get_port_status(uhub_t hub, rt_uint16_t port, rt_uint32_t* buffer)
{
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(hub != RT_NULL);
/* get roothub port status */
if(hub->is_roothub)
{
- root_hub_ctrl(hub->hcd, port, RH_GET_PORT_STATUS,
+ root_hub_ctrl(hub->hcd, port, RH_GET_PORT_STATUS,
(void*)buffer);
return RT_EOK;
}
@@ -210,36 +210,36 @@ rt_err_t rt_usbh_hub_get_port_status(uhub_t hub, rt_uint16_t port, rt_uint32_t*
return RT_EOK;
}
}
- return -RT_FALSE;
+ return -RT_FALSE;
}
/**
- * This function will do USB_REQ_CLEAR_FEATURE bRequest for the device instance
+ * This function will do USB_REQ_CLEAR_FEATURE bRequest for the device instance
* to clear feature of the hub port.
*
* @param intf the interface instance.
* @port the hub port.
* @feature feature to be cleared.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port, rt_uint16_t feature)
{
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(hub != RT_NULL);
/* clear roothub feature */
if(hub->is_roothub)
{
- root_hub_ctrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE,
+ root_hub_ctrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE,
(void*)(rt_uint32_t)feature);
return RT_EOK;
}
- 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_OTHER;
setup.bRequest = USB_REQ_CLEAR_FEATURE;
setup.wIndex = port;
@@ -250,37 +250,37 @@ rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port, rt_uint16_
{
return RT_EOK;
}
- return -RT_FALSE;
+ return -RT_FALSE;
}
/**
- * This function will do USB_REQ_SET_FEATURE bRequest for the device instance
+ * This function will do USB_REQ_SET_FEATURE bRequest for the device instance
* to set feature of the hub port.
*
* @param intf the interface instance.
* @port the hub port.
* @feature feature to be set.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port,
+rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port,
rt_uint16_t feature)
{
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
-
+
/* parameter check */
RT_ASSERT(hub != RT_NULL);
/* clear roothub feature */
if(hub->is_roothub)
{
- root_hub_ctrl(hub->hcd, port, RH_SET_PORT_FEATURE,
+ root_hub_ctrl(hub->hcd, port, RH_SET_PORT_FEATURE,
(void*)(rt_uint32_t)feature);
return RT_EOK;
}
- 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_OTHER;
setup.bRequest = USB_REQ_SET_FEATURE;
setup.wIndex = port;
@@ -291,7 +291,7 @@ rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port,
{
return RT_EOK;
}
- else return -RT_FALSE;
+ else return -RT_FALSE;
}
/**
@@ -299,17 +299,17 @@ rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port,
*
* @param intf the interface instance.
* @param port the hub port.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hub_reset_port(uhub_t hub, rt_uint16_t port)
{
rt_err_t ret;
rt_uint32_t pstatus;
-
+
/* parameter check */
RT_ASSERT(hub != RT_NULL);
-
+
rt_thread_delay(50);
/* reset hub port */
@@ -321,12 +321,12 @@ rt_err_t rt_usbh_hub_reset_port(uhub_t hub, rt_uint16_t port)
ret = rt_usbh_hub_get_port_status(hub, port, &pstatus);
if(!(pstatus & PORT_PRS)) break;
}
-
+
/* clear port reset feature */
- ret = rt_usbh_hub_clear_port_feature(hub, port, PORT_FEAT_C_RESET);
+ ret = rt_usbh_hub_clear_port_feature(hub, port, PORT_FEAT_C_RESET);
if(ret != RT_EOK) return ret;
- rt_thread_delay(50);
+ rt_thread_delay(50);
return RT_EOK;
}
@@ -336,7 +336,7 @@ rt_err_t rt_usbh_hub_reset_port(uhub_t hub, rt_uint16_t port)
*
* @param device the usb instance.
* @param port the hub port.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port)
@@ -356,15 +356,15 @@ rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port)
{
ret = rt_usbh_hub_get_port_status(hub, port, &pstatus);
if(ret != RT_EOK) return ret;
-
- if(!(pstatus & PORT_CCS))
+
+ if(!(pstatus & PORT_CCS))
{
connect = RT_FALSE;
break;
}
-
+
rt_thread_delay(delayticks);
- }
+ }
if(connect) return RT_EOK;
else return -RT_ERROR;
@@ -375,7 +375,7 @@ rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port)
* disconnect events.
*
* @param intf the interface instance.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
@@ -386,7 +386,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
/* parameter check */
RT_ASSERT(hub != RT_NULL);
- /* get usb device instance */
+ /* get usb device instance */
for (i = 0; i < hub->num_ports; i++)
{
rt_err_t ret;
@@ -394,7 +394,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
rt_uint32_t pstatus = 0;
reconnect = RT_FALSE;
-
+
/* get hub port status */
ret = rt_usbh_hub_get_port_status(hub, i + 1, &pstatus);
if(ret != RT_EOK) continue;
@@ -402,8 +402,8 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
RT_DEBUG_LOG(RT_DEBUG_USB, ("port %d status 0x%x\n", i + 1, pstatus));
/* check port status change */
- if (pstatus & PORT_CCSC)
- {
+ if (pstatus & PORT_CCSC)
+ {
/* clear port status change feature */
rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_CONNECTION);
reconnect = RT_TRUE;
@@ -411,39 +411,39 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
if(pstatus & PORT_PESC)
{
- rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_ENABLE);
+ rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_ENABLE);
reconnect = RT_TRUE;
}
-
+
if(reconnect)
- {
+ {
if(hub->child[i] != RT_NULL && hub->child[i]->status != DEV_STATUS_IDLE)
- {
+ {
rt_usbh_detach_instance(hub->child[i]);
/* Child device have been detach. Set hub->child[i] to NULL. */
hub->child[i] = RT_NULL;
}
-
+
ret = rt_usbh_hub_port_debounce(hub, i + 1);
if(ret != RT_EOK) continue;
-
+
/* allocate an usb instance for new connected device */
device = rt_usbh_alloc_instance(hub->hcd);
if(device == RT_NULL) break;
-
+
/* set usb device speed */
device->speed = (pstatus & PORT_LSDA) ? 1 : 0;
- device->parent_hub = hub;
+ device->parent_hub = hub;
device->hcd = hub->hcd;
device->port = i + 1;
hub->child[i] = device;
/* reset usb roothub port */
rt_usbh_hub_reset_port(hub, i + 1);
-
+
/* attatch the usb instance to the hcd */
- rt_usbh_attatch_instance(device);
+ rt_usbh_attatch_instance(device);
}
}
@@ -454,7 +454,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
* This function is the callback function of hub's int endpoint, it is invoked when data comes.
*
* @param context the context of the callback function.
- *
+ *
* @return none.
*/
static void rt_usbh_hub_irq(void* context)
@@ -462,9 +462,9 @@ static void rt_usbh_hub_irq(void* context)
upipe_t pipe;
uhub_t hub;
int timeout = USB_TIMEOUT_BASIC;
-
+
RT_ASSERT(context != RT_NULL);
-
+
pipe = (upipe_t)context;
hub = (uhub_t)pipe->user_data;
@@ -473,14 +473,14 @@ static void rt_usbh_hub_irq(void* context)
RT_DEBUG_LOG(RT_DEBUG_USB,("hub irq error\n"));
return;
}
-
+
rt_usbh_hub_port_change(hub);
RT_DEBUG_LOG(RT_DEBUG_USB,("hub int xfer...\n"));
/* parameter check */
RT_ASSERT(pipe->inst->hcd != RT_NULL);
-
+
rt_usb_hcd_pipe_xfer(hub->self->hcd, pipe, hub->buffer, pipe->ep.wMaxPacketSize, timeout);
}
@@ -489,7 +489,7 @@ static void rt_usbh_hub_irq(void* context)
* as a hub class device, it will continue to do the enumulate process.
*
* @param arg the argument.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
@@ -505,7 +505,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
int timeout = USB_TIMEOUT_LONG;
/* paremeter check */
RT_ASSERT(intf != RT_NULL);
-
+
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_hub_run\n"));
/* get usb device instance */
@@ -515,7 +515,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
hub = rt_malloc(sizeof(struct uhub));
RT_ASSERT(hub != RT_NULL);
rt_memset(hub, 0, sizeof(struct uhub));
-
+
/* make interface instance's user data point to hub instance */
intf->user_data = (void*)hub;
@@ -524,17 +524,17 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
if(ret != RT_EOK)
{
rt_kprintf("get hub descriptor failed\n");
- return -RT_ERROR;
+ return -RT_ERROR;
}
/* get full hub descriptor */
- ret = rt_usbh_hub_get_descriptor(device, (rt_uint8_t*)&hub->hub_desc,
+ ret = rt_usbh_hub_get_descriptor(device, (rt_uint8_t*)&hub->hub_desc,
hub->hub_desc.length);
if(ret != RT_EOK)
{
rt_kprintf("get hub descriptor again failed\n");
- return -RT_ERROR;
- }
+ return -RT_ERROR;
+ }
/* get hub ports number */
/* If hub device supported ports over USB_HUB_PORT_NUM(Ex: 8 port hub). Set hub->num_ports to USB_HUB_PORT_NUM */
@@ -554,7 +554,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
* 2 * RT_TICK_PER_SECOND / 1000 );
}
- if(intf->intf_desc->bNumEndpoints != 1)
+ if(intf->intf_desc->bNumEndpoints != 1)
return -RT_ERROR;
/* get endpoint descriptor from interface descriptor */
@@ -565,12 +565,12 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
return -RT_ERROR;
}
- /* the endpoint type of hub class should be interrupt */
+ /* the endpoint type of hub class should be interrupt */
if( USB_EP_ATTR(ep_desc->bmAttributes) == USB_EP_ATTR_INT)
{
/* the endpoint direction of hub class should be in */
if(ep_desc->bEndpointAddress & USB_DIR_IN)
- {
+ {
/* allocate a pipe according to the endpoint type */
pipe_in = rt_usb_instance_find_pipe(device,ep_desc->bEndpointAddress);
if(pipe_in == RT_NULL)
@@ -585,17 +585,17 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
/* parameter check */
RT_ASSERT(device->hcd != RT_NULL);
pipe_in->user_data = hub;
- rt_usb_hcd_pipe_xfer(hub->hcd, pipe_in, hub->buffer,
+ rt_usb_hcd_pipe_xfer(hub->hcd, pipe_in, hub->buffer,
pipe_in->ep.wMaxPacketSize, timeout);
return RT_EOK;
}
/**
- * This function will be invoked when usb hub plug out is detected and it would clean
+ * This function will be invoked when usb hub 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_hub_disable(void* arg)
@@ -615,7 +615,7 @@ static rt_err_t rt_usbh_hub_disable(void* arg)
if(hub->child[i] != RT_NULL)
rt_usbh_detach_instance(hub->child[i]);
}
-
+
if(hub != RT_NULL) rt_free(hub);
return RT_EOK;
@@ -624,13 +624,13 @@ static rt_err_t rt_usbh_hub_disable(void* arg)
/**
* This function will register hub 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_hub(void)
-{
+{
hub_driver.class_code = USB_CLASS_HUB;
-
+
hub_driver.enable = rt_usbh_hub_enable;
hub_driver.disable = rt_usbh_hub_disable;
@@ -638,27 +638,27 @@ ucd_t rt_usbh_class_driver_hub(void)
}
/**
- * This function is the main entry of usb hub thread, it is in charge of
- * processing all messages received from the usb message buffer.
+ * This function is the main entry of usb hub thread, it is in charge of
+ * processing all messages received from the usb message buffer.
*
* @param parameter the parameter of the usb host thread.
- *
+ *
* @return none.
*/
static void rt_usbh_hub_thread_entry(void* 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(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));
-
+
switch (msg.type)
- {
+ {
case USB_MSG_CONNECT_CHANGE:
rt_usbh_hub_port_change(msg.content.hub);
break;
@@ -668,7 +668,7 @@ static void rt_usbh_hub_thread_entry(void* parameter)
break;
default:
break;
- }
+ }
}
}
@@ -676,8 +676,8 @@ static void rt_usbh_hub_thread_entry(void* parameter)
* This function will post an message to the usb message queue,
*
* @param msg the message to be posted
- *
- * @return the error code, RT_EOK on successfully.
+ *
+ * @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_event_signal(struct uhost_msg* msg)
{
@@ -693,7 +693,7 @@ rt_err_t rt_usbh_event_signal(struct uhost_msg* msg)
* This function will initialize usb hub thread.
*
* @return none.
- *
+ *
*/
void rt_usbh_hub_init(uhcd_t hcd)
{
@@ -705,9 +705,9 @@ void rt_usbh_hub_init(uhcd_t hcd)
root_hub.num_ports = hcd->num_ports;
/* create usb message queue */
usb_mq = rt_mq_create("usbh", 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("usbh", rt_usbh_hub_thread_entry, RT_NULL,
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..a76f6d4586 100644
--- a/components/drivers/usb/usbhost/core/usbhost.c
+++ b/components/drivers/usb/usbhost/core/usbhost.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
*
@@ -19,13 +19,13 @@
/**
* This function will initialize the usb host stack, all the usb class driver and
* host controller driver are also be initialized here.
- *
+ *
* @return none.
*/
rt_err_t rt_usb_host_init(void)
{
ucd_t drv;
- rt_device_t uhc;
+ rt_device_t uhc;
uhc = rt_device_find(USB_HOST_CONTROLLER_NAME);
if(uhc == RT_NULL)
diff --git a/components/drivers/usb/usbhost/core/usbhost_core.c b/components/drivers/usb/usbhost/core/usbhost_core.c
index d72dca82f2..71fe3b8b3f 100644
--- a/components/drivers/usb/usbhost/core/usbhost_core.c
+++ b/components/drivers/usb/usbhost/core/usbhost_core.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
*
@@ -27,28 +27,28 @@ uinst_t rt_usbh_alloc_instance(uhcd_t uhcd)
/* lock scheduler */
rt_enter_critical();
-
+
for(i=0; i<USB_MAX_DEVICE; i++)
{
/* to find an idle instance handle */
if(dev[i].status != DEV_STATUS_IDLE) continue;
-
+
/* initialize the usb device instance */
rt_memset(&dev[i], 0, sizeof(struct uinstance));
-
+
dev[i].status = DEV_STATUS_BUSY;
dev[i].index = i + 1;
dev[i].address = 0;
dev[i].max_packet_size = 0x8;
rt_list_init(&dev[i].pipe);
dev[i].hcd = uhcd;
- /* unlock scheduler */
+ /* unlock scheduler */
rt_exit_critical();
return &dev[i];
}
- /* unlock scheduler */
- rt_exit_critical();
+ /* unlock scheduler */
+ rt_exit_critical();
return RT_NULL;
}
@@ -59,10 +59,10 @@ uinst_t rt_usbh_alloc_instance(uhcd_t uhcd)
*
* @param hcd the host controller driver.
* @param device the usb device instance.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-static struct uendpoint_descriptor ep0_out_desc =
+static struct uendpoint_descriptor ep0_out_desc =
{
/*endpoint descriptor*/
USB_DESC_LENGTH_ENDPOINT,
@@ -72,7 +72,7 @@ static struct uendpoint_descriptor ep0_out_desc =
0x00,
0x00,
};
-static struct uendpoint_descriptor ep0_in_desc =
+static struct uendpoint_descriptor ep0_in_desc =
{
/*endpoint descriptor*/
USB_DESC_LENGTH_ENDPOINT,
@@ -95,10 +95,10 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
ucd_t drv;
RT_ASSERT(device != RT_NULL);
-
+
rt_memset(&cfg_desc, 0, sizeof(struct uconfig_descriptor));
dev_desc = &device->dev_desc;
-
+
/* alloc address 0 ep0 pipe*/
ep0_out_desc.wMaxPacketSize = 8;
ep0_in_desc.wMaxPacketSize = 8;
@@ -106,7 +106,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_in, device, &ep0_in_desc);
RT_DEBUG_LOG(RT_DEBUG_USB, ("start enumnation\n"));
-
+
/* get device descriptor head */
ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_DEVICE, (void*)dev_desc, 8);
if(ret != RT_EOK)
@@ -114,7 +114,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
rt_kprintf("get device descriptor head failed\n");
return ret;
}
-
+
/* reset bus */
rt_usbh_hub_reset_port(device->parent_hub, device->port);
rt_thread_delay(2);
@@ -127,20 +127,20 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
return ret;
}
/* free address 0 ep0 pipe*/
-
+
rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_out);
rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_in);
-
+
/* set device max packet size */
ep0_out_desc.wMaxPacketSize = device->dev_desc.bMaxPacketSize0;
ep0_in_desc.wMaxPacketSize = device->dev_desc.bMaxPacketSize0;
-
+
/* alloc true address ep0 pipe*/
rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_out, device, &ep0_out_desc);
rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_in, device, &ep0_in_desc);
RT_DEBUG_LOG(RT_DEBUG_USB, ("get device descriptor length %d\n",
dev_desc->bLength));
-
+
/* get full device descriptor again */
ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_DEVICE, (void*)dev_desc, dev_desc->bLength);
if(ret != RT_EOK)
@@ -169,7 +169,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
rt_memset(device->cfg_desc, 0, cfg_desc.wTotalLength);
/* get full configuration descriptor */
- ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_CONFIGURATION,
+ ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_CONFIGURATION,
device->cfg_desc, cfg_desc.wTotalLength);
if(ret != RT_EOK)
{
@@ -179,12 +179,12 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
/* set configuration */
ret = rt_usbh_set_configure(device, 1);
- if(ret != RT_EOK)
+ if(ret != RT_EOK)
{
return ret;
}
for(i=0; i<device->cfg_desc->bNumInterfaces; i++)
- {
+ {
/* get interface descriptor through configuration descriptor */
ret = rt_usbh_get_interface_descriptor(device->cfg_desc, i, &intf_desc);
if(ret != RT_EOK)
@@ -193,7 +193,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
return -RT_ERROR;
}
- RT_DEBUG_LOG(RT_DEBUG_USB, ("interface class 0x%x, subclass 0x%x\n",
+ RT_DEBUG_LOG(RT_DEBUG_USB, ("interface class 0x%x, subclass 0x%x\n",
intf_desc->bInterfaceClass,
intf_desc->bInterfaceSubClass));
/* alloc pipe*/
@@ -216,9 +216,9 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
}
}
/* find driver by class code found in interface descriptor */
- drv = rt_usbh_class_driver_find(intf_desc->bInterfaceClass,
+ drv = rt_usbh_class_driver_find(intf_desc->bInterfaceClass,
intf_desc->bInterfaceSubClass);
-
+
if(drv != RT_NULL)
{
/* allocate memory for interface device */
@@ -245,7 +245,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
continue;
}
}
-
+
return RT_EOK;
}
@@ -254,19 +254,19 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
* and release all resource.
*
* @param device the usb device instance.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_detach_instance(uinst_t device)
{
int i = 0;
rt_list_t * l;
- if(device == RT_NULL)
+ if(device == RT_NULL)
{
rt_kprintf("no usb instance to detach\n");
return -RT_ERROR;
}
-
+
/* free configration descriptor */
if (device->cfg_desc) {
for (i = 0; i < device->cfg_desc->bNumInterfaces; i++)
@@ -282,10 +282,10 @@ rt_err_t rt_usbh_detach_instance(uinst_t device)
}
rt_free(device->cfg_desc);
}
-
+
rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_out);
rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_in);
-
+
while(device->pipe.next!= &device->pipe)
{
l = device->pipe.next;
@@ -293,29 +293,29 @@ rt_err_t rt_usbh_detach_instance(uinst_t device)
rt_usb_hcd_free_pipe(device->hcd,rt_list_entry(l,struct upipe,list));
}
rt_memset(device, 0, sizeof(struct uinstance));
-
+
return RT_EOK;
}
/**
* This function will do USB_REQ_GET_DESCRIPTO' bRequest for the usb device instance,
*
- * @param device the usb device instance.
+ * @param device the usb device instance.
* @param type the type of descriptor bRequest.
* @param buffer the data buffer to save requested data
* @param nbytes the size of buffer
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer,
+rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer,
int nbytes)
{
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
-
+
RT_ASSERT(device != RT_NULL);
- 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_DEVICE;
setup.bRequest = USB_REQ_GET_DESCRIPTOR;
setup.wIndex = 0;
@@ -339,19 +339,19 @@ rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer,
* This function will set an address to the usb device.
*
* @param device the usb device instance.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_set_address(uinst_t device)
{
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
-
+
RT_ASSERT(device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usb_set_address\n"));
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
+ setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
USB_REQ_TYPE_DEVICE;
setup.bRequest = USB_REQ_SET_ADDRESS;
setup.wIndex = 0;
@@ -375,7 +375,7 @@ rt_err_t rt_usbh_set_address(uinst_t device)
*
* @param device the usb device instance.
* @param config the configuration number.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_set_configure(uinst_t device, int config)
@@ -386,7 +386,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config)
/* check parameter */
RT_ASSERT(device != RT_NULL);
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
+ setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
USB_REQ_TYPE_DEVICE;
setup.bRequest = USB_REQ_SET_CONFIGURATION;
setup.wIndex = 0;
@@ -401,7 +401,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config)
{
return RT_ERROR;
}
- return RT_EOK;
+ return RT_EOK;
}
/**
@@ -409,7 +409,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config)
*
* @param device the usb device instance.
* @param intf the interface number.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_set_interface(uinst_t device, int intf)
@@ -420,7 +420,7 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf)
/* check parameter */
RT_ASSERT(device != RT_NULL);
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
+ setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
USB_REQ_TYPE_INTERFACE;
setup.bRequest = USB_REQ_SET_INTERFACE;
setup.wIndex = 0;
@@ -431,8 +431,8 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf)
{
return RT_ERROR;
}
-
- return RT_EOK;
+
+ return RT_EOK;
}
/**
@@ -440,7 +440,7 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf)
*
* @param device the usb device instance.
* @param endpoint the endpoint number of the usb device.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature)
@@ -451,7 +451,7 @@ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature)
/* check parameter */
RT_ASSERT(device != RT_NULL);
- setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
+ setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
USB_REQ_TYPE_ENDPOINT;
setup.bRequest = USB_REQ_CLEAR_FEATURE;
setup.wIndex = endpoint;
@@ -462,8 +462,8 @@ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature)
{
return RT_ERROR;
}
-
- return RT_EOK;
+
+ return RT_EOK;
}
/**
@@ -472,10 +472,10 @@ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature)
* @param cfg_desc the point of configuration descriptor structure.
* @param num the number of interface descriptor.
* @intf_desc the point of interface descriptor point.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num,
+rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num,
uintf_desc_t* intf_desc)
{
rt_uint32_t ptr, depth = 0;
@@ -487,9 +487,9 @@ rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num,
ptr = (rt_uint32_t)cfg_desc + cfg_desc->bLength;
while(ptr < (rt_uint32_t)cfg_desc + cfg_desc->wTotalLength)
{
- if(depth++ > 0x20)
+ if(depth++ > 0x20)
{
- *intf_desc = RT_NULL;
+ *intf_desc = RT_NULL;
return -RT_EIO;
}
desc = (udesc_t)ptr;
@@ -500,10 +500,10 @@ rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num,
*intf_desc = (uintf_desc_t)desc;
RT_DEBUG_LOG(RT_DEBUG_USB,
- ("rt_usb_get_interface_descriptor: %d\n", num));
+ ("rt_usb_get_interface_descriptor: %d\n", num));
return RT_EOK;
}
- }
+ }
ptr = (rt_uint32_t)desc + desc->bLength;
}
@@ -517,14 +517,14 @@ rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num,
* @param intf_desc the point of interface descriptor structure.
* @param num the number of endpoint descriptor.
* @param ep_desc the point of endpoint descriptor point.
- *
+ *
* @return the error code, RT_EOK on successfully.
*/
-rt_err_t rt_usbh_get_endpoint_descriptor(uintf_desc_t intf_desc, int num,
+rt_err_t rt_usbh_get_endpoint_descriptor(uintf_desc_t intf_desc, int num,
uep_desc_t* ep_desc)
{
int count = 0, depth = 0;
- rt_uint32_t ptr;
+ rt_uint32_t ptr;
udesc_t desc;
/* check parameter */
@@ -535,15 +535,15 @@ rt_err_t rt_usbh_get_endpoint_descriptor(uintf_desc_t intf_desc, int num,
ptr = (rt_uint32_t)intf_desc + intf_desc->bLength;
while(count < intf_desc->bNumEndpoints)
{
- if(depth++ > 0x20)
+ if(depth++ > 0x20)
{
- *ep_desc = RT_NULL;
+ *ep_desc = RT_NULL;
return -RT_EIO;
}
- desc = (udesc_t)ptr;
+ desc = (udesc_t)ptr;
if(desc->type == USB_DESC_TYPE_ENDPOINT)
{
- if(num == count)
+ if(num == count)
{
*ep_desc = (uep_desc_t)desc;