[debug] use LOG_D instead RT_DEBUG_LOG
related: https://github.com/RT-Thread/rt-thread/pull/7799
This commit is contained in:
parent
307e9e5e98
commit
4e0225a48d
|
@ -18,7 +18,7 @@
|
|||
#include "drv_config.h"
|
||||
|
||||
//#define DRV_DEBUG
|
||||
#define LOG_TAG "drv.usb"
|
||||
#define LOG_TAG "drv.usb.fsh"
|
||||
#include <drv_log.h>
|
||||
|
||||
static struct rt_completion urb_completion;
|
||||
|
@ -76,7 +76,7 @@ void usbh_connect_callback(usbh_core_type *uhost)
|
|||
if (!connect_status)
|
||||
{
|
||||
connect_status = RT_TRUE;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
rt_usbh_root_hub_connect_handler(hcd, 1, RT_FALSE);
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void usbh_disconnect_callback(usbh_core_type *uhost)
|
|||
if (connect_status)
|
||||
{
|
||||
connect_status = RT_FALSE;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnnect\n"));
|
||||
LOG_D("usb disconnnect");
|
||||
rt_usbh_root_hub_disconnect_handler(hcd, 1);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void usbd_notify_urbchange_callback(usbh_core_type *uhost, uint8_t chnum, urb_st
|
|||
|
||||
static rt_err_t drv_reset_port(rt_uint8_t port)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("reset port\n"));
|
||||
LOG_D("reset port");
|
||||
usbh_reset_port(&p_usbfs_instance->p_otg_core->host);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
|
||||
if(usbh_get_status((&p_usbfs_instance->p_otg_core->host), pipe->pipe_index) == HCH_NAK)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nak\n"));
|
||||
LOG_D("nak");
|
||||
if (pipe->ep.bmAttributes == USB_EP_ATTR_INT)
|
||||
{
|
||||
rt_thread_delay((pipe->ep.bInterval * RT_TICK_PER_SECOND / 1000) > 0 ? (pipe->ep.bInterval * RT_TICK_PER_SECOND / 1000) : 1);
|
||||
|
@ -242,7 +242,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
}
|
||||
else if (usbh_get_status(&p_usbfs_instance->p_otg_core->host, pipe->pipe_index) == HCH_STALL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("stall\n"));
|
||||
LOG_D("stall");
|
||||
pipe->status = UPIPE_STATUS_STALL;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
}
|
||||
else if (usbh_get_status(&p_usbfs_instance->p_otg_core->host, pipe->pipe_index) == URB_ERROR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error\n"));
|
||||
LOG_D("error");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -262,7 +262,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
}
|
||||
else if(URB_DONE == usbh_get_urb_status(&p_usbfs_instance->p_otg_core->host, pipe->pipe_index))
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ok\n"));
|
||||
LOG_D("ok");
|
||||
pipe->status = UPIPE_STATUS_OK;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include <usb/host/usb_host_ehci.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
//#define DRV_DEBUG
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#include <drv_log.h>
|
||||
|
||||
/* USB PHY configuration */
|
||||
#ifndef BOARD_USB_PHY_D_CAL
|
||||
|
@ -171,12 +174,12 @@ static int _ehci0_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
usb_host_transfer_t *transfer;
|
||||
if (imxrt_usb_host_obj[USBH0_INDEX].pipes[pipe->pipe_index].pipe_handle == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error operation on null pipe\n"));
|
||||
LOG_D("error operation on null pipe");
|
||||
return -1;
|
||||
}
|
||||
if (USB_HostMallocTransfer(imxrt_usb_host_obj[USBH0_INDEX].host_handle, &transfer) != kStatus_USB_Success)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error to get transfer\n"));
|
||||
LOG_D("error to get transfer");
|
||||
return -1;
|
||||
}
|
||||
transfer->transferBuffer = buffer;
|
||||
|
@ -228,13 +231,13 @@ static int _ehci0_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
rt_completion_init(&(imxrt_usb_host_obj[USBH0_INDEX].pipes[pipe->pipe_index].urb_completion));
|
||||
if (USB_HostEhciWritePipe(((usb_host_instance_t *)imxrt_usb_host_obj[USBH0_INDEX].host_handle)->controllerHandle, imxrt_usb_host_obj[USBH0_INDEX].pipes[pipe->pipe_index].pipe_handle, transfer) != kStatus_USB_Success)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb host failed to send\n"));
|
||||
LOG_D("usb host failed to send");
|
||||
(void)USB_HostFreeTransfer(imxrt_usb_host_obj[USBH0_INDEX].host_handle, transfer);
|
||||
return -1;
|
||||
}
|
||||
if (-RT_ETIMEOUT == rt_completion_wait(&(imxrt_usb_host_obj[USBH0_INDEX].pipes[pipe->pipe_index].urb_completion), RT_WAITING_FOREVER))
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb transfer timeout\n"));
|
||||
LOG_D("usb transfer timeout");
|
||||
(void)USB_HostFreeTransfer(imxrt_usb_host_obj[USBH0_INDEX].host_handle, transfer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -243,7 +246,7 @@ static int _ehci0_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
{
|
||||
case kStatus_USB_Success:
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ok\n"));
|
||||
LOG_D("ok");
|
||||
pipe->status = UPIPE_STATUS_OK;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -264,7 +267,7 @@ static int _ehci0_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
}
|
||||
case kStatus_USB_TransferStall:
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("stall\n"));
|
||||
LOG_D("stall");
|
||||
pipe->status = UPIPE_STATUS_STALL;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -277,7 +280,7 @@ static int _ehci0_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
case kStatus_USB_TransferFailed:
|
||||
default:
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error\n"));
|
||||
LOG_D("error");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -358,17 +361,17 @@ static usb_status_t usb0_host_callback(usb_device_handle handle, usb_host_config
|
|||
{
|
||||
imxrt_usb_host_obj[USBH0_INDEX].connect_status = RT_TRUE;
|
||||
imxrt_usb_host_obj[USBH0_INDEX].device_handle = handle;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
rt_usbh_root_hub_connect_handler(&(imxrt_usb_host_obj[USBH0_INDEX].uhcd), OTG_PORT, RT_TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case kUSB_HostEventNotSupported:
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb device not supported\n"));
|
||||
LOG_D("usb device not supported");
|
||||
break;
|
||||
|
||||
case kUSB_HostEventEnumerationDone:
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("enumeration done\n"));
|
||||
LOG_D("enumeration done");
|
||||
break;
|
||||
|
||||
case kUSB_HostEventDetach:
|
||||
|
@ -376,7 +379,7 @@ static usb_status_t usb0_host_callback(usb_device_handle handle, usb_host_config
|
|||
{
|
||||
imxrt_usb_host_obj[USBH0_INDEX].connect_status = RT_FALSE;
|
||||
imxrt_usb_host_obj[USBH0_INDEX].device_handle = handle;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnnect\n"));
|
||||
LOG_D("usb disconnnect");
|
||||
rt_usbh_root_hub_disconnect_handler(&(imxrt_usb_host_obj[USBH0_INDEX].uhcd), OTG_PORT);
|
||||
(void)USB_HostCloseDeviceInterface(handle, NULL);
|
||||
}
|
||||
|
@ -448,12 +451,12 @@ static int _ehci1_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
usb_host_transfer_t *transfer;
|
||||
if (imxrt_usb_host_obj[USBH1_INDEX].pipes[pipe->pipe_index].pipe_handle == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error operation on null pipe\n"));
|
||||
LOG_D("error operation on null pipe");
|
||||
return -1;
|
||||
}
|
||||
if (USB_HostMallocTransfer(imxrt_usb_host_obj[USBH1_INDEX].host_handle, &transfer) != kStatus_USB_Success)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error to get transfer\n"));
|
||||
LOG_D("error to get transfer");
|
||||
return -1;
|
||||
}
|
||||
transfer->transferBuffer = buffer;
|
||||
|
@ -505,13 +508,13 @@ static int _ehci1_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
rt_completion_init(&(imxrt_usb_host_obj[USBH1_INDEX].pipes[pipe->pipe_index].urb_completion));
|
||||
if (USB_HostEhciWritePipe(((usb_host_instance_t *)imxrt_usb_host_obj[USBH1_INDEX].host_handle)->controllerHandle, imxrt_usb_host_obj[USBH1_INDEX].pipes[pipe->pipe_index].pipe_handle, transfer) != kStatus_USB_Success)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb host failed to send\n"));
|
||||
LOG_D("usb host failed to send");
|
||||
(void)USB_HostFreeTransfer(imxrt_usb_host_obj[USBH1_INDEX].host_handle, transfer);
|
||||
return -1;
|
||||
}
|
||||
if (-RT_ETIMEOUT == rt_completion_wait(&(imxrt_usb_host_obj[USBH1_INDEX].pipes[pipe->pipe_index].urb_completion), RT_WAITING_FOREVER))
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb transfer timeout\n"));
|
||||
LOG_D("usb transfer timeout");
|
||||
(void)USB_HostFreeTransfer(imxrt_usb_host_obj[USBH1_INDEX].host_handle, transfer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -521,7 +524,7 @@ static int _ehci1_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
{
|
||||
case kStatus_USB_Success:
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ok\n"));
|
||||
LOG_D("ok");
|
||||
pipe->status = UPIPE_STATUS_OK;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -542,7 +545,7 @@ static int _ehci1_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
}
|
||||
case kStatus_USB_TransferStall:
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("stall\n"));
|
||||
LOG_D("stall");
|
||||
pipe->status = UPIPE_STATUS_STALL;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -555,7 +558,7 @@ static int _ehci1_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nb
|
|||
case kStatus_USB_TransferFailed:
|
||||
default:
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error\n"));
|
||||
LOG_D("error");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -636,17 +639,17 @@ static usb_status_t usb1_host_callback(usb_device_handle handle, usb_host_config
|
|||
{
|
||||
imxrt_usb_host_obj[USBH1_INDEX].connect_status = RT_TRUE;
|
||||
imxrt_usb_host_obj[USBH1_INDEX].device_handle = handle;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
rt_usbh_root_hub_connect_handler(&(imxrt_usb_host_obj[USBH1_INDEX].uhcd), OTG_PORT, RT_TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case kUSB_HostEventNotSupported:
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb device not supported\n"));
|
||||
LOG_D("usb device not supported");
|
||||
break;
|
||||
|
||||
case kUSB_HostEventEnumerationDone:
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("enumeration done\n"));
|
||||
LOG_D("enumeration done");
|
||||
break;
|
||||
|
||||
case kUSB_HostEventDetach:
|
||||
|
@ -654,7 +657,7 @@ static usb_status_t usb1_host_callback(usb_device_handle handle, usb_host_config
|
|||
{
|
||||
imxrt_usb_host_obj[USBH1_INDEX].connect_status = RT_FALSE;
|
||||
imxrt_usb_host_obj[USBH1_INDEX].device_handle = handle;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnnect\n"));
|
||||
LOG_D("usb disconnnect");
|
||||
rt_usbh_root_hub_disconnect_handler(&(imxrt_usb_host_obj[USBH1_INDEX].uhcd), OTG_PORT);
|
||||
(void)USB_HostCloseDeviceInterface(handle, NULL);
|
||||
}
|
||||
|
|
|
@ -21,12 +21,9 @@
|
|||
#include "usb.h"
|
||||
#include "usbh_lib.h"
|
||||
|
||||
#define LOG_TAG "drv.usbhost"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL LOG_LVL_DBG
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <drv_log.h>
|
||||
|
||||
#if !defined(NU_USBHOST_HUB_POLLING_INTERVAL)
|
||||
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
|
||||
|
@ -113,7 +110,7 @@ GetRHPortControlFromPipe(
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT\n"));
|
||||
LOG_D("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT");
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
@ -155,14 +152,14 @@ static rt_err_t nu_reset_port(rt_uint8_t port)
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: port index over NU_MAX_USBH_PORT\n", __func__));
|
||||
LOG_D("%s ERROR: port index over NU_MAX_USBH_PORT", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
psPortCtrl = &s_sUSBHDev.asPortCtrl[port - 1];
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
|
@ -252,13 +249,13 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
psPortCtrl = GetRHPortControlFromPipe(pipe);
|
||||
if (psPortCtrl == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: RHPort not found\n", __func__));
|
||||
LOG_D("%s ERROR: RHPort not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -271,7 +268,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
|
||||
if (psPortDev == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: udev allocate failed\n"));
|
||||
LOG_D("nu_open_pipe ERROR: udev allocate failed");
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -302,7 +299,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
EP_INFO_T *psEPInfo = GetFreePipe(psPortCtrl, psPortDev, &pipe->pipe_index);
|
||||
if (psEPInfo == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: get free pipe failed\n", __func__));
|
||||
LOG_D("%s ERROR: get free pipe failed", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -380,13 +377,13 @@ static int nu_ctrl_xfer(
|
|||
ret = usbh_ctrl_xfer(psPortDev->pUDev, psSetup->request_type, psSetup->bRequest, psSetup->wValue, psSetup->wIndex, psSetup->wLength, buffer, &xfer_len, timeouts * 10);
|
||||
if (ret < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer failed %d\n", ret));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer failed %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (xfer_len != psSetup->wLength)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer length %d %d\n", psSetup->wLength, xfer_len));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer length %d %d", psSetup->wLength, xfer_len);
|
||||
}
|
||||
|
||||
if ((psSetup->bRequest == USB_REQ_SET_ADDRESS) && ((psSetup->request_type & 0x60) == REQ_TYPE_STD_DEV))
|
||||
|
@ -443,7 +440,7 @@ static int nu_int_xfer(
|
|||
|
||||
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Request %08x Timeout in %d ms!!\n", psUTR, timeouts));
|
||||
LOG_D("Request %08x Timeout in %d ms", psUTR, timeouts);
|
||||
usbh_quit_utr(psUTR);
|
||||
|
||||
rt_completion_init(&(psPortDev->utr_completion));
|
||||
|
@ -452,7 +449,7 @@ static int nu_int_xfer(
|
|||
else
|
||||
{
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Transferring done %08x\n", psUTR));
|
||||
LOG_D("Transferring done %08x", psUTR);
|
||||
usbh_quit_utr(psUTR);
|
||||
break;
|
||||
}
|
||||
|
@ -489,7 +486,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
psPortDev = GetPortDevFromPipe(pipe);
|
||||
if (psPortDev->pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: udev not found\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: udev not found");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -553,7 +550,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
}
|
||||
else
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%d == USBH_PID_DATA, nil buf-%d \n", token, nbytes));
|
||||
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
|
||||
}
|
||||
|
||||
} //else
|
||||
|
@ -567,7 +564,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
|
||||
if (!psUTR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: unable alloc UTR\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: unable alloc UTR");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -587,7 +584,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_bulk_xfer(psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: bulk transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: bulk transfer failed");
|
||||
goto failreport_nu_pipe_xfer;
|
||||
}
|
||||
}
|
||||
|
@ -595,7 +592,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: int transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
|
||||
//goto exit_nu_pipe_xfer;
|
||||
}
|
||||
else
|
||||
|
@ -607,7 +604,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
|
||||
{
|
||||
//TODO: ISO transfer
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: isoc transfer not support\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -618,7 +615,7 @@ failreport_nu_pipe_xfer:
|
|||
if (psUTR->bIsTransferDone == 0)
|
||||
{
|
||||
//Timeout
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: timeout\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: timeout");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
usbh_quit_utr(psUTR);
|
||||
}
|
||||
|
@ -687,7 +684,7 @@ static void nu_hcd_connect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: port connect slot is full\n"));
|
||||
LOG_D("ERROR: port connect slot is full");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -695,7 +692,7 @@ static void nu_hcd_connect_callback(
|
|||
psPortCtrl->sRHPortDev.pUDev = udev;
|
||||
psPortCtrl->sRHPortDev.bRHParent = TRUE;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
|
||||
if (udev->speed == SPEED_HIGH)
|
||||
rt_usbh_root_hub_connect_handler(&s_sUSBHDev.uhcd, port_index, RT_TRUE);
|
||||
|
@ -720,7 +717,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: udev not found\n"));
|
||||
LOG_D("ERROR: udev not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -736,7 +733,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
psPortCtrl->sRHPortDev.pUDev = NULL;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnect\n"));
|
||||
LOG_D("usb disconnect");
|
||||
|
||||
rt_usbh_root_hub_disconnect_handler(&s_sUSBHDev.uhcd, port_index);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,9 @@
|
|||
#include "usb.h"
|
||||
#include "usbh_lib.h"
|
||||
|
||||
#define LOG_TAG "drv.usbhost"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL LOG_LVL_DBG
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <drv_log.h>
|
||||
|
||||
#if !defined(NU_USBHOST_HUB_POLLING_INTERVAL)
|
||||
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
|
||||
|
@ -115,7 +112,7 @@ GetRHPortControlFromPipe(
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT\n"));
|
||||
LOG_D("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT");
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
@ -157,14 +154,14 @@ static rt_err_t nu_reset_port(rt_uint8_t port)
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: port index over NU_MAX_USBH_PORT\n", __func__));
|
||||
LOG_D("%s ERROR: port index over NU_MAX_USBH_PORT", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
psPortCtrl = &s_sUSBHDev.asPortCtrl[port - 1];
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
|
@ -254,13 +251,13 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
psPortCtrl = GetRHPortControlFromPipe(pipe);
|
||||
if (psPortCtrl == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: RHPort not found\n", __func__));
|
||||
LOG_D("%s ERROR: RHPort not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -273,7 +270,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
|
||||
if (psPortDev == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: udev allocate failed\n"));
|
||||
LOG_D("nu_open_pipe ERROR: udev allocate failed");
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -304,7 +301,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
EP_INFO_T *psEPInfo = GetFreePipe(psPortCtrl, psPortDev, &pipe->pipe_index);
|
||||
if (psEPInfo == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: get free pipe failed\n", __func__));
|
||||
LOG_D("%s ERROR: get free pipe failed", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -382,13 +379,13 @@ static int nu_ctrl_xfer(
|
|||
ret = usbh_ctrl_xfer(psPortDev->pUDev, psSetup->request_type, psSetup->bRequest, psSetup->wValue, psSetup->wIndex, psSetup->wLength, buffer, &xfer_len, timeouts * 10);
|
||||
if (ret < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer failed %d\n", ret));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer failed %d");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (xfer_len != psSetup->wLength)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer length %d %d\n", psSetup->wLength, xfer_len));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer length %d %d", psSetup->wLength, xfer_len);
|
||||
}
|
||||
|
||||
if ((psSetup->bRequest == USB_REQ_SET_ADDRESS) && ((psSetup->request_type & 0x60) == REQ_TYPE_STD_DEV))
|
||||
|
@ -462,7 +459,7 @@ static int nu_int_xfer(
|
|||
|
||||
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Request %08x Timeout in %d ms!!\n", psUTR, timeouts));
|
||||
LOG_D("Request %08x Timeout in %d ms", psUTR, timeouts);
|
||||
usbh_quit_utr(psUTR);
|
||||
|
||||
rt_completion_init(&(psPortDev->utr_completion));
|
||||
|
@ -471,7 +468,7 @@ static int nu_int_xfer(
|
|||
else
|
||||
{
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Transferring done %08x\n", psUTR));
|
||||
LOG_D("Transferring done %08x", psUTR);
|
||||
usbh_quit_utr(psUTR);
|
||||
break;
|
||||
}
|
||||
|
@ -508,7 +505,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
psPortDev = GetPortDevFromPipe(pipe);
|
||||
if (psPortDev->pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: udev not found\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: udev not found");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -572,7 +569,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
}
|
||||
else
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%d == USBH_PID_DATA, nil buf-%d \n", token, nbytes));
|
||||
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
|
||||
}
|
||||
|
||||
} //else
|
||||
|
@ -586,7 +583,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
|
||||
if (!psUTR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: unable alloc UTR\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: unable alloc UTR");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -606,7 +603,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_bulk_xfer(psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: bulk transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: bulk transfer failed");
|
||||
goto failreport_nu_pipe_xfer;
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +611,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: int transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
|
||||
//goto exit_nu_pipe_xfer;
|
||||
}
|
||||
else
|
||||
|
@ -626,7 +623,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
|
||||
{
|
||||
//TODO: ISO transfer
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: isoc transfer not support\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -637,7 +634,7 @@ failreport_nu_pipe_xfer:
|
|||
if (psUTR->bIsTransferDone == 0)
|
||||
{
|
||||
//Timeout
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: timeout\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: timeout");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
usbh_quit_utr(psUTR);
|
||||
}
|
||||
|
@ -706,7 +703,7 @@ static void nu_hcd_connect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: port connect slot is full\n"));
|
||||
LOG_D("ERROR: port connect slot is full");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -714,7 +711,7 @@ static void nu_hcd_connect_callback(
|
|||
psPortCtrl->sRHPortDev.pUDev = udev;
|
||||
psPortCtrl->sRHPortDev.bRHParent = TRUE;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
|
||||
if (udev->speed == SPEED_HIGH)
|
||||
rt_usbh_root_hub_connect_handler(&s_sUSBHDev.uhcd, port_index, RT_TRUE);
|
||||
|
@ -739,7 +736,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: udev not found\n"));
|
||||
LOG_D("ERROR: udev not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -755,7 +752,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
psPortCtrl->sRHPortDev.pUDev = NULL;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnect\n"));
|
||||
LOG_D("usb disconnect");
|
||||
|
||||
rt_usbh_root_hub_disconnect_handler(&s_sUSBHDev.uhcd, port_index);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,9 @@
|
|||
#include "usb.h"
|
||||
#include "usbh_lib.h"
|
||||
|
||||
#define LOG_TAG "drv.usbhost"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL LOG_LVL_DBG
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <drv_log.h>
|
||||
|
||||
#if !defined(NU_USBHOST_HUB_POLLING_INTERVAL)
|
||||
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
|
||||
|
@ -115,7 +112,7 @@ GetRHPortControlFromPipe(
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT\n"));
|
||||
LOG_D("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT");
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
@ -157,14 +154,14 @@ static rt_err_t nu_reset_port(rt_uint8_t port)
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: port index over NU_MAX_USBH_PORT\n", __func__));
|
||||
LOG_D("%s ERROR: port index over NU_MAX_USBH_PORT", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
psPortCtrl = &s_sUSBHDev.asPortCtrl[port - 1];
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
|
@ -254,13 +251,13 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
psPortCtrl = GetRHPortControlFromPipe(pipe);
|
||||
if (psPortCtrl == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: RHPort not found\n", __func__));
|
||||
LOG_D("%s ERROR: RHPort not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -273,7 +270,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
|
||||
if (psPortDev == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: udev allocate failed\n"));
|
||||
LOG_D("nu_open_pipe ERROR: udev allocate failed");
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -304,7 +301,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
EP_INFO_T *psEPInfo = GetFreePipe(psPortCtrl, psPortDev, &pipe->pipe_index);
|
||||
if (psEPInfo == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: get free pipe failed\n", __func__));
|
||||
LOG_D("%s ERROR: get free pipe failed", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -382,13 +379,13 @@ static int nu_ctrl_xfer(
|
|||
ret = usbh_ctrl_xfer(psPortDev->pUDev, psSetup->request_type, psSetup->bRequest, psSetup->wValue, psSetup->wIndex, psSetup->wLength, buffer, &xfer_len, timeouts * 10);
|
||||
if (ret < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer failed %d\n", ret));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer failed %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (xfer_len != psSetup->wLength)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer length %d %d\n", psSetup->wLength, xfer_len));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer length %d %d", psSetup->wLength, xfer_len);
|
||||
}
|
||||
|
||||
if ((psSetup->bRequest == USB_REQ_SET_ADDRESS) && ((psSetup->request_type & 0x60) == REQ_TYPE_STD_DEV))
|
||||
|
@ -445,7 +442,7 @@ static int nu_int_xfer(
|
|||
|
||||
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Request %08x Timeout in %d ms!!\n", psUTR, timeouts));
|
||||
LOG_D("Request %08x Timeout in %d ms", psUTR, timeouts);
|
||||
usbh_quit_utr(psUTR);
|
||||
|
||||
rt_completion_init(&(psPortDev->utr_completion));
|
||||
|
@ -454,7 +451,7 @@ static int nu_int_xfer(
|
|||
else
|
||||
{
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Transferring done %08x\n", psUTR));
|
||||
LOG_D("Transferring done %08x", psUTR);
|
||||
usbh_quit_utr(psUTR);
|
||||
break;
|
||||
}
|
||||
|
@ -491,7 +488,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
psPortDev = GetPortDevFromPipe(pipe);
|
||||
if (psPortDev->pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: udev not found\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: udev not found");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -555,7 +552,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
}
|
||||
else
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%d == USBH_PID_DATA, nil buf-%d \n", token, nbytes));
|
||||
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
|
||||
}
|
||||
|
||||
} //else
|
||||
|
@ -569,7 +566,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
|
||||
if (!psUTR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: unable alloc UTR\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: unable alloc UTR");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -589,7 +586,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_bulk_xfer(psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: bulk transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: bulk transfer failed");
|
||||
goto failreport_nu_pipe_xfer;
|
||||
}
|
||||
}
|
||||
|
@ -597,7 +594,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: int transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
|
||||
//goto exit_nu_pipe_xfer;
|
||||
}
|
||||
else
|
||||
|
@ -609,7 +606,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
|
||||
{
|
||||
//TODO: ISO transfer
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: isoc transfer not support\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -620,7 +617,7 @@ failreport_nu_pipe_xfer:
|
|||
if (psUTR->bIsTransferDone == 0)
|
||||
{
|
||||
//Timeout
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: timeout\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: timeout");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
usbh_quit_utr(psUTR);
|
||||
}
|
||||
|
@ -689,7 +686,7 @@ static void nu_hcd_connect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: port connect slot is full\n"));
|
||||
LOG_D("ERROR: port connect slot is full");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -697,7 +694,7 @@ static void nu_hcd_connect_callback(
|
|||
psPortCtrl->sRHPortDev.pUDev = udev;
|
||||
psPortCtrl->sRHPortDev.bRHParent = TRUE;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
|
||||
if (udev->speed == SPEED_HIGH)
|
||||
rt_usbh_root_hub_connect_handler(&s_sUSBHDev.uhcd, port_index, RT_TRUE);
|
||||
|
@ -722,7 +719,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: udev not found\n"));
|
||||
LOG_D("ERROR: udev not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -738,7 +735,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
psPortCtrl->sRHPortDev.pUDev = NULL;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnect\n"));
|
||||
LOG_D("usb disconnect");
|
||||
|
||||
rt_usbh_root_hub_disconnect_handler(&s_sUSBHDev.uhcd, port_index);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,9 @@
|
|||
#include "usb.h"
|
||||
#include "usbh_lib.h"
|
||||
|
||||
#define LOG_TAG "drv.usbhost"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL LOG_LVL_DBG
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <drv_log.h>
|
||||
|
||||
#if !defined(NU_USBHOST_HUB_POLLING_INTERVAL)
|
||||
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
|
||||
|
@ -119,7 +116,7 @@ GetRHPortControlFromPipe(
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT\n"));
|
||||
LOG_D("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT");
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
@ -161,14 +158,14 @@ static rt_err_t nu_reset_port(rt_uint8_t port)
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: port index over NU_MAX_USBH_PORT\n", __func__));
|
||||
LOG_D("%s ERROR: port index over NU_MAX_USBH_PORT", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
psPortCtrl = &s_sUSBHDev.asPortCtrl[port - 1];
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
|
@ -258,13 +255,13 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
psPortCtrl = GetRHPortControlFromPipe(pipe);
|
||||
if (psPortCtrl == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: RHPort not found\n", __func__));
|
||||
LOG_D("%s ERROR: RHPort not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -277,7 +274,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
|
||||
if (psPortDev == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: udev allocate failed\n"));
|
||||
LOG_D("nu_open_pipe ERROR: udev allocate failed");
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -308,7 +305,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
EP_INFO_T *psEPInfo = GetFreePipe(psPortCtrl, psPortDev, &pipe->pipe_index);
|
||||
if (psEPInfo == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: get free pipe failed\n", __func__));
|
||||
LOG_D("%s ERROR: get free pipe failed", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -397,13 +394,13 @@ static int nu_ctrl_xfer(
|
|||
ret = usbh_ctrl_xfer(psPortDev->pUDev, psSetup->request_type, psSetup->bRequest, psSetup->wValue, psSetup->wIndex, psSetup->wLength, buffer, &xfer_len, timeouts * 10);
|
||||
if (ret < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer failed %d\n", ret));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer failed %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (xfer_len != psSetup->wLength)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer length %d %d\n", psSetup->wLength, xfer_len));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer length %d %d", psSetup->wLength, xfer_len);
|
||||
}
|
||||
|
||||
if ((psSetup->bRequest == USB_REQ_SET_ADDRESS) && ((psSetup->request_type & 0x60) == REQ_TYPE_STD_DEV))
|
||||
|
@ -461,7 +458,7 @@ static int nu_int_xfer(
|
|||
|
||||
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Request %08x Timeout in %d ms!!\n", psUTR, timeouts));
|
||||
LOG_D("Request %08x Timeout in %d ms", psUTR, timeouts);
|
||||
usbh_quit_utr(psUTR);
|
||||
|
||||
rt_completion_init(&(psPortDev->utr_completion));
|
||||
|
@ -470,7 +467,7 @@ static int nu_int_xfer(
|
|||
else
|
||||
{
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Transferring done %08x\n", psUTR));
|
||||
LOG_D("Transferring done %08x", psUTR);
|
||||
usbh_quit_utr(psUTR);
|
||||
break;
|
||||
}
|
||||
|
@ -507,7 +504,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
psPortDev = GetPortDevFromPipe(pipe);
|
||||
if (psPortDev->pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: udev not found\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: udev not found");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -586,7 +583,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
}
|
||||
else
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%d == USBH_PID_DATA, nil buf-%d \n", token, nbytes));
|
||||
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
|
||||
}
|
||||
|
||||
} //else
|
||||
|
@ -600,7 +597,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
|
||||
if (!psUTR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: unable alloc UTR\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: unable alloc UTR");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -620,7 +617,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_bulk_xfer(psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: bulk transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: bulk transfer failed");
|
||||
goto failreport_nu_pipe_xfer;
|
||||
}
|
||||
}
|
||||
|
@ -628,7 +625,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: int transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
|
||||
//goto exit_nu_pipe_xfer;
|
||||
}
|
||||
else
|
||||
|
@ -640,7 +637,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
|
||||
{
|
||||
//TODO: ISO transfer
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: isoc transfer not support\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -651,7 +648,7 @@ failreport_nu_pipe_xfer:
|
|||
if (psUTR->bIsTransferDone == 0)
|
||||
{
|
||||
//Timeout
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: timeout\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: timeout");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
usbh_quit_utr(psUTR);
|
||||
}
|
||||
|
@ -732,7 +729,7 @@ static void nu_hcd_connect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: port connect slot is full\n"));
|
||||
LOG_D("ERROR: port connect slot is full");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -740,7 +737,7 @@ static void nu_hcd_connect_callback(
|
|||
psPortCtrl->sRHPortDev.pUDev = udev;
|
||||
psPortCtrl->sRHPortDev.bRHParent = TRUE;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
|
||||
if (udev->speed == SPEED_HIGH)
|
||||
rt_usbh_root_hub_connect_handler(&s_sUSBHDev.uhcd, port_index, RT_TRUE);
|
||||
|
@ -765,7 +762,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: udev not found\n"));
|
||||
LOG_D("ERROR: udev not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -781,7 +778,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
psPortCtrl->sRHPortDev.pUDev = NULL;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnect\n"));
|
||||
LOG_D("usb disconnect");
|
||||
|
||||
rt_usbh_root_hub_disconnect_handler(&s_sUSBHDev.uhcd, port_index);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,9 @@
|
|||
#include "usb.h"
|
||||
#include "usbh_lib.h"
|
||||
|
||||
#define LOG_TAG "drv.usbhost"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL LOG_LVL_DBG
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <drv_log.h>
|
||||
|
||||
#if !defined(NU_USBHOST_HUB_POLLING_INTERVAL)
|
||||
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
|
||||
|
@ -127,7 +124,7 @@ GetRHPortControlFromPipe(
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT\n"));
|
||||
LOG_D("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT");
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
@ -169,14 +166,14 @@ static rt_err_t nu_reset_port(rt_uint8_t port)
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: port index over NU_MAX_USBH_PORT\n", __func__));
|
||||
LOG_D("%s ERROR: port index over NU_MAX_USBH_PORT", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
psPortCtrl = &s_sUSBHDev.asPortCtrl[port - 1];
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
|
@ -274,13 +271,13 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
psPortCtrl = GetRHPortControlFromPipe(pipe);
|
||||
if (psPortCtrl == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: RHPort not found\n", __func__));
|
||||
LOG_D("%s ERROR: RHPort not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -293,7 +290,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
|
||||
if (psPortDev == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: udev allocate failed\n"));
|
||||
LOG_D("nu_open_pipe ERROR: udev allocate failed");
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -324,7 +321,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
EP_INFO_T *psEPInfo = GetFreePipe(psPortCtrl, psPortDev, &pipe->pipe_index);
|
||||
if (psEPInfo == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: get free pipe failed\n", __func__));
|
||||
LOG_D("%s ERROR: get free pipe failed", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -420,13 +417,13 @@ static int nu_ctrl_xfer(
|
|||
ret = usbh_ctrl_xfer(psPortDev->pUDev, psSetup->request_type, psSetup->bRequest, psSetup->wValue, psSetup->wIndex, psSetup->wLength, buffer, &xfer_len, timeouts * 10);
|
||||
if (ret < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer failed %d\n", ret));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer failed %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (xfer_len != psSetup->wLength)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer length %d %d\n", psSetup->wLength, xfer_len));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer length %d %d", psSetup->wLength, xfer_len);
|
||||
}
|
||||
|
||||
if ((psSetup->bRequest == USB_REQ_SET_ADDRESS) && ((psSetup->request_type & 0x60) == REQ_TYPE_STD_DEV))
|
||||
|
@ -500,7 +497,7 @@ static int nu_int_xfer(
|
|||
|
||||
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Request %08x Timeout in %d ms!!\n", psUTR, timeouts));
|
||||
LOG_D("Request %08x Timeout in %d ms", psUTR, timeouts);
|
||||
usbh_quit_utr(psUTR);
|
||||
|
||||
rt_completion_init(&(psPortDev->utr_completion));
|
||||
|
@ -509,7 +506,7 @@ static int nu_int_xfer(
|
|||
else
|
||||
{
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Transferring done %08x\n", psUTR));
|
||||
LOG_D("Transferring done %08x", psUTR);
|
||||
usbh_quit_utr(psUTR);
|
||||
break;
|
||||
}
|
||||
|
@ -546,7 +543,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
psPortDev = GetPortDevFromPipe(pipe);
|
||||
if (psPortDev->pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: udev not found\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: udev not found");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -625,7 +622,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
}
|
||||
else
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%d == USBH_PID_DATA, nil buf-%d \n", token, nbytes));
|
||||
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
|
||||
}
|
||||
|
||||
} //else
|
||||
|
@ -639,7 +636,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
|
||||
if (!psUTR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: unable alloc UTR\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: unable alloc UTR");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -659,7 +656,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_bulk_xfer(psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: bulk transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: bulk transfer failed");
|
||||
goto failreport_nu_pipe_xfer;
|
||||
}
|
||||
}
|
||||
|
@ -667,7 +664,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: int transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
|
||||
//goto exit_nu_pipe_xfer;
|
||||
}
|
||||
else
|
||||
|
@ -679,7 +676,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
|
||||
{
|
||||
//TODO: ISO transfer
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: isoc transfer not support\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -690,7 +687,7 @@ failreport_nu_pipe_xfer:
|
|||
if (psUTR->bIsTransferDone == 0)
|
||||
{
|
||||
//Timeout
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: timeout\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: timeout");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
usbh_quit_utr(psUTR);
|
||||
}
|
||||
|
@ -781,7 +778,7 @@ static void nu_hcd_connect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: port connect slot is full\n"));
|
||||
LOG_D("ERROR: port connect slot is full");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -789,7 +786,7 @@ static void nu_hcd_connect_callback(
|
|||
psPortCtrl->sRHPortDev.pUDev = udev;
|
||||
psPortCtrl->sRHPortDev.bRHParent = TRUE;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
|
||||
if (udev->speed == SPEED_HIGH)
|
||||
rt_usbh_root_hub_connect_handler(&s_sUSBHDev.uhcd, port_index, RT_TRUE);
|
||||
|
@ -814,7 +811,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: udev not found\n"));
|
||||
LOG_D("ERROR: udev not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -830,7 +827,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
psPortCtrl->sRHPortDev.pUDev = NULL;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnect\n"));
|
||||
LOG_D("usb disconnect");
|
||||
|
||||
rt_usbh_root_hub_disconnect_handler(&s_sUSBHDev.uhcd, port_index);
|
||||
|
||||
|
|
|
@ -20,12 +20,9 @@
|
|||
#include "usb.h"
|
||||
#include "usbh_lib.h"
|
||||
|
||||
#define LOG_TAG "drv.usbhost"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL LOG_LVL_DBG
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <drv_log.h>
|
||||
|
||||
#if !defined(NU_USBHOST_HUB_POLLING_INTERVAL)
|
||||
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
|
||||
|
@ -127,7 +124,7 @@ GetRHPortControlFromPipe(
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT\n"));
|
||||
LOG_D("nu_open_pipe ERROR: port index over NU_MAX_USBH_PORT");
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
@ -169,14 +166,14 @@ static rt_err_t nu_reset_port(rt_uint8_t port)
|
|||
|
||||
if (port > NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: port index over NU_MAX_USBH_PORT\n", __func__));
|
||||
LOG_D("%s ERROR: port index over NU_MAX_USBH_PORT", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
psPortCtrl = &s_sUSBHDev.asPortCtrl[port - 1];
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
|
@ -274,13 +271,13 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
psPortCtrl = GetRHPortControlFromPipe(pipe);
|
||||
if (psPortCtrl == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: RHPort not found\n", __func__));
|
||||
LOG_D("%s ERROR: RHPort not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
if (psPortCtrl->sRHPortDev.pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: udev not found\n", __func__));
|
||||
LOG_D("%s ERROR: udev not found", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -293,7 +290,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
|
||||
if (psPortDev == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_open_pipe ERROR: udev allocate failed\n"));
|
||||
LOG_D("nu_open_pipe ERROR: udev allocate failed");
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -324,7 +321,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
|
|||
EP_INFO_T *psEPInfo = GetFreePipe(psPortCtrl, psPortDev, &pipe->pipe_index);
|
||||
if (psEPInfo == RT_NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s ERROR: get free pipe failed\n", __func__));
|
||||
LOG_D("%s ERROR: get free pipe failed", __func__);
|
||||
goto exit_nu_open_pipe;
|
||||
}
|
||||
|
||||
|
@ -420,13 +417,13 @@ static int nu_ctrl_xfer(
|
|||
ret = usbh_ctrl_xfer(psPortDev->pUDev, psSetup->request_type, psSetup->bRequest, psSetup->wValue, psSetup->wIndex, psSetup->wLength, buffer, &xfer_len, timeouts * 10);
|
||||
if (ret < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer failed %d\n", ret));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer failed %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (xfer_len != psSetup->wLength)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_ctrl_xfer ERROR: xfer length %d %d\n", psSetup->wLength, xfer_len));
|
||||
LOG_D("nu_ctrl_xfer ERROR: xfer length %d %d\n", psSetup->wLength, xfer_len);
|
||||
}
|
||||
|
||||
if ((psSetup->bRequest == USB_REQ_SET_ADDRESS) && ((psSetup->request_type & 0x60) == REQ_TYPE_STD_DEV))
|
||||
|
@ -500,7 +497,7 @@ static int nu_int_xfer(
|
|||
|
||||
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Request %08x Timeout in %d ms!!\n", psUTR, timeouts));
|
||||
LOG_D("Request %08x Timeout in %d ms\n", psUTR, timeouts);
|
||||
usbh_quit_utr(psUTR);
|
||||
|
||||
rt_completion_init(&(psPortDev->utr_completion));
|
||||
|
@ -509,7 +506,7 @@ static int nu_int_xfer(
|
|||
else
|
||||
{
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("Transferring done %08x\n", psUTR));
|
||||
LOG_D("Transferring done %08x\n", psUTR);
|
||||
usbh_quit_utr(psUTR);
|
||||
break;
|
||||
}
|
||||
|
@ -546,7 +543,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
psPortDev = GetPortDevFromPipe(pipe);
|
||||
if (psPortDev->pUDev == NULL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: udev not found\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: udev not found");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -625,7 +622,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
}
|
||||
else
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("%d == USBH_PID_DATA, nil buf-%d \n", token, nbytes));
|
||||
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
|
||||
}
|
||||
|
||||
} //else
|
||||
|
@ -639,7 +636,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
|
||||
if (!psUTR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: unable alloc UTR\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: unable alloc UTR");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -659,7 +656,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_bulk_xfer(psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: bulk transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: bulk transfer failed");
|
||||
goto failreport_nu_pipe_xfer;
|
||||
}
|
||||
}
|
||||
|
@ -667,7 +664,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
{
|
||||
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: int transfer failed\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
|
||||
//goto exit_nu_pipe_xfer;
|
||||
}
|
||||
else
|
||||
|
@ -679,7 +676,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
|||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
|
||||
{
|
||||
//TODO: ISO transfer
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: isoc transfer not support\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
|
||||
goto exit_nu_pipe_xfer;
|
||||
}
|
||||
|
||||
|
@ -690,7 +687,7 @@ failreport_nu_pipe_xfer:
|
|||
if (psUTR->bIsTransferDone == 0)
|
||||
{
|
||||
//Timeout
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: timeout\n"));
|
||||
LOG_D("nu_pipe_xfer ERROR: timeout");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
usbh_quit_utr(psUTR);
|
||||
}
|
||||
|
@ -781,7 +778,7 @@ static void nu_hcd_connect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: port connect slot is full\n"));
|
||||
LOG_D("ERROR: port connect slot is full");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -789,7 +786,7 @@ static void nu_hcd_connect_callback(
|
|||
psPortCtrl->sRHPortDev.pUDev = udev;
|
||||
psPortCtrl->sRHPortDev.bRHParent = TRUE;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
|
||||
if (udev->speed == SPEED_HIGH)
|
||||
rt_usbh_root_hub_connect_handler(&s_sUSBHDev.uhcd, port_index, RT_TRUE);
|
||||
|
@ -814,7 +811,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
if (i >= NU_MAX_USBH_PORT)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ERROR: udev not found\n"));
|
||||
LOG_D("ERROR: udev not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -830,7 +827,7 @@ static void nu_hcd_disconnect_callback(
|
|||
|
||||
psPortCtrl->sRHPortDev.pUDev = NULL;
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnect\n"));
|
||||
LOG_D("usb disconnect");
|
||||
|
||||
rt_usbh_root_hub_disconnect_handler(&s_sUSBHDev.uhcd, port_index);
|
||||
|
||||
|
|
|
@ -8,9 +8,14 @@
|
|||
* 2017-10-30 ZYH the first version
|
||||
* 2019-12-19 tyustli port to stm32 series
|
||||
*/
|
||||
|
||||
#include "drv_usbh.h"
|
||||
#include "board.h"
|
||||
|
||||
#define LOG_TAG "drv.usb.host"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <drv_log.h>
|
||||
|
||||
static HCD_HandleTypeDef stm32_hhcd_fs;
|
||||
static struct rt_completion urb_completion;
|
||||
static volatile rt_bool_t connect_status = RT_FALSE;
|
||||
|
@ -28,7 +33,7 @@ void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd)
|
|||
if (!connect_status)
|
||||
{
|
||||
connect_status = RT_TRUE;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb connected\n"));
|
||||
LOG_D("usb connected");
|
||||
rt_usbh_root_hub_connect_handler(hcd, OTG_FS_PORT, RT_FALSE);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +44,7 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd)
|
|||
if (connect_status)
|
||||
{
|
||||
connect_status = RT_FALSE;
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("usb disconnnect\n"));
|
||||
LOG_D("usb disconnnect");
|
||||
rt_usbh_root_hub_disconnect_handler(hcd, OTG_FS_PORT);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +56,7 @@ void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum,
|
|||
|
||||
static rt_err_t drv_reset_port(rt_uint8_t port)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("reset port\n"));
|
||||
LOG_D("reset port");
|
||||
HAL_HCD_ResetPort(&stm32_hhcd_fs);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
@ -79,7 +84,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
rt_thread_mdelay(1);
|
||||
if (HAL_HCD_HC_GetState(&stm32_hhcd_fs, pipe->pipe_index) == HC_NAK)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nak\n"));
|
||||
LOG_D("nak");
|
||||
if (pipe->ep.bmAttributes == USB_EP_ATTR_INT)
|
||||
{
|
||||
rt_thread_delay((pipe->ep.bInterval * RT_TICK_PER_SECOND / 1000) > 0 ? (pipe->ep.bInterval * RT_TICK_PER_SECOND / 1000) : 1);
|
||||
|
@ -96,7 +101,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
}
|
||||
else if (HAL_HCD_HC_GetState(&stm32_hhcd_fs, pipe->pipe_index) == HC_STALL)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("stall\n"));
|
||||
LOG_D("stall");
|
||||
pipe->status = UPIPE_STATUS_STALL;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -106,7 +111,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
}
|
||||
else if (HAL_HCD_HC_GetState(&stm32_hhcd_fs, pipe->pipe_index) == URB_ERROR)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("error\n"));
|
||||
LOG_D("error");
|
||||
pipe->status = UPIPE_STATUS_ERROR;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
@ -116,7 +121,7 @@ static int drv_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbyte
|
|||
}
|
||||
else if(URB_DONE == HAL_HCD_HC_GetURBState(&stm32_hhcd_fs, pipe->pipe_index))
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("ok\n"));
|
||||
LOG_D("ok");
|
||||
pipe->status = UPIPE_STATUS_OK;
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#define USB_THREAD_STACK_SIZE 4096
|
||||
|
||||
#define DBG_TAG "usbhost.hub"
|
||||
#define DBG_TAG "usb.host.hub"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
|
@ -405,7 +405,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
|
|||
ret = rt_usbh_hub_get_port_status(hub, i + 1, &pstatus);
|
||||
if(ret != RT_EOK) continue;
|
||||
|
||||
RT_DEBUG_LOG_D("port %d status 0x%x", i + 1, pstatus);
|
||||
LOG_D("port %d status 0x%x", i + 1, pstatus);
|
||||
|
||||
/* check port status change */
|
||||
if (pstatus & PORT_CCSC)
|
||||
|
@ -512,8 +512,6 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
|
|||
/* paremeter check */
|
||||
RT_ASSERT(intf != RT_NULL);
|
||||
|
||||
RT_DEBUG_LOG_D("rt_usbh_hub_run");
|
||||
|
||||
/* get usb device instance */
|
||||
device = intf->device;
|
||||
|
||||
|
@ -613,7 +611,7 @@ static rt_err_t rt_usbh_hub_disable(void* arg)
|
|||
/* paremeter check */
|
||||
RT_ASSERT(intf != RT_NULL);
|
||||
|
||||
RT_DEBUG_LOG_D("rt_usbh_hub_stop");
|
||||
LOG_D("rt_usbh_hub_stop");
|
||||
hub = (uhub_t)intf->user_data;
|
||||
|
||||
for(i=0; i<hub->num_ports; i++)
|
||||
|
@ -662,8 +660,6 @@ static void rt_usbh_hub_thread_entry(void* parameter)
|
|||
if (rt_mq_recv(hcd->usb_mq, &msg, sizeof(struct uhost_msg), RT_WAITING_FOREVER) < 0)
|
||||
continue;
|
||||
|
||||
//RT_DEBUG_LOG_D("msg type %d", msg.type);
|
||||
|
||||
switch (msg.type)
|
||||
{
|
||||
case USB_MSG_CONNECT_CHANGE:
|
||||
|
|
Loading…
Reference in New Issue