Fix unfinished printer host demo - some printer languages use embedded NULLs and...
[pub/lufa.git] / Demos / Host / LowLevel / StillImageHost / Lib / StillImageCommands.c
index f2f666b..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
@@ -109,10 +113,10 @@ uint8_t SImage_RecieveBlockHeader(void)
        while (!(Pipe_IsReadWriteAllowed()))\r
        {\r
                /* Check to see if a new frame has been issued (1ms elapsed) */\r
-               if (FrameElapsed)\r
+               if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
                {\r
                        /* Clear the flag and decrement the timeout period counter */\r
-                       FrameElapsed = false;\r
+                       USB_INT_Clear(USB_INT_HSOFI);\r
                        TimeoutMSRem--;\r
 \r
                        /* Check to see if the timeout period for the command has elapsed */\r
@@ -190,29 +194,33 @@ uint8_t SImage_RecieveBlockHeader(void)
 \r
 /** Function to send the given data to the device, after a command block has been issued.\r
  *\r
- *  \param Buffer  Source data buffer to send to the device\r
- *  \param Bytes   Number of bytes to send\r
+ *  \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
  *\r
- *  \param Buffer  Destination data buffer to put read bytes from the device\r
- *  \param Bytes   Number of bytes to receive\r
+ *  \param[out] Buffer  Destination data buffer to put read bytes from the device\r
+ *  \param[in] Bytes    Number of bytes to receive\r
  *\r
  *  \return A value from the Pipe_Stream_RW_ErrorCodes_t enum\r
  */\r
@@ -257,7 +265,7 @@ bool SImage_IsEventReceived(void)
 \r
 /** Clears the stall condition in the attached device on the nominated endpoint number.\r
  *\r
- *  \param EndpointNum  Endpoint number in the attached device whose stall condition is to be cleared\r
+ *  \param[in] EndpointNum  Endpoint number in the attached device whose stall condition is to be cleared\r
  *\r
  *  \return A value from the USB_Host_SendControlErrorCodes_t enum\r
  */\r