/* Returns the direction of an endpoint given its descriptor.  */
unsigned char USBEndpointDescriptor_GetDirection(const USBEndpointDescriptor *endpoint)
/* Returns the direction of an endpoint given its descriptor.  */
unsigned char USBEndpointDescriptor_GetDirection(const USBEndpointDescriptor *endpoint)
{
    if ((endpoint->bEndpointAddress & 0x80) != 0) {
        return USBEndpointDescriptor_IN;
    }
    else {
        return USBEndpointDescriptor_OUT;
    }
}