diff --git a/BTD.cpp b/BTD.cpp index df1de1b8..07f03339 100644 --- a/BTD.cpp +++ b/BTD.cpp @@ -335,15 +335,13 @@ void BTD::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto bConfNum = conf; uint8_t index; - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) { // Interrupt In endpoint found + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) { // Interrupt In endpoint found index = BTD_EVENT_PIPE; epInfo[index].bmNakPower = USB_NAK_NOWAIT; - } else { - if((pep->bmAttributes & 0x02) == 2) // Bulk endpoint found - index = ((pep->bEndpointAddress & 0x80) == 0x80) ? BTD_DATAIN_PIPE : BTD_DATAOUT_PIPE; - else - return; - } + } else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) // Bulk endpoint found + index = ((pep->bEndpointAddress & 0x80) == 0x80) ? BTD_DATAIN_PIPE : BTD_DATAOUT_PIPE; + else + return; // Fill the rest of endpoint data structure epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); diff --git a/adk.cpp b/adk.cpp index f9631ae8..a60bb85a 100644 --- a/adk.cpp +++ b/adk.cpp @@ -321,7 +321,7 @@ void ADK::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto bConfNum = conf; - if((pep->bmAttributes & 0x02) == 2) { + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) { uint8_t index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; // Fill in the endpoint info structure epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); diff --git a/cdcacm.cpp b/cdcacm.cpp index 6611cd3c..548b4685 100644 --- a/cdcacm.cpp +++ b/cdcacm.cpp @@ -237,10 +237,9 @@ void ACM::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto uint8_t index; - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) index = epInterruptInIndex; - else - if((pep->bmAttributes & 0x02) == 2) + else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; else return; diff --git a/cdcftdi.cpp b/cdcftdi.cpp index 14420847..fbdd033e 100644 --- a/cdcftdi.cpp +++ b/cdcftdi.cpp @@ -229,10 +229,9 @@ void FTDI::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t prot uint8_t index; - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) index = epInterruptInIndex; - else - if((pep->bmAttributes & 0x02) == 2) + else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; else return; diff --git a/hidboot.h b/hidboot.h index 6c192dac..df4fa421 100644 --- a/hidboot.h +++ b/hidboot.h @@ -546,7 +546,7 @@ void HIDBoot::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t bConfNum = conf; bIfaceNum = iface; - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) { + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) { if(pep->bInterval > bInterval) bInterval = pep->bInterval; // Fill in the endpoint info structure diff --git a/hidcomposite.cpp b/hidcomposite.cpp index 65cbb6ef..3f0a21c2 100644 --- a/hidcomposite.cpp +++ b/hidcomposite.cpp @@ -313,29 +313,27 @@ void HIDComposite::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint bNumIface++; } - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) - index = epInterruptInIndex; - else - index = epInterruptOutIndex; + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT) + index = (pep->bEndpointAddress & 0x80) == 0x80 ? epInterruptInIndex : epInterruptOutIndex; if(!SelectInterface(iface, proto)) - index = 0; + index = 0; if(index) { - // Fill in the endpoint info structure - epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[bNumEP].bmSndToggle = 0; - epInfo[bNumEP].bmRcvToggle = 0; - epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT; + // Fill in the endpoint info structure + epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F); + epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize; + epInfo[bNumEP].bmSndToggle = 0; + epInfo[bNumEP].bmRcvToggle = 0; + epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT; - // Fill in the endpoint index list - piface->epIndex[index] = bNumEP; //(pep->bEndpointAddress & 0x0F); + // Fill in the endpoint index list + piface->epIndex[index] = bNumEP; //(pep->bEndpointAddress & 0x0F); - if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints - pollInterval = pep->bInterval; + if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints + pollInterval = pep->bInterval; - bNumEP++; + bNumEP++; } } diff --git a/hiduniversal.cpp b/hiduniversal.cpp index cef4b329..49309df4 100644 --- a/hiduniversal.cpp +++ b/hiduniversal.cpp @@ -315,10 +315,8 @@ void HIDUniversal::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint bNumIface++; } - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) - index = epInterruptInIndex; - else - index = epInterruptOutIndex; + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT) + index = (pep->bEndpointAddress & 0x80) == 0x80 ? epInterruptInIndex : epInterruptOutIndex; if(index) { // Fill in the endpoint info structure diff --git a/masstorage.cpp b/masstorage.cpp index 4c0c37ad..52b1275a 100644 --- a/masstorage.cpp +++ b/masstorage.cpp @@ -550,7 +550,7 @@ void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t uint8_t index; #if 1 - if((pep->bmAttributes & 0x02) == 2) { + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) { index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; // Fill in the endpoint info structure epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); @@ -564,10 +564,9 @@ void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t } #else - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) + if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) index = epInterruptInIndex; - else - if((pep->bmAttributes & 0x02) == 2) + else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; else return; diff --git a/usbh_midi.cpp b/usbh_midi.cpp index b4f12cf2..8bc4fd31 100644 --- a/usbh_midi.cpp +++ b/usbh_midi.cpp @@ -304,7 +304,7 @@ uint8_t USBH_MIDI::parseConfigDescr( uint8_t addr, uint8_t conf ) USBTRACE("-EPAddr:"), D_PrintHex(epDesc->bEndpointAddress, 0x80); USBTRACE(" bmAttr:"), D_PrintHex(epDesc->bmAttributes, 0x80); USBTRACE2(" MaxPktSz:", (uint8_t)epDesc->wMaxPacketSize); - if ((epDesc->bmAttributes & 0x02) == 2) {//bulk + if ((epDesc->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) {//bulk uint8_t index; if( isMidi ) index = ((epDesc->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;