Added error codes to most StillImageHost demo commands.
[pub/USBasp.git] / Demos / Host / LowLevel / StillImageHost / Lib / StillImageCommands.c
index bf85750..c0a9575 100644 (file)
@@ -80,20 +80,24 @@ void SImage_SendBlockHeader(void)
 }\r
 \r
 /** Function to receive a PIMA event container from the attached still image device. */\r
-void SImage_RecieveEventHeader(void)\r
+uint8_t SImage_RecieveEventHeader(void)\r
 {\r
+       uint8_t ErrorCode;\r
+\r
        /* Unfreeze the events pipe */\r
        Pipe_SelectPipe(SIMAGE_EVENTS_PIPE);\r
        Pipe_Unfreeze();\r
        \r
        /* Read in the event data into the global structure */\r
-       Pipe_Read_Stream_LE(&PIMA_EventBlock, sizeof(PIMA_EventBlock));\r
+       ErrorCode = Pipe_Read_Stream_LE(&PIMA_EventBlock, sizeof(PIMA_EventBlock));\r
        \r
        /* Clear the pipe after read complete to prepare for next event */\r
        Pipe_ClearIN();\r
        \r
        /* Freeze the event pipe again after use */\r
        Pipe_Freeze();\r
+       \r
+       return ErrorCode;\r
 }\r
 \r
 /** Function to receive a PIMA response container from the attached still image device. */\r
@@ -193,20 +197,24 @@ uint8_t SImage_RecieveBlockHeader(void)
  *  \param[in] Buffer  Source data buffer to send to the device\r
  *  \param[in] Bytes   Number of bytes to send\r
  */\r
-void SImage_SendData(void* Buffer, uint16_t Bytes)\r
+uint8_t SImage_SendData(void* Buffer, uint16_t Bytes)\r
 {\r
+       uint8_t ErrorCode;\r
+\r
        /* Unfreeze the data OUT pipe */\r
        Pipe_SelectPipe(SIMAGE_DATA_OUT_PIPE);\r
        Pipe_Unfreeze();\r
        \r
        /* Write the data contents to the pipe */\r
-       Pipe_Write_Stream_LE(Buffer, Bytes);\r
+       ErrorCode = Pipe_Write_Stream_LE(Buffer, Bytes);\r
 \r
        /* Send the last packet to the attached device */\r
        Pipe_ClearOUT();\r
 \r
        /* Freeze the pipe again after use */\r
        Pipe_Freeze();\r
+       \r
+       return ErrorCode;\r
 }\r
 \r
 /** Function to receive the given data to the device, after a response block has been received.\r