Skip to content

Commit 1577037

Browse files
committed
USBHOST : add return value to queue transfer
modify add transfer to support return value.
1 parent e7361eb commit 1577037

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

features/unsupported/USBHost/USBHost/USBEndpoint.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const char * USBEndpoint::getStateString() {
132132
return type_string[state].str;
133133
}
134134

135-
void USBEndpoint::queueTransfer()
135+
USB_TYPE USBEndpoint::queueTransfer()
136136
{
137137
transfer_len = (uint32_t)td_current->bufEnd - (uint32_t)td_current->currBufPtr + 1;
138138
transferred = transfer_len;
@@ -142,6 +142,7 @@ void USBEndpoint::queueTransfer()
142142
state = USB_TYPE_PROCESSING;
143143
td_current->nextTD = (hcTd*)td_next;
144144
hced->tailTD = td_next;
145+
return USB_TYPE_PROCESSING;
145146
}
146147

147148
void USBEndpoint::unqueueTransfer(volatile HCTD * td)

features/unsupported/USBHost/USBHost/USBEndpoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class USBEndpoint
6767
/**
6868
* Queue a transfer on the endpoint
6969
*/
70-
void queueTransfer();
70+
USB_TYPE queueTransfer();
7171

7272
/**
7373
* Unqueue a transfer from the endpoint

features/unsupported/USBHost/USBHost/USBHost.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,8 @@ void USBHost::printList(ENDPOINT_TYPE type)
699699
// add a transfer on the TD linked list
700700
USB_TYPE USBHost::addTransfer(USBEndpoint * ed, uint8_t * buf, uint32_t len)
701701
{
702-
td_mutex.lock();
702+
USB_TYPE ret=USB_TYPE_PROCESSING;
703+
td_mutex.lock();
703704

704705
// allocate a TD which will be freed in TDcompletion
705706
volatile HCTD * td = ed->getNextTD();
@@ -734,7 +735,7 @@ USB_TYPE USBHost::addTransfer(USBEndpoint * ed, uint8_t * buf, uint32_t len)
734735

735736
td_mutex.unlock();
736737

737-
return USB_TYPE_PROCESSING;
738+
return ret;
738739
}
739740

740741

@@ -1033,9 +1034,9 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
10331034
printf("\r\n\r\n");
10341035
}
10351036
#endif
1036-
addTransfer(ep, buf, len);
1037+
res = addTransfer(ep, buf, len);
10371038

1038-
if (blocking) {
1039+
if ((blocking)&& (res == USB_TYPE_PROCESSING)) {
10391040

10401041
ep->ep_queue.get();
10411042
res = ep->getState();
@@ -1049,7 +1050,7 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
10491050
return USB_TYPE_OK;
10501051
}
10511052

1052-
return USB_TYPE_PROCESSING;
1053+
return res;
10531054

10541055
}
10551056

@@ -1090,9 +1091,9 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
10901091
#endif
10911092

10921093
control->setNextToken(TD_SETUP);
1093-
addTransfer(control, (uint8_t*)setupPacket, 8);
1094+
res = addTransfer(control, (uint8_t*)setupPacket, 8);
10941095

1095-
control->ep_queue.get();
1096+
if (res == USB_TYPE_PROCESSING) control->ep_queue.get();
10961097
res = control->getState();
10971098

10981099
USB_DBG_TRANSFER("CONTROL setup stage %s", control->getStateString());
@@ -1104,9 +1105,9 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
11041105
if (length_transfer) {
11051106
token = (write) ? TD_OUT : TD_IN;
11061107
control->setNextToken(token);
1107-
addTransfer(control, (uint8_t *)buf, length_transfer);
1108+
res = addTransfer(control, (uint8_t *)buf, length_transfer);
11081109

1109-
control->ep_queue.get();
1110+
if (res == USB_TYPE_PROCESSING) control->ep_queue.get();
11101111
res = control->getState();
11111112

11121113
#if DEBUG_TRANSFER
@@ -1131,9 +1132,9 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
11311132

11321133
token = (write) ? TD_IN : TD_OUT;
11331134
control->setNextToken(token);
1134-
addTransfer(control, NULL, 0);
1135+
res = addTransfer(control, NULL, 0);
11351136

1136-
control->ep_queue.get();
1137+
if (res == USB_TYPE_PROCESSING) control->ep_queue.get();
11371138
res = control->getState();
11381139

11391140
USB_DBG_TRANSFER("CONTROL ack stage %s", control->getStateString());

0 commit comments

Comments
 (0)