summaryrefslogtreecommitdiff
path: root/components/drivers/usb/usbdevice/class
diff options
context:
space:
mode:
authorShicheng Chu <[email protected]>2023-06-29 23:24:25 +0800
committerGitHub <[email protected]>2023-06-29 11:24:25 -0400
commite2c031643c8dec7c9ea1581216e19bf19c8f73f0 (patch)
tree926536732e7472c5e86ac5198b239d82f9f55da4 /components/drivers/usb/usbdevice/class
parent148ae53cf8d3abc2c2e11c94c171b123b950b2fc (diff)
[include][dbg]update: no longer use RT_DEBUG_LOG in rtdebug.h (#7750)
Diffstat (limited to 'components/drivers/usb/usbdevice/class')
-rw-r--r--components/drivers/usb/usbdevice/class/cdc_vcom.c26
-rw-r--r--components/drivers/usb/usbdevice/class/hid.c11
-rw-r--r--components/drivers/usb/usbdevice/class/mstorage.c68
3 files changed, 59 insertions, 46 deletions
diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c
index 416e901bcf..0d65b0cdc5 100644
--- a/components/drivers/usb/usbdevice/class/cdc_vcom.c
+++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c
@@ -20,6 +20,10 @@
#ifdef RT_USB_DEVICE_CDC
+#define DBG_TAG "usbdevice_cdc"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
#define VCOM_INTF_STR_INDEX 5
#ifdef RT_VCOM_TX_TIMEOUT
#define VCOM_TX_TIMEOUT RT_VCOM_TX_TIMEOUT
@@ -287,7 +291,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
data = (struct vcom*)func->user_data;
request_size = data->ep_in->request.size;
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_in_handler %d\n", request_size));
+ LOG_D("_ep_in_handler %d", request_size);
if ((request_size != 0) && ((request_size % EP_MAXPACKET(data->ep_in)) == 0))
{
/* don't have data right now. Send a zero-length-packet to
@@ -325,7 +329,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
RT_ASSERT(func != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size));
+ LOG_D("_ep_out_handler %d", size);
data = (struct vcom*)func->user_data;
/* ensure serial is active */
@@ -362,7 +366,7 @@ static rt_err_t _ep_cmd_handler(ufunction_t func, rt_size_t size)
{
RT_ASSERT(func != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_cmd_handler\n"));
+ LOG_D("_ep_cmd_handler");
return RT_EOK;
}
@@ -383,7 +387,7 @@ static rt_err_t _cdc_get_line_coding(udevice_t device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_cdc_get_line_coding\n"));
+ LOG_D("_cdc_get_line_coding");
data.dwDTERate = 115200;
data.bCharFormat = 0;
@@ -398,7 +402,7 @@ static rt_err_t _cdc_get_line_coding(udevice_t device, ureq_t setup)
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"));
+ LOG_D("_cdc_set_line_coding_callback");
dcd_ep0_send_status(device->dcd);
@@ -418,7 +422,7 @@ static rt_err_t _cdc_set_line_coding(udevice_t device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_cdc_set_line_coding\n"));
+ LOG_D("_cdc_set_line_coding");
rt_usbd_ep0_read(device, (void*)&line_coding, sizeof(struct ucdc_line_coding),
_cdc_set_line_coding_callback);
@@ -464,7 +468,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
break;
case CDC_SET_CONTROL_LINE_STATE:
data->connected = (setup->wValue & 0x01) > 0?RT_TRUE:RT_FALSE;
- RT_DEBUG_LOG(RT_DEBUG_USB, ("vcom state:%d \n", data->connected));
+ LOG_D("vcom state:%d ", data->connected);
dcd_ep0_send_status(func->device->dcd);
break;
case CDC_SEND_BREAK:
@@ -490,7 +494,7 @@ static rt_err_t _function_enable(ufunction_t func)
RT_ASSERT(func != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc function enable\n"));
+ LOG_D("cdc function enable");
_vcom_reset_state(func);
@@ -524,7 +528,7 @@ static rt_err_t _function_disable(ufunction_t func)
RT_ASSERT(func != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc function disable\n"));
+ LOG_D("cdc function disable");
_vcom_reset_state(func);
@@ -765,7 +769,7 @@ static rt_ssize_t _vcom_tx(struct rt_serial_device *serial, rt_uint8_t *buf, rt_
RT_ASSERT(serial != RT_NULL);
RT_ASSERT(buf != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("%s\n",__func__));
+ LOG_D("%s",__func__);
if (data->connected)
{
@@ -917,7 +921,7 @@ static void vcom_tx_thread_entry(void* parameter)
if (rt_completion_wait(&data->wait, VCOM_TX_TIMEOUT) != RT_EOK)
{
- RT_DEBUG_LOG(RT_DEBUG_USB, ("vcom tx timeout\n"));
+ LOG_D("vcom tx timeout");
}
if(data->serial.parent.open_flag &
#ifdef RT_USING_SERIAL_V1
diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c
index 59816df4a9..b0c7e63e00 100644
--- a/components/drivers/usb/usbdevice/class/hid.c
+++ b/components/drivers/usb/usbdevice/class/hid.c
@@ -17,6 +17,11 @@
#include "hid.h"
#ifdef RT_USB_DEVICE_HID
+
+#define DBG_TAG "usbdevice.hid"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
#define HID_INTF_STR_INDEX 7
struct hid_s
{
@@ -431,7 +436,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
static rt_err_t _hid_set_report_callback(udevice_t device, rt_size_t size)
{
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_hid_set_report_callback\n"));
+ LOG_D("_hid_set_report_callback");
if(size != 0)
{
@@ -525,7 +530,7 @@ static rt_err_t _function_enable(ufunction_t func)
RT_ASSERT(func->device != RT_NULL);
data = (struct hid_s *) func->user_data;
- RT_DEBUG_LOG(RT_DEBUG_USB, ("hid function enable\n"));
+ LOG_D("hid function enable");
//
// _vcom_reset_state(func);
//
@@ -557,7 +562,7 @@ static rt_err_t _function_disable(ufunction_t func)
RT_ASSERT(func->device != RT_NULL);
data = (struct hid_s *) func->user_data;
- RT_DEBUG_LOG(RT_DEBUG_USB, ("hid function disable\n"));
+ LOG_D("hid function disable");
if(data->ep_out->buffer != RT_NULL)
{
diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c
index 3e7d046166..aeb3ccd510 100644
--- a/components/drivers/usb/usbdevice/class/mstorage.c
+++ b/components/drivers/usb/usbdevice/class/mstorage.c
@@ -21,6 +21,10 @@
#ifdef RT_USB_DEVICE_MSTORAGE
#define MSTRORAGE_INTF_STR_INDEX 11
+#define DBG_TAG "usbdevice.mstorage"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
enum STAT
{
STAT_CBW,
@@ -202,7 +206,7 @@ static void _send_status(ufunction_t func)
RT_ASSERT(func != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_send_status\n"));
+ LOG_D("_send_status");
data = (struct mstorage*)func->user_data;
data->ep_in->request.buffer = (rt_uint8_t*)&data->csw_response;
@@ -219,7 +223,7 @@ static rt_ssize_t _test_unit_ready(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_test_unit_ready\n"));
+ LOG_D("_test_unit_ready");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@@ -234,7 +238,7 @@ static rt_ssize_t _allow_removal(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_allow_removal\n"));
+ LOG_D("_allow_removal");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@@ -260,7 +264,7 @@ static rt_ssize_t _inquiry_cmd(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_inquiry_cmd\n"));
+ LOG_D("_inquiry_cmd");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@@ -299,7 +303,7 @@ static rt_ssize_t _request_sense(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_request_sense\n"));
+ LOG_D("_request_sense");
data = (struct mstorage*)func->user_data;
buf = (struct request_sense_data *)data->ep_in->buffer;
@@ -342,7 +346,7 @@ static rt_ssize_t _mode_sense_6(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_mode_sense_6\n"));
+ LOG_D("_mode_sense_6");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@@ -379,7 +383,7 @@ static rt_ssize_t _read_capacities(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacities\n"));
+ LOG_D("_read_capacities");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@@ -425,7 +429,7 @@ static rt_ssize_t _read_capacity(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacity\n"));
+ LOG_D("_read_capacity");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@@ -515,8 +519,8 @@ static rt_ssize_t _write_10(ufunction_t func, ustorage_cbw_t cbw)
data->csw_response.data_reside = cbw->xfer_len;
data->size = data->count * data->geometry.bytes_per_sector;
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_write_10 count 0x%x block 0x%x 0x%x\n",
- data->count, data->block, data->geometry.sector_count));
+ LOG_D("_write_10 count 0x%x block 0x%x 0x%x",
+ data->count, data->block, data->geometry.sector_count);
data->csw_response.data_reside = data->cb_data_size;
@@ -543,7 +547,7 @@ static rt_ssize_t _verify_10(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_verify_10\n"));
+ LOG_D("_verify_10");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@@ -559,7 +563,7 @@ static rt_ssize_t _start_stop(ufunction_t func,
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_start_stop\n"));
+ LOG_D("_start_stop");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@@ -574,7 +578,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_in_handler\n"));
+ LOG_D("_ep_in_handler");
data = (struct mstorage*)func->user_data;
@@ -588,7 +592,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
}
else
{
- RT_DEBUG_LOG(RT_DEBUG_USB, ("return to cbw status\n"));
+ LOG_D("return to cbw status");
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;
@@ -606,8 +610,8 @@ 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",
- data->csw_response.data_reside, data->ep_in->request.size));
+ LOG_D("data_reside %d, request %d",
+ 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);
@@ -657,13 +661,13 @@ static void cbw_dump(struct ustorage_cbw* cbw)
{
RT_ASSERT(cbw != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("signature 0x%x\n", cbw->signature));
- RT_DEBUG_LOG(RT_DEBUG_USB, ("tag 0x%x\n", cbw->tag));
- RT_DEBUG_LOG(RT_DEBUG_USB, ("xfer_len 0x%x\n", cbw->xfer_len));
- RT_DEBUG_LOG(RT_DEBUG_USB, ("dflags 0x%x\n", cbw->dflags));
- RT_DEBUG_LOG(RT_DEBUG_USB, ("lun 0x%x\n", cbw->lun));
- RT_DEBUG_LOG(RT_DEBUG_USB, ("cb_len 0x%x\n", cbw->cb_len));
- RT_DEBUG_LOG(RT_DEBUG_USB, ("cb[0] 0x%x\n", cbw->cb[0]));
+ LOG_D("signature 0x%x", cbw->signature);
+ LOG_D("tag 0x%x", cbw->tag);
+ LOG_D("xfer_len 0x%x", cbw->xfer_len);
+ LOG_D("dflags 0x%x", cbw->dflags);
+ LOG_D("lun 0x%x", cbw->lun);
+ LOG_D("cb_len 0x%x", cbw->cb_len);
+ LOG_D("cb[0] 0x%x", cbw->cb[0]);
}
#endif
@@ -827,7 +831,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size));
+ LOG_D("_ep_out_handler %d", size);
data = (struct mstorage*)func->user_data;
cbw = (struct ustorage_cbw*)data->ep_out->buffer;
@@ -844,7 +848,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
data->csw_response.data_reside = cbw->xfer_len;
data->csw_response.status = 0;
- RT_DEBUG_LOG(RT_DEBUG_USB, ("ep_out reside %d\n", data->csw_response.data_reside));
+ LOG_D("ep_out reside %d", data->csw_response.data_reside);
cmd = _find_cbw_command(cbw->cb[0]);
if(cmd == RT_NULL)
@@ -869,8 +873,8 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
}
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));
+ LOG_D("write size %d block 0x%x oount 0x%x",
+ size, data->block, data->size);
data->size -= size;
data->csw_response.data_reside -= size;
@@ -928,13 +932,13 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("mstorage_interface_handler\n"));
+ LOG_D("mstorage_interface_handler");
switch(setup->bRequest)
{
case USBREQ_GET_MAX_LUN:
- RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_GET_MAX_LUN\n"));
+ LOG_D("USBREQ_GET_MAX_LUN");
if(setup->wValue || setup->wLength != 1)
{
@@ -947,7 +951,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
break;
case USBREQ_MASS_STORAGE_RESET:
- RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_MASS_STORAGE_RESET\n"));
+ LOG_D("USBREQ_MASS_STORAGE_RESET");
if(setup->wValue || setup->wLength != 0)
{
@@ -977,7 +981,7 @@ static rt_err_t _function_enable(ufunction_t func)
{
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("Mass storage function enabled\n"));
+ LOG_D("Mass storage function enabled");
data = (struct mstorage*)func->user_data;
data->disk = rt_device_find(RT_USB_MSTORAGE_DISK_NAME);
@@ -1039,7 +1043,7 @@ static rt_err_t _function_disable(ufunction_t func)
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
- RT_DEBUG_LOG(RT_DEBUG_USB, ("Mass storage function disabled\n"));
+ LOG_D("Mass storage function disabled");
data = (struct mstorage*)func->user_data;
if(data->ep_in->buffer != RT_NULL)