USBHOST: USBHOST_OTHER Add timeout on TD (indentation)

pull/4231/head
Michel Jaouen 2017-04-21 11:39:21 +02:00
parent 309b9aef62
commit f3c6f95b0a
2 changed files with 59 additions and 9 deletions

View File

@ -1115,8 +1115,19 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
res = addTransfer(ep, buf, len);
if ((blocking)&& (res == USB_TYPE_PROCESSING)) {
#ifdef USBHOST_OTHER
osEvent event = ep->ep_queue.get(TD_TIMEOUT);
if (event.status == osEventTimeout) {
/* control endpoint is confusing for merge on b */
disableList(CONTROL_ENDPOINT);
ep->setState(USB_TYPE_ERROR);
ep->ep_queue.get(0);
ep->unqueueTransfer(ep->getProcessedTD());
enableList(CONTROL_ENDPOINT);
}
#else
ep->ep_queue.get();
#endif
res = ep->getState();
USB_DBG_TRANSFER("%s TRANSFER res: %s on ep: %p\r\n", type_str, ep->getStateString(), ep);
@ -1174,9 +1185,21 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
control->setNextToken(TD_SETUP);
res = addTransfer(control, (uint8_t*)setupPacket, 8);
if (res == USB_TYPE_PROCESSING) {
control->ep_queue.get();
if (res == USB_TYPE_PROCESSING)
#ifdef USBHOST_OTHER
{
osEvent event = control->ep_queue.get(TD_TIMEOUT_CTRL);
if (event.status == osEventTimeout) {
disableList(CONTROL_ENDPOINT);
control->setState(USB_TYPE_ERROR);
control->ep_queue.get(0);
control->unqueueTransfer(control->getProcessedTD());
enableList(CONTROL_ENDPOINT);
}
}
#else
control->ep_queue.get();
#endif
res = control->getState();
USB_DBG_TRANSFER("CONTROL setup stage %s", control->getStateString());
@ -1190,9 +1213,21 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
control->setNextToken(token);
res = addTransfer(control, (uint8_t *)buf, length_transfer);
if (res == USB_TYPE_PROCESSING) {
control->ep_queue.get();
if (res == USB_TYPE_PROCESSING)
#ifdef USBHOST_OTHER
{
osEvent event = control->ep_queue.get(TD_TIMEOUT_CTRL);
if (event.status == osEventTimeout) {
disableList(CONTROL_ENDPOINT);
control->setState(USB_TYPE_ERROR);
control->ep_queue.get(0);
control->unqueueTransfer(control->getProcessedTD());
enableList(CONTROL_ENDPOINT);
}
}
#else
control->ep_queue.get();
#endif
res = control->getState();
#if DEBUG_TRANSFER
@ -1220,10 +1255,21 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
token = (write) ? TD_IN : TD_OUT;
control->setNextToken(token);
res = addTransfer(control, NULL, 0);
if (res == USB_TYPE_PROCESSING) {
control->ep_queue.get();
if (res == USB_TYPE_PROCESSING)
#ifdef USBHOST_OTHER
{
osEvent event = control->ep_queue.get(TD_TIMEOUT_CTRL);
if (event.status == osEventTimeout) {
disableList(CONTROL_ENDPOINT);
control->setState(USB_TYPE_ERROR);
control->ep_queue.get(0);
control->unqueueTransfer(control->getProcessedTD());
enableList(CONTROL_ENDPOINT);
}
}
#else
control->ep_queue.get();
#endif
res = control->getState();
USB_DBG_TRANSFER("CONTROL ack stage %s", control->getStateString());

View File

@ -117,6 +117,8 @@ enum ENDPOINT_TYPE {
#else
#define TD_TIMEOUT_CTRL 100
#define TD_TIMEOUT 2000
#define TD_SETUP (uint32_t)(0) // Direction of Setup Packet
#define TD_IN (uint32_t)(0x00100000) // Direction In
#define TD_OUT (uint32_t)(0x00080000) // Direction Out
@ -152,11 +154,13 @@ enum ENDPOINT_TYPE {
#if defined(USBHOST_OTHER)
typedef struct hcTd {
__IO uint32_t state;
__IO uint32_t state;
__IO uint8_t * currBufPtr; // Physical address of current buffer pointer
__IO hcTd * nextTD; // Physical pointer to next Transfer Descriptor
__IO uint32_t size; // size of buffer
void * ep; // ep address where a td is linked in
__IO uint32_t retry;
__IO uint32_t setup;
} PACKED HCTD;
// ----------- HostController EndPoint Descriptor -------------
typedef struct hcEd {