diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2009-09-02 13:08:55 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2009-09-02 13:08:55 +0000 |
| commit | 937b511595000c05cf45a8dd8f169017fdbe34f9 (patch) | |
| tree | 192e7b44b6e0ff87d1cd5108c2d2b4d318e90eb7 /LUFA/Drivers | |
| parent | c9829403f321e7f9dba2f9024e80d8db94164254 (diff) | |
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".
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@809 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'LUFA/Drivers')
| -rw-r--r-- | LUFA/Drivers/USB/Class/Common/StillImage.h | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.h | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/CDC.c | 20 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/CDC.h | 10 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/HID.c | 8 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/HID.h | 8 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.c | 120 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.h | 8 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/StillImage.c | 89 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/StillImage.h | 31 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.h | 2 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.h | 2 |
12 files changed, 169 insertions, 133 deletions
diff --git a/LUFA/Drivers/USB/Class/Common/StillImage.h b/LUFA/Drivers/USB/Class/Common/StillImage.h index 84dee715..690b1bb1 100644 --- a/LUFA/Drivers/USB/Class/Common/StillImage.h +++ b/LUFA/Drivers/USB/Class/Common/StillImage.h @@ -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: */
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index dcb1762b..5905474c 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -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.
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c index cb70808a..68dddeac 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.c +++ b/LUFA/Drivers/USB/Class/Host/CDC.c @@ -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);
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.h b/LUFA/Drivers/USB/Class/Host/CDC.h index 99fbdbbd..de4b6afd 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.h +++ b/LUFA/Drivers/USB/Class/Host/CDC.h @@ -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
diff --git a/LUFA/Drivers/USB/Class/Host/HID.c b/LUFA/Drivers/USB/Class/Host/HID.c index f9c42b28..15106cee 100644 --- a/LUFA/Drivers/USB/Class/Host/HID.c +++ b/LUFA/Drivers/USB/Class/Host/HID.c @@ -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();
diff --git a/LUFA/Drivers/USB/Class/Host/HID.h b/LUFA/Drivers/USB/Class/Host/HID.h index 48cdcb03..dd4a7537 100644 --- a/LUFA/Drivers/USB/Class/Host/HID.h +++ b/LUFA/Drivers/USB/Class/Host/HID.h @@ -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 */
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c index 678c070c..a812fa97 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c @@ -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
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h index 9fc8851b..ff2e9019 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h @@ -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 */
diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.c b/LUFA/Drivers/USB/Class/Host/StillImage.c index 40ef4f23..a3b15084 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImage.c +++ b/LUFA/Drivers/USB/Class/Host/StillImage.c @@ -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)
{
uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
@@ -231,7 +244,7 @@ uint8_t SImage_Host_RecieveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, return PIPE_RWSTREAM_NoError;
}
-uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)
+static uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)
{
uint8_t ErrorCode;
@@ -246,7 +259,7 @@ uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buf return ErrorCode;
}
-uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)
+static uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes)
{
uint8_t ErrorCode;
@@ -260,7 +273,7 @@ uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buf return ErrorCode;
}
-bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
+static bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
{
bool IsEventReceived = false;
@@ -275,7 +288,7 @@ bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) return IsEventReceived;
}
-uint8_t SImage_Host_RecieveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)
+static uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader)
{
uint8_t ErrorCode;
@@ -290,4 +303,58 @@ uint8_t SImage_Host_RecieveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, return ErrorCode;
}
+uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
+{
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return HOST_SENDCONTROL_DeviceDisconnect;
+
+ uint8_t ErrorCode;
+
+ SI_PIMA_Container_t PIMABlock = (SI_PIMA_Container_t)
+ {
+ .DataLength = PIMA_COMMAND_SIZE(0),
+ .Type = CType_CommandBlock,
+ .Code = 0x1002,
+ .Params = {},
+ };
+
+ SIInterfaceInfo->State.TransactionID = 1;
+
+ if ((ErrorCode = SImage_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
+ return ErrorCode;
+
+ if ((ErrorCode = SImage_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
+ return ErrorCode;
+
+ SIInterfaceInfo->State.IsSessionOpen = true;
+
+ return PIPE_RWSTREAM_NoError;
+}
+
+uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
+{
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return HOST_SENDCONTROL_DeviceDisconnect;
+
+ uint8_t ErrorCode;
+
+ SI_PIMA_Container_t PIMABlock = (SI_PIMA_Container_t)
+ {
+ .DataLength = PIMA_COMMAND_SIZE(0),
+ .Type = CType_CommandBlock,
+ .Code = 0x1003,
+ .Params = {},
+ };
+
+ if ((ErrorCode = SImage_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
+ return ErrorCode;
+
+ if ((ErrorCode = SImage_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
+ return ErrorCode;
+
+ SIInterfaceInfo->State.IsSessionOpen = false;
+
+ return PIPE_RWSTREAM_NoError;
+}
+
#endif
diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.h b/LUFA/Drivers/USB/Class/Host/StillImage.h index 4d377960..7e33fc4b 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImage.h +++ b/LUFA/Drivers/USB/Class/Host/StillImage.h @@ -67,14 +67,17 @@ */
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
+ */
uint16_t DataINPipeSize; /**< Size in bytes of the Still Image interface's IN data pipe */
uint16_t DataOUTPipeSize; /**< Size in bytes of the Still Image interface's OUT data pipe */
uint16_t EventsPipeSize; /**< Size in bytes of the Still Image interface's IN events pipe */
+
+ bool IsSessionOpen; /**< Indicates if a PIMA session is currently open with the attached device */
+ uint32_t TransactionID; /**< Transaction ID for the next transaction to send to the device */
} State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when
* the interface is enumerated.
@@ -120,13 +123,9 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t ConfigDescriptorLength,
uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
- void SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader);
- uint8_t SImage_Host_RecieveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader);
- uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);
- uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);
- bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
- uint8_t SImage_Host_RecieveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader);
-
+ uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
+ uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
+
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
@@ -144,6 +143,16 @@ #if defined(INCLUDE_FROM_SI_CLASS_HOST_C)
static uint8_t DComp_SI_Host_NextSIInterface(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DComp_SI_Host_NextSIInterfaceEndpoint(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
+
+ static uint8_t SImage_Host_SendBlockHeader(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);
+ static uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);
+ static uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes);
+ static bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo);
+ static uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo,
+ SI_PIMA_Container_t* PIMAHeader);
#endif
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 652ee804..2fa20dfe 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -33,7 +33,7 @@ *
* Functions, macros and enums related to endpoint management when in USB Device mode. This
* module contains the endpoint management macros, as well as endpoint interrupt and data
- * send/recieve functions for various data types.
+ * send/receive functions for various data types.
*
* @{
*/
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index 1057ec8b..29454580 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -32,7 +32,7 @@ * @defgroup Group_PipeManagement Pipe Management
*
* This module contains functions, macros and enums related to pipe management when in USB Host mode. This
- * module contains the pipe management macros, as well as pipe interrupt and data send/recieve functions
+ * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions
* for various data types.
*
* @{
|
