Fix spelling of "Received" in all source files where it is misspelt "Recieved".
},\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
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
+ LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
break;\r
}\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
}\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
\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
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
\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
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
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
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
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
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
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
}\r
}\r
\r
- CDCInterfaceInfo->State.Active = true;\r
+ CDCInterfaceInfo->State.IsActive = true;\r
return CDC_ENUMERROR_NoError;\r
}\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
\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
\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
- uint8_t ErrorCode = PIPE_READYWAIT_NoError;\r
+ uint8_t ErrorCode;\r
\r
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); \r
Pipe_Unfreeze();\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
- 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
- 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
{\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
*/\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
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
}\r
}\r
\r
- HIDInterfaceInfo->State.Active = true;\r
+ HIDInterfaceInfo->State.IsActive = true;\r
return HID_ENUMERROR_NoError;\r
}\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
+ bool ReportReceived;\r
+\r
Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);\r
Pipe_Unfreeze();\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
} \r
}\r
\r
- MSInterfaceInfo->State.Active = true;\r
+ MSInterfaceInfo->State.IsActive = true;\r
return MS_ENUMERROR_NoError;\r
}\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
\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
*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
- 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 = PIPE_RWSTREAM_NoError;\r
+ uint8_t ErrorCode;\r
\r
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
{\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
- Pipe_Freeze();\r
- return ErrorCode;\r
- }\r
+ return ErrorCode;\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
- 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 = PIPE_RWSTREAM_NoError; \r
+ uint8_t ErrorCode; \r
\r
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
{\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
- Pipe_Freeze();\r
- return ErrorCode;\r
- }\r
+ return ErrorCode;\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
- 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 = PIPE_RWSTREAM_NoError;\r
+ uint8_t ErrorCode;\r
\r
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
{\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
- Pipe_Freeze();\r
- return ErrorCode;\r
- }\r
+ return ErrorCode;\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
- 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 = PIPE_RWSTREAM_NoError;\r
+ uint8_t ErrorCode;\r
\r
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
{\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
- Pipe_Freeze();\r
- return ErrorCode;\r
- }\r
+ return ErrorCode;\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
- 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 = PIPE_RWSTREAM_NoError;\r
+ uint8_t ErrorCode;\r
\r
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
{\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
- Pipe_Freeze();\r
- return ErrorCode;\r
- }\r
+ return ErrorCode;\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
- 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 = PIPE_RWSTREAM_NoError;\r
+ uint8_t ErrorCode;\r
\r
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
{\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
- Pipe_Freeze();\r
- return ErrorCode;\r
- }\r
+ return ErrorCode;\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
- 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 = PIPE_RWSTREAM_NoError;\r
+ uint8_t ErrorCode;\r
\r
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
{\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
- Pipe_Freeze();\r
- return ErrorCode;\r
- }\r
+ return ErrorCode;\r
\r
- return ErrorCode;\r
+ return PIPE_RWSTREAM_NoError;\r
}\r
\r
#endif\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
}\r
}\r
\r
+ SIInterfaceInfo->State.IsActive = true;\r
return SI_ENUMERROR_NoError;\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
+ 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_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
- 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
+ Pipe_ClearOUT(); \r
Pipe_Freeze();\r
+ \r
+ return PIPE_RWSTREAM_NoError;\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
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
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
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
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
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
*/\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
+ 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
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
#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
*\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
* @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
* - 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
*\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
* 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