@@ -699,7 +699,8 @@ void USBHost::printList(ENDPOINT_TYPE type)
699
699
// add a transfer on the TD linked list
700
700
USB_TYPE USBHost::addTransfer (USBEndpoint * ed, uint8_t * buf, uint32_t len)
701
701
{
702
- td_mutex.lock ();
702
+ USB_TYPE ret=USB_TYPE_PROCESSING;
703
+ td_mutex.lock ();
703
704
704
705
// allocate a TD which will be freed in TDcompletion
705
706
volatile HCTD * td = ed->getNextTD ();
@@ -734,7 +735,7 @@ USB_TYPE USBHost::addTransfer(USBEndpoint * ed, uint8_t * buf, uint32_t len)
734
735
735
736
td_mutex.unlock ();
736
737
737
- return USB_TYPE_PROCESSING ;
738
+ return ret ;
738
739
}
739
740
740
741
@@ -1033,9 +1034,9 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
1033
1034
printf (" \r\n\r\n " );
1034
1035
}
1035
1036
#endif
1036
- addTransfer (ep, buf, len);
1037
+ res = addTransfer (ep, buf, len);
1037
1038
1038
- if (blocking) {
1039
+ if (( blocking)&& (res == USB_TYPE_PROCESSING) ) {
1039
1040
1040
1041
ep->ep_queue .get ();
1041
1042
res = ep->getState ();
@@ -1049,7 +1050,7 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
1049
1050
return USB_TYPE_OK;
1050
1051
}
1051
1052
1052
- return USB_TYPE_PROCESSING ;
1053
+ return res ;
1053
1054
1054
1055
}
1055
1056
@@ -1090,9 +1091,9 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
1090
1091
#endif
1091
1092
1092
1093
control->setNextToken (TD_SETUP);
1093
- addTransfer (control, (uint8_t *)setupPacket, 8 );
1094
+ res = addTransfer (control, (uint8_t *)setupPacket, 8 );
1094
1095
1095
- control->ep_queue .get ();
1096
+ if (res == USB_TYPE_PROCESSING) control->ep_queue .get ();
1096
1097
res = control->getState ();
1097
1098
1098
1099
USB_DBG_TRANSFER (" CONTROL setup stage %s" , control->getStateString ());
@@ -1104,9 +1105,9 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
1104
1105
if (length_transfer) {
1105
1106
token = (write) ? TD_OUT : TD_IN;
1106
1107
control->setNextToken (token);
1107
- addTransfer (control, (uint8_t *)buf, length_transfer);
1108
+ res = addTransfer (control, (uint8_t *)buf, length_transfer);
1108
1109
1109
- control->ep_queue .get ();
1110
+ if (res == USB_TYPE_PROCESSING) control->ep_queue .get ();
1110
1111
res = control->getState ();
1111
1112
1112
1113
#if DEBUG_TRANSFER
@@ -1131,9 +1132,9 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType,
1131
1132
1132
1133
token = (write) ? TD_IN : TD_OUT;
1133
1134
control->setNextToken (token);
1134
- addTransfer (control, NULL , 0 );
1135
+ res = addTransfer (control, NULL , 0 );
1135
1136
1136
- control->ep_queue .get ();
1137
+ if (res == USB_TYPE_PROCESSING) control->ep_queue .get ();
1137
1138
res = control->getState ();
1138
1139
1139
1140
USB_DBG_TRANSFER (" CONTROL ack stage %s" , control->getStateString ());
0 commit comments