diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-10 19:24:58 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-10 19:24:58 +0000 |
commit | 359fbfe14d00ab378f85a36664820ea9ba538c3f (patch) | |
tree | 0929d5663a3be4dc078dda0aba5ba798ebb627ab /LUFA/Drivers/USB/Class/Host/StillImageClassHost.c | |
parent | e8570c4a37e41117e3fd1e989e0b41f1e9608f3c (diff) | |
download | lufa-359fbfe14d00ab378f85a36664820ea9ba538c3f.tar.gz lufa-359fbfe14d00ab378f85a36664820ea9ba538c3f.tar.bz2 lufa-359fbfe14d00ab378f85a36664820ea9ba538c3f.zip |
Add branch for the conversion of demos to use standard C header files for configuration, rather than makefile defined macros.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Host/StillImageClassHost.c')
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/StillImageClassHost.c | 92 |
1 files changed, 28 insertions, 64 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c b/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c index 2b5514a28..5c18d7503 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c @@ -87,63 +87,27 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, } } - 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 == SIInterfaceInfo->Config.DataINPipeNumber) - { - Size = DataINEndpoint->EndpointSize; - EndpointAddress = DataINEndpoint->EndpointAddress; - Token = PIPE_TOKEN_IN; - Type = EP_TYPE_BULK; - DoubleBanked = SIInterfaceInfo->Config.DataINPipeDoubleBank; - InterruptPeriod = 0; - - SIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; - } - else if (PipeNum == SIInterfaceInfo->Config.DataOUTPipeNumber) - { - Size = DataOUTEndpoint->EndpointSize; - EndpointAddress = DataOUTEndpoint->EndpointAddress; - Token = PIPE_TOKEN_OUT; - Type = EP_TYPE_BULK; - DoubleBanked = SIInterfaceInfo->Config.DataOUTPipeDoubleBank; - InterruptPeriod = 0; - - SIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; - } - else if (PipeNum == SIInterfaceInfo->Config.EventsPipeNumber) - { - Size = EventsEndpoint->EndpointSize; - EndpointAddress = EventsEndpoint->EndpointAddress; - Token = PIPE_TOKEN_IN; - Type = EP_TYPE_INTERRUPT; - DoubleBanked = SIInterfaceInfo->Config.EventsPipeDoubleBank; - InterruptPeriod = EventsEndpoint->PollingIntervalMS; - - SIInterfaceInfo->State.EventsPipeSize = EventsEndpoint->EndpointSize; - } - else - { - continue; - } - - if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size, - DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE))) - { - return SI_ENUMERROR_PipeConfigurationFailed; - } - - if (InterruptPeriod) - Pipe_SetInterruptPeriod(InterruptPeriod); - } + SIInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + SIInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + SIInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + SIInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + SIInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + SIInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + SIInterfaceInfo->Config.EventsPipe.Size = le16_to_cpu(EventsEndpoint->EndpointSize); + SIInterfaceInfo->Config.EventsPipe.EndpointAddress = EventsEndpoint->EndpointAddress; + SIInterfaceInfo->Config.EventsPipe.Type = EP_TYPE_INTERRUPT; + + if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.EventsPipe, 1))) + return false; + SIInterfaceInfo->State.InterfaceNumber = StillImageInterface->InterfaceNumber; SIInterfaceInfo->State.IsActive = true; @@ -204,7 +168,7 @@ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, if (SIInterfaceInfo->State.IsSessionOpen) PIMAHeader->TransactionID = cpu_to_le32(SIInterfaceInfo->State.TransactionID++); - Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); if ((ErrorCode = Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NULL)) != PIPE_RWSTREAM_NoError) @@ -233,7 +197,7 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return PIPE_RWSTREAM_DeviceDisconnected; - Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipe.Address); Pipe_Unfreeze(); while (!(Pipe_IsINReceived())) @@ -249,7 +213,7 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf } Pipe_Freeze(); - Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); if (Pipe_IsStalled()) @@ -259,7 +223,7 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf } Pipe_Freeze(); - Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipe.Address); Pipe_Unfreeze(); if (Pipe_IsStalled()) @@ -298,7 +262,7 @@ uint8_t SI_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return PIPE_RWSTREAM_DeviceDisconnected; - Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); ErrorCode = Pipe_Write_Stream_LE(Buffer, Bytes, NULL); @@ -318,7 +282,7 @@ uint8_t SI_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return PIPE_RWSTREAM_DeviceDisconnected; - Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipe.Address); Pipe_Unfreeze(); ErrorCode = Pipe_Read_Stream_LE(Buffer, Bytes, NULL); @@ -335,7 +299,7 @@ bool SI_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return false; - Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipe.Address); Pipe_Unfreeze(); if (Pipe_BytesInPipe()) @@ -354,7 +318,7 @@ uint8_t SI_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return PIPE_RWSTREAM_DeviceDisconnected; - Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber); + Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipe.Address); Pipe_Unfreeze(); ErrorCode = Pipe_Read_Stream_LE(PIMAHeader, sizeof(PIMA_Container_t), NULL); |