From 47f6a35013b2c6a370e5dce29aa6da3a96844695 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sat, 14 Apr 2012 14:41:17 +0000 Subject: Reintegrate the FullEPAddresses development branch into trunk. --- LUFA/Drivers/USB/Class/Host/CDCClassHost.c | 90 +++++++++--------------------- 1 file changed, 27 insertions(+), 63 deletions(-) (limited to 'LUFA/Drivers/USB/Class/Host/CDCClassHost.c') diff --git a/LUFA/Drivers/USB/Class/Host/CDCClassHost.c b/LUFA/Drivers/USB/Class/Host/CDCClassHost.c index 63df6b0c5..8c79e9c22 100644 --- a/LUFA/Drivers/USB/Class/Host/CDCClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/CDCClassHost.c @@ -99,62 +99,26 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo } } - for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) - { - uint16_t Size; - uint8_t Type; - uint8_t Token; - uint8_t EndpointAddress; - uint8_t InterruptPeriod; - bool DoubleBanked; - - if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber) - { - Size = le16_to_cpu(DataINEndpoint->EndpointSize); - EndpointAddress = DataINEndpoint->EndpointAddress; - Token = PIPE_TOKEN_IN; - Type = EP_TYPE_BULK; - DoubleBanked = CDCInterfaceInfo->Config.DataINPipeDoubleBank; - InterruptPeriod = 0; - - CDCInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; - } - else if (PipeNum == CDCInterfaceInfo->Config.DataOUTPipeNumber) - { - Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); - EndpointAddress = DataOUTEndpoint->EndpointAddress; - Token = PIPE_TOKEN_OUT; - Type = EP_TYPE_BULK; - DoubleBanked = CDCInterfaceInfo->Config.DataOUTPipeDoubleBank; - InterruptPeriod = 0; - - CDCInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; - } - else if (PipeNum == CDCInterfaceInfo->Config.NotificationPipeNumber) - { - Size = le16_to_cpu(NotificationEndpoint->EndpointSize); - EndpointAddress = NotificationEndpoint->EndpointAddress; - Token = PIPE_TOKEN_IN; - Type = EP_TYPE_INTERRUPT; - DoubleBanked = CDCInterfaceInfo->Config.NotificationPipeDoubleBank; - InterruptPeriod = NotificationEndpoint->PollingIntervalMS; - - CDCInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize; - } - else - { - continue; - } - - if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size, - DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE))) - { - return CDC_ENUMERROR_PipeConfigurationFailed; - } - - if (InterruptPeriod) - Pipe_SetInterruptPeriod(InterruptPeriod); - } + CDCInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + CDCInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + CDCInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + CDCInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + CDCInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + CDCInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + CDCInterfaceInfo->Config.NotificationPipe.Size = le16_to_cpu(NotificationEndpoint->EndpointSize); + CDCInterfaceInfo->Config.NotificationPipe.EndpointAddress = NotificationEndpoint->EndpointAddress; + CDCInterfaceInfo->Config.NotificationPipe.Type = EP_TYPE_INTERRUPT; + + if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.NotificationPipe, 1))) + return false; CDCInterfaceInfo->State.ControlInterfaceNumber = CDCControlInterface->InterfaceNumber; CDCInterfaceInfo->State.ControlLineStates.HostToDevice = (CDC_CONTROL_LINE_OUT_RTS | CDC_CONTROL_LINE_OUT_DTR); @@ -231,7 +195,7 @@ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) return; - Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber); + Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipe.Address); Pipe_Unfreeze(); if (Pipe_IsINReceived()) @@ -321,7 +285,7 @@ uint8_t CDC_Host_SendData(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint8_t ErrorCode; - Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL); @@ -338,7 +302,7 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint8_t ErrorCode; - Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL); @@ -355,7 +319,7 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint8_t ErrorCode; - Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); if (!(Pipe_IsReadWriteAllowed())) @@ -377,7 +341,7 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) return 0; - Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber); + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipe.Address); Pipe_Unfreeze(); if (Pipe_IsINReceived()) @@ -409,7 +373,7 @@ int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) int16_t ReceivedByte = -1; - Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber); + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipe.Address); Pipe_Unfreeze(); if (Pipe_IsINReceived()) @@ -433,7 +397,7 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) uint8_t ErrorCode; - Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); if (!(Pipe_BytesInPipe())) -- cgit v1.2.3