Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest...
[pub/USBasp.git] / Demos / Host / StillImageHost / StillImageCommands.c
index 4d4c0b1..8f05e48 100644 (file)
@@ -72,7 +72,7 @@ void SImage_SendBlockHeader(void)
                }\r
                \r
                /* Send the PIMA command block to the attached device */\r
-               Pipe_ClearCurrentBank();\r
+               Pipe_ClearOUT();\r
        }\r
                                        \r
        /* Freeze pipe after use */\r
@@ -90,7 +90,7 @@ void SImage_RecieveEventHeader(void)
        Pipe_Read_Stream_LE(&PIMA_EventBlock, sizeof(PIMA_EventBlock));\r
        \r
        /* Clear the pipe after read complete to prepare for next event */\r
-       Pipe_ClearCurrentBank();\r
+       Pipe_ClearIN();\r
        \r
        /* Freeze the event pipe again after use */\r
        Pipe_Freeze();\r
@@ -106,12 +106,12 @@ uint8_t SImage_RecieveBlockHeader(void)
        Pipe_Unfreeze();\r
        \r
        /* Wait until data received on the IN pipe */\r
-       while (!(Pipe_ReadWriteAllowed()))\r
+       while (!(Pipe_IsReadWriteAllowed()))\r
        {\r
                /* Check to see if a new frame has been issued (1ms elapsed) */\r
                if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
                {\r
-                       /* Clear the flag and decrement the timout period counter */\r
+                       /* Clear the flag and decrement the timeout period counter */\r
                        USB_INT_Clear(USB_INT_HSOFI);\r
                        TimeoutMSRem--;\r
 \r
@@ -119,7 +119,7 @@ uint8_t SImage_RecieveBlockHeader(void)
                        if (!(TimeoutMSRem))\r
                        {\r
                                /* Return error code */\r
-                               return PIPE_RWSTREAM_ERROR_Timeout;\r
+                               return PIPE_RWSTREAM_Timeout;\r
                        }\r
                }\r
                \r
@@ -132,7 +132,7 @@ uint8_t SImage_RecieveBlockHeader(void)
                        SImage_ClearPipeStall(SIMAGE_DATA_OUT_PIPE);\r
 \r
                        /* Return error code and break out of the loop */\r
-                       return PIPE_RWSTREAM_ERROR_PipeStalled;\r
+                       return PIPE_RWSTREAM_PipeStalled;\r
                }\r
 \r
                Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE);\r
@@ -144,14 +144,14 @@ uint8_t SImage_RecieveBlockHeader(void)
                        SImage_ClearPipeStall(SIMAGE_DATA_IN_PIPE);\r
 \r
                        /* Return error code */\r
-                       return PIPE_RWSTREAM_ERROR_PipeStalled;\r
+                       return PIPE_RWSTREAM_PipeStalled;\r
                }\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_ERROR_DeviceDisconnected;\r
+                       return PIPE_RWSTREAM_DeviceDisconnected;\r
                }\r
        };\r
        \r
@@ -179,13 +179,13 @@ uint8_t SImage_RecieveBlockHeader(void)
                }\r
                \r
                /* Clear pipe bank after use */\r
-               Pipe_ClearCurrentBank();\r
+               Pipe_ClearIN();\r
        }\r
        \r
        /* Freeze the IN pipe after use */\r
        Pipe_Freeze();\r
        \r
-       return PIPE_RWSTREAM_ERROR_NoError;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 /** Function to send the given data to the device, after a command block has been issued.\r
@@ -203,7 +203,7 @@ void SImage_SendData(void* Buffer, uint16_t Bytes)
        Pipe_Write_Stream_LE(Buffer, Bytes);\r
 \r
        /* Send the last packet to the attached device */\r
-       Pipe_ClearCurrentBank();\r
+       Pipe_ClearOUT();\r
 \r
        /* Freeze the pipe again after use */\r
        Pipe_Freeze();\r
@@ -261,16 +261,19 @@ bool SImage_IsEventReceived(void)
  *\r
  *  \return A value from the USB_Host_SendControlErrorCodes_t enum\r
  */\r
-uint8_t SImage_ClearPipeStall(const uint8_t PipeEndpointNum)\r
+uint8_t SImage_ClearPipeStall(const uint8_t EndpointNum)\r
 {\r
-       USB_HostRequest = (USB_Host_Request_Header_t)\r
+       USB_ControlRequest = (USB_Request_Header_t)\r
                {\r
-                       bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
-                       bRequest:      REQ_ClearFeature,\r
-                       wValue:        FEATURE_ENDPOINT_HALT,\r
-                       wIndex:        PipeEndpointNum,\r
-                       wLength:       0,\r
+                       .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
+                       .bRequest      = REQ_ClearFeature,\r
+                       .wValue        = FEATURE_ENDPOINT_HALT,\r
+                       .wIndex        = EndpointNum,\r
+                       .wLength       = 0,\r
                };\r
        \r
+       /* Select the control pipe for the request transfer */\r
+       Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
        return USB_Host_SendControlRequest(NULL);\r
 }\r