Description
Source
Call Graph
Start Line: 789
void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor)
{
Endpoint *pEndpoint;
unsigned char bEndpoint;
unsigned char bType;
unsigned char bEndpointDir;
// NULL descriptor -> Control endpoint 0
if (pDescriptor == 0) {
bEndpoint = 0;
pEndpoint = &(endpoints[bEndpoint]);
bType= USBEndpointDescriptor_CONTROL;
bEndpointDir = 0;
pEndpoint->size = BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0);
}
else {
bEndpoint = USBEndpointDescriptor_GetNumber(pDescriptor);
pEndpoint = &(endpoints[bEndpoint]);
bType = USBEndpointDescriptor_GetType(pDescriptor);
bEndpointDir = USBEndpointDescriptor_GetDirection(pDescriptor);
pEndpoint->size = USBEndpointDescriptor_GetMaxPacketSize(pDescriptor);
}
// Abort the current transfer is the endpoint was configured and in
// Write or Read state
if ((pEndpoint->state == UDP_ENDPOINT_RECEIVING)
|| (pEndpoint->state == UDP_ENDPOINT_SENDING)) {
UDP_EndOfTransfer(bEndpoint, USBD_STATUS_RESET);
}
pEndpoint->state = UDP_ENDPOINT_IDLE;
// Reset Endpoint Fifos
AT91C_BASE_UDP->UDP_RSTEP |= (1 << bEndpoint);
AT91C_BASE_UDP->UDP_RSTEP &= ~(1 << bEndpoint);
// Configure endpoint
SET_CSR(bEndpoint, (unsigned int)AT91C_UDP_EPEDS | (bType << 8) | (bEndpointDir << 10));
if (bType == USBEndpointDescriptor_CONTROL) {
AT91C_BASE_UDP->UDP_IER = (1 << bEndpoint);
}
TRACE_INFO_WP("CfgEpt%d ", bEndpoint);
}