Commit 6783bc45 authored by Dean Camera's avatar Dean Camera
Browse files

Add StillImage Host Class Driver functions for opening and closing sessions....

Add StillImage Host Class Driver functions for opening and closing sessions. Ensure IsActive is set on the interface to allow device functions to run.

Fix spelling of "Received" in all source files where it is misspelt "Recieved".
parent 205b35d1
......@@ -50,7 +50,6 @@ USB_ClassInfo_SI_Host_t DigitalCamera_SI_Interface =
},
};
/** Main program entry point. This routine configures the hardware required by the application, then
* starts the scheduler to run the application tasks.
*/
......@@ -102,7 +101,28 @@ int main(void)
USB_HostState = HOST_STATE_Configured;
break;
case HOST_STATE_Configured:
printf("Opening Session...\r\n");
if (SImage_Host_OpenSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError)
{
printf("Could not open PIMA session.\r\n");
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
printf("Closing Session...\r\n");
if (SImage_Host_CloseSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError)
{
printf("Could not close PIMA session.\r\n");
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
printf("Device Idle.\r\n");
LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
......
......@@ -30,7 +30,7 @@
/** \file
*
* Printer Device commands, to send/recieve data to and from an attached USB
* Printer Device commands, to send/receive data to and from an attached USB
* printer, and to send and receive Printer Class control requests.
*/
......
......@@ -80,7 +80,7 @@ void SImage_SendBlockHeader(void)
}
/** Function to receive a PIMA event container from the attached still image device. */
uint8_t SImage_RecieveEventHeader(void)
uint8_t SImage_ReceiveEventHeader(void)
{
uint8_t ErrorCode;
......@@ -101,7 +101,7 @@ uint8_t SImage_RecieveEventHeader(void)
}
/** Function to receive a PIMA response container from the attached still image device. */
uint8_t SImage_RecieveBlockHeader(void)
uint8_t SImage_ReceiveBlockHeader(void)
{
uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
......
......@@ -85,7 +85,7 @@
uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */
uint16_t Code; /**< Command, event or response code of the container */
uint32_t TransactionID; /**< Unique container ID to link blocks together */
uint32_t Params[4]; /**< Block parameters to be issued along with the block code (command blocks only) */
uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only) */
} PIMA_Container_t;
/* Enums: */
......@@ -106,8 +106,8 @@
/* Function Prototypes: */
void SImage_SendBlockHeader(void);
uint8_t SImage_RecieveBlockHeader(void);
uint8_t SImage_RecieveEventHeader(void);
uint8_t SImage_ReceiveBlockHeader(void);
uint8_t SImage_ReceiveEventHeader(void);
uint8_t SImage_SendData(void* Buffer, uint16_t Bytes);
uint8_t SImage_ReadData(void* Buffer, uint16_t Bytes);
bool SImage_IsEventReceived(void);
......
......@@ -189,7 +189,7 @@ void StillImage_Task(void)
SImage_SendBlockHeader();
/* Receive the response data block */
if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)
if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)
{
ShowCommandError(ErrorCode, false);
......@@ -242,7 +242,7 @@ void StillImage_Task(void)
printf_P(PSTR(" Device Version: %s\r\n"), DeviceVersion);
/* Receive the final response block from the device */
if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)
if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)
{
ShowCommandError(ErrorCode, false);
......@@ -274,7 +274,7 @@ void StillImage_Task(void)
SImage_SendBlockHeader();
/* Receive the response block from the device */
if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)
if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)
{
ShowCommandError(ErrorCode, false);
......@@ -306,7 +306,7 @@ void StillImage_Task(void)
SImage_SendBlockHeader();
/* Receive the response block from the device */
if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError)
if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError)
{
ShowCommandError(ErrorCode, false);
......
......@@ -117,7 +117,7 @@
uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */
uint16_t Code; /**< Command, event or response code of the container */
uint32_t TransactionID; /**< Unique container ID to link blocks together */
uint32_t Params[4]; /**< Block parameters to be issued along with the block code (command blocks only) */
uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only) */
} SI_PIMA_Container_t;
/* Disable C linkage for C++ Compilers: */
......
......@@ -180,7 +180,7 @@
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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
* returns 0. The \ref CDC_Device_BytesReceived() function should be queried before data is recieved to ensure that no data
* returns 0. The \ref CDC_Device_BytesReceived() function should be queried before data is received to ensure that no data
* underflow occurs.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
......
......@@ -131,7 +131,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint
}
}
CDCInterfaceInfo->State.Active = true;
CDCInterfaceInfo->State.IsActive = true;
return CDC_ENUMERROR_NoError;
}
......@@ -196,7 +196,7 @@ static uint8_t DComp_CDC_Host_NextCDCInterfaceEndpoint(void* CurrentDescriptor)
void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return;
Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber);
......@@ -258,7 +258,7 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfa
uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return;
uint8_t ErrorCode;
......@@ -273,10 +273,10 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Da
uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return;
uint8_t ErrorCode = PIPE_READYWAIT_NoError;
uint8_t ErrorCode;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
......@@ -284,20 +284,22 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Da
if (!(Pipe_IsReadWriteAllowed()))
{
Pipe_ClearOUT();
ErrorCode = Pipe_WaitUntilReady();
if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)
return ErrorCode;
}
Pipe_Write_Byte(Data);
Pipe_Freeze();
return ErrorCode;
return PIPE_READYWAIT_NoError;
}
uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
uint16_t BytesInPipe = 0;
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return BytesInPipe;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
......@@ -316,7 +318,7 @@ uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
uint8_t ReceivedByte = 0;
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return ReceivedByte;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
......
......@@ -71,10 +71,10 @@
*/
struct
{
bool Active; /**< Indicates if the current interface instance is connected to an attached device, valid
* after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
* Configured state
*/
bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid
* after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
* Configured state
*/
uint8_t ControlInterfaceNumber; /**< Interface index of the CDC-ACM control interface within the attached device */
uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe */
......@@ -187,7 +187,7 @@
uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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
* returns 0. The \ref CDC_Host_BytesReceived() function should be queried before data is recieved to ensure that no data
* returns 0. The \ref CDC_Host_BytesReceived() function should be queried before data is received to ensure that no data
* underflow occurs.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state
......
......@@ -99,7 +99,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint
}
}
HIDInterfaceInfo->State.Active = true;
HIDInterfaceInfo->State.IsActive = true;
return HID_ENUMERROR_NoError;
}
......@@ -142,11 +142,11 @@ void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
{
bool ReportReceived;
if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))
return false;
bool ReportReceived;
Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
......
......@@ -76,10 +76,10 @@
*/
struct
{
bool Active; /**< Indicates if the current interface instance is connected to an attached device, valid
* after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
* Configured state
*/
bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid
* after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
* Configured state
*/
uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device */
uint16_t DataINPipeSize; /**< Size in bytes of the HID interface's IN data pipe */
......
......@@ -87,7 +87,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint16_
}
}
MSInterfaceInfo->State.Active = true;
MSInterfaceInfo->State.IsActive = true;
return MS_ENUMERROR_NoError;
}
......@@ -290,7 +290,7 @@ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInf
uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
USB_ControlRequest = (USB_Request_Header_t)
......@@ -309,7 +309,7 @@ uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)
uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* MaxLUNIndex)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode;
......@@ -332,15 +332,15 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* Max
*MaxLUNIndex = 0;
}
return ErrorCode;
return HOST_SENDCONTROL_SetupStalled;
}
uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, SCSI_Inquiry_Response_t* InquiryData)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
......@@ -363,26 +363,20 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
return ErrorCode;
return PIPE_RWSTREAM_NoError;
}
uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
......@@ -405,27 +399,21 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
return ErrorCode;
return PIPE_RWSTREAM_NoError;
}
uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,
SCSI_Capacity_t* DeviceCapacity)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
......@@ -452,30 +440,24 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uin
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
DeviceCapacity->Blocks = SwapEndian_32(DeviceCapacity->Blocks);
DeviceCapacity->BlockSize = SwapEndian_32(DeviceCapacity->BlockSize);
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
return ErrorCode;
return PIPE_RWSTREAM_NoError;
}
uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,
SCSI_Request_Sense_Response_t* SenseData)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
......@@ -498,26 +480,20 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t L
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
return ErrorCode;
return PIPE_RWSTREAM_NoError;
}
uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, bool PreventRemoval)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
......@@ -540,27 +516,21 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceIn
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
return ErrorCode;
return PIPE_RWSTREAM_NoError;
}
uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress,
uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
......@@ -587,27 +557,21 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
return ErrorCode;
return PIPE_RWSTREAM_NoError;
}
uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress,
uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnect;
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
......@@ -634,18 +598,12 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
return ErrorCode;
return PIPE_RWSTREAM_NoError;
}
#endif
......@@ -73,10 +73,10 @@
*/
struct
{
bool Active; /**< Indicates if the current interface instance is connected to an attached device, valid
* after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
* Configured state
*/
bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid
* after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
* Configured state
*/
uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device */
uint16_t DataINPipeSize; /**< Size in bytes of the MS interface's IN data pipe */
......
......@@ -99,6 +99,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_
}
}
SIInterfaceInfo->State.IsActive = true;
return SI_ENUMERROR_NoError;
}
......@@ -148,27 +149,39 @@ void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
}
void SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)
static uint8_t SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)
{
uint8_t ErrorCode;
if (SIInterfaceInfo->State.IsSessionOpen)
PIMAHeader->TransactionID = SIInterfaceInfo->State.TransactionID++;
else
PIMAHeader->TransactionID = 0;
Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK);
if ((ErrorCode = Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
if (PIMAHeader->Type == CType_CommandBlock)
{
uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));
if (ParamBytes)
Pipe_Write_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK);
Pipe_ClearOUT();
{
if ((ErrorCode = Pipe_Write_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
}
}
Pipe_ClearOUT();
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
uint8_t SImage_Host_RecieveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)
static uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)
{