Add StillImage Host Class Driver functions for opening and closing sessions. Ensure...
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 2 Sep 2009 13:08:55 +0000 (13:08 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 2 Sep 2009 13:08:55 +0000 (13:08 +0000)
Fix spelling of "Received" in all source files where it is misspelt "Recieved".

20 files changed:
Demos/Host/ClassDriver/StillImageHost/StillImageHost.c
Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c
Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c
Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.h
Demos/Host/LowLevel/StillImageHost/StillImageHost.c
LUFA/Drivers/USB/Class/Common/StillImage.h
LUFA/Drivers/USB/Class/Device/CDC.h
LUFA/Drivers/USB/Class/Host/CDC.c
LUFA/Drivers/USB/Class/Host/CDC.h
LUFA/Drivers/USB/Class/Host/HID.c
LUFA/Drivers/USB/Class/Host/HID.h
LUFA/Drivers/USB/Class/Host/MassStorage.c
LUFA/Drivers/USB/Class/Host/MassStorage.h
LUFA/Drivers/USB/Class/Host/StillImage.c
LUFA/Drivers/USB/Class/Host/StillImage.h
LUFA/Drivers/USB/LowLevel/Endpoint.h
LUFA/Drivers/USB/LowLevel/Pipe.h
LUFA/ManPages/ChangeLog.txt
LUFA/ManPages/FutureChanges.txt
LUFA/ManPages/MigrationInformation.txt

index deb8a55..d60db09 100644 (file)
@@ -50,7 +50,6 @@ USB_ClassInfo_SI_Host_t DigitalCamera_SI_Interface =
                        },\r
        };\r
 \r
                        },\r
        };\r
 \r
-       \r
 /** Main program entry point. This routine configures the hardware required by the application, then\r
  *  starts the scheduler to run the application tasks.\r
  */\r
 /** Main program entry point. This routine configures the hardware required by the application, then\r
  *  starts the scheduler to run the application tasks.\r
  */\r
@@ -102,7 +101,28 @@ int main(void)
                                USB_HostState = HOST_STATE_Configured;\r
                                break;\r
                        case HOST_STATE_Configured:\r
                                USB_HostState = HOST_STATE_Configured;\r
                                break;\r
                        case HOST_STATE_Configured:\r
+                               printf("Opening Session...\r\n");\r
+                               \r
+                               if (SImage_Host_OpenSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError)\r
+                               {\r
+                                       printf("Could not open PIMA session.\r\n");\r
+                                       USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
+                                       break;\r
+                               }\r
+\r
+                               printf("Closing Session...\r\n");\r
+\r
+                               if (SImage_Host_CloseSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError)\r
+                               {\r
+                                       printf("Could not close PIMA session.\r\n");\r
+                                       USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
+                                       break;\r
+                               }\r
+                               \r
+                               printf("Device Idle.\r\n");\r
                        \r
                        \r
+                               LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+                               USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                break;\r
                }\r
        \r
                                break;\r
                }\r
        \r
index fefcbbf..7ed8898 100644 (file)
@@ -30,7 +30,7 @@
 \r
 /** \file\r
  *\r
 \r
 /** \file\r
  *\r
- *  Printer Device commands, to send/recieve data to and from an attached USB\r
+ *  Printer Device commands, to send/receive data to and from an attached USB\r
  *  printer, and to send and receive Printer Class control requests.\r
  */\r
 \r
  *  printer, and to send and receive Printer Class control requests.\r
  */\r
 \r
index fbff2f4..31b5e00 100644 (file)
@@ -80,7 +80,7 @@ void SImage_SendBlockHeader(void)
 }\r
 \r
 /** Function to receive a PIMA event container from the attached still image device. */\r
 }\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
 {\r
        uint8_t ErrorCode;\r
 \r
@@ -101,7 +101,7 @@ uint8_t SImage_RecieveEventHeader(void)
 }\r
 \r
 /** Function to receive a PIMA response container from the attached still image device. */\r
 }\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
 {\r
        uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;\r
 \r
index b44b752..6ac70fc 100644 (file)
@@ -85,7 +85,7 @@
                        uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */\r
                        uint16_t Code; /**< Command, event or response code of the container */\r
                        uint32_t TransactionID; /**< Unique container ID to link blocks together */\r
                        uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */\r
                        uint16_t Code; /**< Command, event or response code of the container */\r
                        uint32_t TransactionID; /**< Unique container ID to link blocks together */\r
-                       uint32_t Params[4]; /**< Block parameters to be issued along with the block code (command blocks only) */\r
+                       uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only) */\r
                } PIMA_Container_t;\r
        \r
        /* Enums: */\r
                } PIMA_Container_t;\r
        \r
        /* Enums: */\r
        \r
        /* Function Prototypes: */\r
                void    SImage_SendBlockHeader(void);\r
        \r
        /* Function Prototypes: */\r
                void    SImage_SendBlockHeader(void);\r
-               uint8_t SImage_RecieveBlockHeader(void);\r
-               uint8_t SImage_RecieveEventHeader(void);\r
+               uint8_t SImage_ReceiveBlockHeader(void);\r
+               uint8_t SImage_ReceiveEventHeader(void);\r
                uint8_t SImage_SendData(void* Buffer, uint16_t Bytes);\r
                uint8_t SImage_ReadData(void* Buffer, uint16_t Bytes);\r
                bool    SImage_IsEventReceived(void);\r
                uint8_t SImage_SendData(void* Buffer, uint16_t Bytes);\r
                uint8_t SImage_ReadData(void* Buffer, uint16_t Bytes);\r
                bool    SImage_IsEventReceived(void);\r
index fb768fd..75a2934 100644 (file)
@@ -189,7 +189,7 @@ void StillImage_Task(void)
                        SImage_SendBlockHeader();\r
                        \r
                        /* Receive the response data block */\r
                        SImage_SendBlockHeader();\r
                        \r
                        /* Receive the response data block */\r
-                       if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
+                       if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
@@ -242,7 +242,7 @@ void StillImage_Task(void)
                        printf_P(PSTR("   Device Version: %s\r\n"), DeviceVersion);\r
 \r
                        /* Receive the final response block from the device */\r
                        printf_P(PSTR("   Device Version: %s\r\n"), DeviceVersion);\r
 \r
                        /* Receive the final response block from the device */\r
-                       if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
+                       if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
@@ -274,7 +274,7 @@ void StillImage_Task(void)
                        SImage_SendBlockHeader();\r
                        \r
                        /* Receive the response block from the device */\r
                        SImage_SendBlockHeader();\r
                        \r
                        /* Receive the response block from the device */\r
-                       if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
+                       if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
@@ -306,7 +306,7 @@ void StillImage_Task(void)
                        SImage_SendBlockHeader();\r
                        \r
                        /* Receive the response block from the device */\r
                        SImage_SendBlockHeader();\r
                        \r
                        /* Receive the response block from the device */\r
-                       if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
+                       if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)\r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
                        {\r
                                ShowCommandError(ErrorCode, false);\r
                                \r
index 84dee71..690b1bb 100644 (file)
                        uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */\r
                        uint16_t Code; /**< Command, event or response code of the container */\r
                        uint32_t TransactionID; /**< Unique container ID to link blocks together */\r
                        uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */\r
                        uint16_t Code; /**< Command, event or response code of the container */\r
                        uint32_t TransactionID; /**< Unique container ID to link blocks together */\r
-                       uint32_t Params[4]; /**< Block parameters to be issued along with the block code (command blocks only) */\r
+                       uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only) */\r
                } SI_PIMA_Container_t;\r
                \r
        /* Disable C linkage for C++ Compilers: */\r
                } SI_PIMA_Container_t;\r
                \r
        /* Disable C linkage for C++ Compilers: */\r
index dcb1762..5905474 100644 (file)
                        uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
                        \r
                        /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function\r
                        uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
                        \r
                        /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function\r
-                        *  returns 0. The \ref CDC_Device_BytesReceived() function should be queried before data is recieved to ensure that no data\r
+                        *  returns 0. The \ref CDC_Device_BytesReceived() function should be queried before data is received to ensure that no data\r
                         *  underflow occurs.\r
                         *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state.\r
                         *  underflow occurs.\r
                         *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state.\r
index cb70808..68dddea 100644 (file)
@@ -131,7 +131,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint
                }\r
        }\r
 \r
                }\r
        }\r
 \r
-       CDCInterfaceInfo->State.Active = true;\r
+       CDCInterfaceInfo->State.IsActive = true;\r
        return CDC_ENUMERROR_NoError;\r
 }\r
 \r
        return CDC_ENUMERROR_NoError;\r
 }\r
 \r
@@ -196,7 +196,7 @@ static uint8_t DComp_CDC_Host_NextCDCInterfaceEndpoint(void* CurrentDescriptor)
 \r
 void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
 {\r
 \r
 void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
          return;\r
        \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber);       \r
          return;\r
        \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber);       \r
@@ -258,7 +258,7 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfa
 \r
 uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)\r
 {\r
 \r
 uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
          return;\r
 \r
        uint8_t ErrorCode;\r
          return;\r
 \r
        uint8_t ErrorCode;\r
@@ -273,10 +273,10 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Da
 \r
 uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)\r
 {\r
 \r
 uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
          return;\r
          \r
          return;\r
          \r
-       uint8_t ErrorCode = PIPE_READYWAIT_NoError;\r
+       uint8_t ErrorCode;\r
 \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
        Pipe_Unfreeze();\r
 \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
        Pipe_Unfreeze();\r
@@ -284,20 +284,22 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Da
        if (!(Pipe_IsReadWriteAllowed()))\r
        {\r
                Pipe_ClearOUT();\r
        if (!(Pipe_IsReadWriteAllowed()))\r
        {\r
                Pipe_ClearOUT();\r
-               ErrorCode = Pipe_WaitUntilReady();\r
+\r
+               if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+                 return ErrorCode;\r
        }\r
 \r
        Pipe_Write_Byte(Data);  \r
        Pipe_Freeze();\r
        \r
        }\r
 \r
        Pipe_Write_Byte(Data);  \r
        Pipe_Freeze();\r
        \r
-       return ErrorCode;\r
+       return PIPE_READYWAIT_NoError;\r
 }\r
 \r
 uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
 {\r
        uint16_t BytesInPipe = 0;\r
 \r
 }\r
 \r
 uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
 {\r
        uint16_t BytesInPipe = 0;\r
 \r
-       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
          return BytesInPipe;\r
        \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);     \r
          return BytesInPipe;\r
        \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);     \r
@@ -316,7 +318,7 @@ uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
 {\r
        uint8_t ReceivedByte = 0;\r
 \r
 {\r
        uint8_t ReceivedByte = 0;\r
 \r
-       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
          return ReceivedByte;\r
          \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);     \r
          return ReceivedByte;\r
          \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);     \r
index 99fbdbb..de4b6af 100644 (file)
                                           */\r
                                struct\r
                                {\r
                                           */\r
                                struct\r
                                {\r
-                                       bool Active; /**< Indicates if the current interface instance is connected to an attached device, valid\r
-                                                     *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
-                                                     *   Configured state\r
-                                                     */\r
+                                       bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+                                                       *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
+                                                       *   Configured state\r
+                                                       */\r
                                        uint8_t ControlInterfaceNumber; /**< Interface index of the CDC-ACM control interface within the attached device */\r
                                \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe */\r
                                        uint8_t ControlInterfaceNumber; /**< Interface index of the CDC-ACM control interface within the attached device */\r
                                \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe */\r
                        uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function\r
                        uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function\r
-                        *  returns 0. The \ref CDC_Host_BytesReceived() function should be queried before data is recieved to ensure that no data\r
+                        *  returns 0. The \ref CDC_Host_BytesReceived() function should be queried before data is received to ensure that no data\r
                         *  underflow occurs.\r
                         *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
                         *  underflow occurs.\r
                         *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
index f9c42b2..15106ce 100644 (file)
@@ -99,7 +99,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint
                }\r
        }\r
 \r
                }\r
        }\r
 \r
-       HIDInterfaceInfo->State.Active = true;\r
+       HIDInterfaceInfo->State.IsActive = true;\r
        return HID_ENUMERROR_NoError;\r
 }\r
 \r
        return HID_ENUMERROR_NoError;\r
 }\r
 \r
@@ -142,11 +142,11 @@ void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
 \r
 bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)\r
 {\r
 \r
 bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)\r
 {\r
-       bool ReportReceived;\r
-\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))\r
          return false;\r
 \r
          return false;\r
 \r
+       bool ReportReceived;\r
+\r
        Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);\r
        Pipe_Unfreeze();\r
        \r
        Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);\r
        Pipe_Unfreeze();\r
        \r
index 48cdcb0..dd4a753 100644 (file)
                                           */\r
                                struct\r
                                {\r
                                           */\r
                                struct\r
                                {\r
-                                       bool Active; /**< Indicates if the current interface instance is connected to an attached device, valid\r
-                                                     *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
-                                                     *   Configured state\r
-                                                     */\r
+                                       bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+                                                       *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
+                                                       *   Configured state\r
+                                                       */\r
                                        uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device */\r
 \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the HID interface's IN data pipe */\r
                                        uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device */\r
 \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the HID interface's IN data pipe */\r
index 678c070..a812fa9 100644 (file)
@@ -87,7 +87,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint16_
                }               \r
        }\r
 \r
                }               \r
        }\r
 \r
-       MSInterfaceInfo->State.Active = true;\r
+       MSInterfaceInfo->State.IsActive = true;\r
        return MS_ENUMERROR_NoError;\r
 }\r
 \r
        return MS_ENUMERROR_NoError;\r
 }\r
 \r
@@ -290,7 +290,7 @@ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInf
 \r
 uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)\r
 {\r
 \r
 uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
        USB_ControlRequest = (USB_Request_Header_t)\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
        USB_ControlRequest = (USB_Request_Header_t)\r
@@ -309,7 +309,7 @@ uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)
 \r
 uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* MaxLUNIndex)\r
 {\r
 \r
 uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* MaxLUNIndex)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
        uint8_t ErrorCode;\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
        uint8_t ErrorCode;\r
@@ -332,15 +332,15 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* Max
                *MaxLUNIndex = 0;\r
        }\r
        \r
                *MaxLUNIndex = 0;\r
        }\r
        \r
-       return ErrorCode;\r
+       return HOST_SENDCONTROL_SetupStalled;\r
 }\r
 \r
 uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, SCSI_Inquiry_Response_t* InquiryData)\r
 {\r
 }\r
 \r
 uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, SCSI_Inquiry_Response_t* InquiryData)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
          \r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
          \r
-       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+       uint8_t ErrorCode;\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
@@ -363,26 +363,20 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData)) != PIPE_RWSTREAM_NoError)\r
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;       \r
-       }\r
+         return ErrorCode;     \r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
 \r
-       return ErrorCode;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex)\r
 {\r
 }\r
 \r
 uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
-       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;      \r
+       uint8_t ErrorCode;      \r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
@@ -405,27 +399,21 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)\r
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;       \r
-       }\r
+         return ErrorCode;     \r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
 \r
-       return ErrorCode;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,\r
                                    SCSI_Capacity_t* DeviceCapacity)\r
 {\r
 }\r
 \r
 uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,\r
                                    SCSI_Capacity_t* DeviceCapacity)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
-       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+       uint8_t ErrorCode;\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
@@ -452,30 +440,24 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uin
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)\r
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
        DeviceCapacity->Blocks    = SwapEndian_32(DeviceCapacity->Blocks);\r
        DeviceCapacity->BlockSize = SwapEndian_32(DeviceCapacity->BlockSize);\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
 \r
        DeviceCapacity->Blocks    = SwapEndian_32(DeviceCapacity->Blocks);\r
        DeviceCapacity->BlockSize = SwapEndian_32(DeviceCapacity->BlockSize);\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
 \r
-       return ErrorCode;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,\r
                              SCSI_Request_Sense_Response_t* SenseData)\r
 {\r
 }\r
 \r
 uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,\r
                              SCSI_Request_Sense_Response_t* SenseData)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
-       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+       uint8_t ErrorCode;\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
@@ -498,26 +480,20 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t L
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData)) != PIPE_RWSTREAM_NoError)\r
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
 \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
 \r
-       return ErrorCode;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, bool PreventRemoval)\r
 {\r
 }\r
 \r
 uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, bool PreventRemoval)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
-       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+       uint8_t ErrorCode;\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
@@ -540,27 +516,21 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceIn
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)\r
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
 \r
-       return ErrorCode;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress,\r
                                  uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer)\r
 {\r
 }\r
 \r
 uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress,\r
                                  uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
-       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+       uint8_t ErrorCode;\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
@@ -587,27 +557,21 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
 \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
 \r
-       return ErrorCode;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress,\r
                                   uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer)\r
 {\r
 }\r
 \r
 uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress,\r
                                   uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer)\r
 {\r
-       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
 \r
-       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+       uint8_t ErrorCode;\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
 \r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
@@ -634,18 +598,12 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
        MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
        if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        \r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+         return ErrorCode;\r
 \r
 \r
-       return ErrorCode;\r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 #endif\r
 }\r
 \r
 #endif\r
index 9fc8851..ff2e901 100644 (file)
                                           */\r
                                struct\r
                                {\r
                                           */\r
                                struct\r
                                {\r
-                                       bool Active; /**< Indicates if the current interface instance is connected to an attached device, valid\r
-                                                     *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
-                                                     *   Configured state\r
-                                                     */\r
+                                       bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+                                                       *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
+                                                       *   Configured state\r
+                                                       */\r
                                        uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device */\r
 \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the MS interface's IN data pipe */\r
                                        uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device */\r
 \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the MS interface's IN data pipe */\r
index 40ef4f2..a3b1508 100644 (file)
@@ -99,6 +99,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_
                }\r
        }\r
 \r
                }\r
        }\r
 \r
+       SIInterfaceInfo->State.IsActive = true;\r
        return SI_ENUMERROR_NoError;\r
 }\r
 \r
        return SI_ENUMERROR_NoError;\r
 }\r
 \r
@@ -148,27 +149,39 @@ void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
 \r
 }\r
 \r
 \r
 }\r
 \r
-void SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)\r
+static uint8_t SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)\r
 {\r
 {\r
+       uint8_t ErrorCode;\r
+       \r
+       if (SIInterfaceInfo->State.IsSessionOpen)\r
+         PIMAHeader->TransactionID = SIInterfaceInfo->State.TransactionID++;\r
+       else\r
+         PIMAHeader->TransactionID = 0;\r
+\r
        Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);\r
        Pipe_Unfreeze();\r
 \r
        Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);\r
        Pipe_Unfreeze();\r
 \r
-       Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK);\r
+       if ((ErrorCode = Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)\r
+         return ErrorCode;\r
        \r
        if (PIMAHeader->Type == CType_CommandBlock)\r
        {\r
                uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));\r
 \r
                if (ParamBytes)\r
        \r
        if (PIMAHeader->Type == CType_CommandBlock)\r
        {\r
                uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));\r
 \r
                if (ParamBytes)\r
-                 Pipe_Write_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK);\r
-               \r
-               Pipe_ClearOUT();\r
+               {\r
+                       if ((ErrorCode = Pipe_Write_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)\r
+                         return ErrorCode;\r
+               }\r
        }\r
        }\r
-                                       \r
+       \r
+       Pipe_ClearOUT();        \r
        Pipe_Freeze();\r
        Pipe_Freeze();\r
+       \r
+       return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
 }\r
 \r
-uint8_t SImage_Host_RecieveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)\r
+static uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)\r
 {\r
        uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;\r
 \r
 {\r
        uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;\r
 \r
@@ -231,7 +244,7 @@ uint8_t SImage_Host_RecieveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo,
        return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
        return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
-uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)\r
+static uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)\r
 {\r
        uint8_t ErrorCode;\r
 \r
 {\r
        uint8_t ErrorCode;\r
 \r
@@ -246,7 +259,7 @@ uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buf
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
 \r
-uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)\r
+static uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)\r
 {\r
        uint8_t ErrorCode;\r
 \r
 {\r
        uint8_t ErrorCode;\r
 \r
@@ -260,7 +273,7 @@ uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buf
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
 \r
-bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)\r
+static bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)\r
 {\r
        bool IsEventReceived = false;\r
 \r
 {\r
        bool IsEventReceived = false;\r
 \r
@@ -275,7 +288,7 @@ bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
        return IsEventReceived;\r
 }\r
 \r
        return IsEventReceived;\r
 }\r
 \r
-uint8_t SImage_Host_RecieveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)\r
+static uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)\r
 {\r
        uint8_t ErrorCode;\r
 \r
 {\r
        uint8_t ErrorCode;\r
 \r
@@ -290,4 +303,58 @@ uint8_t SImage_Host_RecieveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo,
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
 \r
+uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)\r
+{\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+         return HOST_SENDCONTROL_DeviceDisconnect;\r
+\r
+       uint8_t ErrorCode;\r
+\r
+       SI_PIMA_Container_t PIMABlock = (SI_PIMA_Container_t)\r
+                                                       {\r
+                                                               .DataLength    = PIMA_COMMAND_SIZE(0),\r
+                                                               .Type          = CType_CommandBlock,\r
+                                                               .Code          = 0x1002,\r
+                                                               .Params        = {},\r
+                                                       };\r
+                                                       \r
+       SIInterfaceInfo->State.TransactionID = 1;\r
+       \r
+       if ((ErrorCode = SImage_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+         return ErrorCode;\r
+         \r
+       if ((ErrorCode = SImage_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+         return ErrorCode;\r
+         \r
+       SIInterfaceInfo->State.IsSessionOpen = true;\r
+\r
+       return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)\r
+{\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+         return HOST_SENDCONTROL_DeviceDisconnect;\r
+\r
+       uint8_t ErrorCode;\r
+\r
+       SI_PIMA_Container_t PIMABlock = (SI_PIMA_Container_t)\r
+                                                       {\r
+                                                               .DataLength    = PIMA_COMMAND_SIZE(0),\r
+                                                               .Type          = CType_CommandBlock,\r
+                                                               .Code          = 0x1003,\r
+                                                               .Params        = {},\r
+                                                       };\r
+                                                       \r
+       if ((ErrorCode = SImage_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+         return ErrorCode;\r
+         \r
+       if ((ErrorCode = SImage_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+         return ErrorCode;\r
+\r
+       SIInterfaceInfo->State.IsSessionOpen = false;\r
+\r
+       return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
 #endif\r
 #endif\r
index 4d37796..7e33fc4 100644 (file)
                                           */\r
                                struct\r
                                {\r
                                           */\r
                                struct\r
                                {\r
-                                       bool Active; /**< Indicates if the current interface instance is connected to an attached device, valid\r
-                                                     *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
-                                                     *   Configured state\r
-                                                     */\r
+                                       bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+                                                       *   after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
+                                                       *   Configured state\r
+                                                       */\r
 \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the Still Image interface's IN data pipe */\r
                                        uint16_t DataOUTPipeSize;  /**< Size in bytes of the Still Image interface's OUT data pipe */\r
                                        uint16_t EventsPipeSize;  /**< Size in bytes of the Still Image interface's IN events pipe */\r
 \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the Still Image interface's IN data pipe */\r
                                        uint16_t DataOUTPipeSize;  /**< Size in bytes of the Still Image interface's OUT data pipe */\r
                                        uint16_t EventsPipeSize;  /**< Size in bytes of the Still Image interface's IN events pipe */\r
+                                       \r
+                                       bool IsSessionOpen; /**< Indicates if a PIMA session is currently open with the attached device */\r
+                                       uint32_t TransactionID; /**< Transaction ID for the next transaction to send to the device */\r
                                } State; /**< State data for the USB class interface within the device. All elements in this section\r
                                                  *   <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
                                                  *   the interface is enumerated.\r
                                } State; /**< State data for the USB class interface within the device. All elements in this section\r
                                                  *   <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
                                                  *   the interface is enumerated.\r
                        uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t ConfigDescriptorLength,\r
                                            uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);\r
 \r
                        uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t ConfigDescriptorLength,\r
                                            uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);\r
 \r
-                       void SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader);\r
-                       uint8_t SImage_Host_RecieveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader);\r
-                       uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);\r
-                       uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);\r
-                       bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);\r
-                       uint8_t SImage_Host_RecieveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader);\r
-                                                         \r
+                       uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);\r
+                       uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);\r
+                       \r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
                /* Macros: */\r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
                /* Macros: */\r
                        #if defined(INCLUDE_FROM_SI_CLASS_HOST_C)\r
                                static uint8_t DComp_SI_Host_NextSIInterface(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);\r
                                static uint8_t DComp_SI_Host_NextSIInterfaceEndpoint(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);\r
                        #if defined(INCLUDE_FROM_SI_CLASS_HOST_C)\r
                                static uint8_t DComp_SI_Host_NextSIInterface(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);\r
                                static uint8_t DComp_SI_Host_NextSIInterfaceEndpoint(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+                               static uint8_t SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo,\r
+                                                                          SI_PIMA_Container_t* PIMAHeader);\r
+                               static uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo,\r
+                                                                             SI_PIMA_Container_t* PIMAHeader);\r
+                               static uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);\r
+                               static uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);\r
+                               static bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);\r
+                               static uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo,\r
+                                                                             SI_PIMA_Container_t* PIMAHeader);\r
                        #endif\r
        #endif\r
        \r
                        #endif\r
        #endif\r
        \r
index 652ee80..2fa20df 100644 (file)
@@ -33,7 +33,7 @@
  *\r
  *  Functions, macros and enums related to endpoint management when in USB Device mode. This\r
  *  module contains the endpoint management macros, as well as endpoint interrupt and data\r
  *\r
  *  Functions, macros and enums related to endpoint management when in USB Device mode. This\r
  *  module contains the endpoint management macros, as well as endpoint interrupt and data\r
- *  send/recieve functions for various data types.\r
+ *  send/receive functions for various data types.\r
  *\r
  *  @{\r
  */\r
  *\r
  *  @{\r
  */\r
index 1057ec8..2945458 100644 (file)
@@ -32,7 +32,7 @@
  *  @defgroup Group_PipeManagement Pipe Management\r
  *\r
  *  This module contains functions, macros and enums related to pipe management when in USB Host mode. This\r
  *  @defgroup Group_PipeManagement Pipe Management\r
  *\r
  *  This module contains functions, macros and enums related to pipe management when in USB Host mode. This\r
- *  module contains the pipe management macros, as well as pipe interrupt and data send/recieve functions\r
+ *  module contains the pipe management macros, as well as pipe interrupt and data send/receive functions\r
  *  for various data types.\r
  *\r
  *  @{\r
  *  for various data types.\r
  *\r
  *  @{\r
index 75ea016..60f00ed 100644 (file)
   *  - CDC demos now send empty packets after sending a full one to prevent buffering issues on the host\r
   *  - Updated demo descriptors to use VID/PID values donated by Atmel\r
   *  - Added DoxyGen documentation to the source files\r
   *  - CDC demos now send empty packets after sending a full one to prevent buffering issues on the host\r
   *  - Updated demo descriptors to use VID/PID values donated by Atmel\r
   *  - Added DoxyGen documentation to the source files\r
-  *  - Fixed Serial_IsCharRecieved() definition, was previously reversed\r
+  *  - Fixed Serial_IsCharReceived() definition, was previously reversed\r
   *  - Removed separate USB_Descriptor_Language_t descriptor, USB_Descriptor_String_t is used instead\r
   *  - Removed unused Device Qualifier descriptor structure\r
   *  - Renamed the USB_CreateEndpoints event to the more appropriate USB_ConfigurationChanged\r
   *  - Removed separate USB_Descriptor_Language_t descriptor, USB_Descriptor_String_t is used instead\r
   *  - Removed unused Device Qualifier descriptor structure\r
   *  - Renamed the USB_CreateEndpoints event to the more appropriate USB_ConfigurationChanged\r
index 8d39443..fe6523d 100644 (file)
@@ -13,7 +13,6 @@
   *\r
   *  <b>Targeted for This Release:</b>\r
   *  - Finish HID and Still Image Host Mode Class Drivers, add demo summaries\r
   *\r
   *  <b>Targeted for This Release:</b>\r
   *  - Finish HID and Still Image Host Mode Class Drivers, add demo summaries\r
-  *  - Add overviews of each of the officially supported boards to the manual\r
   *  - Re-add in flip, flip-ee, dfu and dfu-ee targets to project makefiles\r
   *  - Add in new invalid event hook check targets to project makefiles\r
   *  - Fix allowable F_CPU values comment in project makefiles\r
   *  - Re-add in flip, flip-ee, dfu and dfu-ee targets to project makefiles\r
   *  - Add in new invalid event hook check targets to project makefiles\r
   *  - Fix allowable F_CPU values comment in project makefiles\r
index a38c27b..c098e13 100644 (file)
  *      as it is neither a full nor a standards compliant implementation.\r
  *\r
  *  <b>Non-USB Library Components</b>\r
  *      as it is neither a full nor a standards compliant implementation.\r
  *\r
  *  <b>Non-USB Library Components</b>\r
- *    - The Serial_IsCharRecieved() macro has been changed to the correct spelling of Serial_IsCharReceived() in Serial.h.\r
+ *    - The Serial_IsCharReceived() macro has been changed to the correct spelling of Serial_IsCharReceived() in Serial.h.\r
  *\r
  *  <b>Device Mode</b>\r
  *    - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask\r
  *\r
  *  <b>Device Mode</b>\r
  *    - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask\r