Added new Printer Host mode Class driver.
[pub/USBasp.git] / Demos / Host / LowLevel / StillImageHost / Lib / StillImageCommands.c
index e0d71a0..4735781 100644 (file)
@@ -37,7 +37,6 @@
 \r
 #include "StillImageCommands.h"\r
 \r
-/* Globals: */\r
 /** PIMA block container for the block to send to the device */\r
 PIMA_Container_t PIMA_SendBlock;\r
 \r
@@ -80,7 +79,7 @@ void SImage_SendBlockHeader(void)
 }\r
 \r
 /** Function to receive a PIMA event container from the attached still image device. */\r
-uint8_t SImage_RecieveEventHeader(void)\r
+uint8_t SImage_ReceiveEventHeader(void)\r
 {\r
        uint8_t ErrorCode;\r
 \r
@@ -101,7 +100,7 @@ uint8_t SImage_RecieveEventHeader(void)
 }\r
 \r
 /** Function to receive a PIMA response container from the attached still image device. */\r
-uint8_t SImage_RecieveBlockHeader(void)\r
+uint8_t SImage_ReceiveBlockHeader(void)\r
 {\r
        uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;\r
 \r
@@ -127,7 +126,9 @@ uint8_t SImage_RecieveBlockHeader(void)
                        }\r
                }\r
                \r
+               Pipe_Freeze();\r
                Pipe_SelectPipe(SIMAGE_DATA_OUT_PIPE);\r
+               Pipe_Unfreeze();\r
 \r
                /* Check if pipe stalled (command failed by device) */\r
                if (Pipe_IsStalled())\r
@@ -139,7 +140,9 @@ uint8_t SImage_RecieveBlockHeader(void)
                        return PIPE_RWSTREAM_PipeStalled;\r
                }\r
 \r
+               Pipe_Freeze();\r
                Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE);\r
+               Pipe_Unfreeze();\r
 \r
                /* Check if pipe stalled (command failed by device) */\r
                if (Pipe_IsStalled())\r
@@ -152,20 +155,10 @@ uint8_t SImage_RecieveBlockHeader(void)
                }\r
                  \r
                /* Check to see if the device was disconnected, if so exit function */\r
-               if (!(USB_IsConnected))\r
-               {\r
-                       /* Return error code */\r
-                       return PIPE_RWSTREAM_DeviceDisconnected;\r
-               }\r
-       };\r
-       \r
-       /* Freeze OUT pipe after use */\r
-       Pipe_SelectPipe(SIMAGE_DATA_OUT_PIPE);\r
-       Pipe_Freeze();\r
-\r
-       /* Select the IN data pipe for data reception */\r
-       Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE);\r
-       \r
+               if (USB_HostState == HOST_STATE_Unattached)\r
+                 return PIPE_RWSTREAM_DeviceDisconnected;\r
+       }\r
+               \r
        /* Load in the response from the attached device */\r
        Pipe_Read_Stream_LE(&PIMA_ReceivedBlock, PIMA_COMMAND_SIZE(0));\r
        \r