X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/211712d66d6949941141964341bb937bf1422636..3d6508c9b9505cb3393b7c12df1a0c87f7828bbe:/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c?ds=sidebyside diff --git a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c index e0d71a059..6f8aa5179 100644 --- a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c +++ b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c @@ -37,7 +37,6 @@ #include "StillImageCommands.h" -/* Globals: */ /** PIMA block container for the block to send to the device */ PIMA_Container_t PIMA_SendBlock; @@ -79,8 +78,11 @@ void SImage_SendBlockHeader(void) Pipe_Freeze(); } -/** Function to receive a PIMA event container from the attached still image device. */ -uint8_t SImage_RecieveEventHeader(void) +/** Function to receive a PIMA event container from the attached still image device. + * + * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum + */ +uint8_t SImage_ReceiveEventHeader(void) { uint8_t ErrorCode; @@ -100,8 +102,11 @@ uint8_t SImage_RecieveEventHeader(void) return ErrorCode; } -/** Function to receive a PIMA response container from the attached still image device. */ -uint8_t SImage_RecieveBlockHeader(void) +/** Function to receive a PIMA response container from the attached still image device. + * + * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum + */ +uint8_t SImage_ReceiveBlockHeader(void) { uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS; @@ -127,7 +132,9 @@ uint8_t SImage_RecieveBlockHeader(void) } } + Pipe_Freeze(); Pipe_SelectPipe(SIMAGE_DATA_OUT_PIPE); + Pipe_Unfreeze(); /* Check if pipe stalled (command failed by device) */ if (Pipe_IsStalled()) @@ -139,7 +146,9 @@ uint8_t SImage_RecieveBlockHeader(void) return PIPE_RWSTREAM_PipeStalled; } + Pipe_Freeze(); Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE); + Pipe_Unfreeze(); /* Check if pipe stalled (command failed by device) */ if (Pipe_IsStalled()) @@ -152,20 +161,10 @@ uint8_t SImage_RecieveBlockHeader(void) } /* Check to see if the device was disconnected, if so exit function */ - if (!(USB_IsConnected)) - { - /* Return error code */ - return PIPE_RWSTREAM_DeviceDisconnected; - } - }; - - /* Freeze OUT pipe after use */ - Pipe_SelectPipe(SIMAGE_DATA_OUT_PIPE); - Pipe_Freeze(); - - /* Select the IN data pipe for data reception */ - Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE); - + if (USB_HostState == HOST_STATE_Unattached) + return PIPE_RWSTREAM_DeviceDisconnected; + } + /* Load in the response from the attached device */ Pipe_Read_Stream_LE(&PIMA_ReceivedBlock, PIMA_COMMAND_SIZE(0)); @@ -196,6 +195,8 @@ uint8_t SImage_RecieveBlockHeader(void) * * \param[in] Buffer Source data buffer to send to the device * \param[in] Bytes Number of bytes to send + * + * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum */ uint8_t SImage_SendData(void* Buffer, uint16_t Bytes) {