aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Host/StillImage.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-11-26 04:46:31 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-11-26 04:46:31 +0000
commit5aa2b26261389cfbdfae8e793be4b8150ddc7a0a (patch)
tree98cd416fe1b9407956892a22e5b01b3018ccbb09 /LUFA/Drivers/USB/Class/Host/StillImage.c
parentf37d21bbe961a72e4d6527767aacf843e3af412c (diff)
downloadlufa-5aa2b26261389cfbdfae8e793be4b8150ddc7a0a.tar.gz
lufa-5aa2b26261389cfbdfae8e793be4b8150ddc7a0a.tar.bz2
lufa-5aa2b26261389cfbdfae8e793be4b8150ddc7a0a.zip
Added new RNDIS Host class driver and the beginnings of a RNDISEthernetHost Class Driver demo.
Fixed all Class drivers to ensure they have appropriate guards on each function to ensure the device is enumerated before running, fixed error codes on all guards to return "DeviceDisconnected" where possble. Renamed HOST_SENDCONTROL_DeviceDisconnect enum value to HOST_SENDCONTROL_DeviceDisconnected to be in line with the rest of the library enum error codes.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Host/StillImage.c')
-rw-r--r--LUFA/Drivers/USB/Class/Host/StillImage.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.c b/LUFA/Drivers/USB/Class/Host/StillImage.c
index fe14084a9..5a958cf44 100644
--- a/LUFA/Drivers/USB/Class/Host/StillImage.c
+++ b/LUFA/Drivers/USB/Class/Host/StillImage.c
@@ -151,6 +151,9 @@ static uint8_t SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInte
{
uint8_t ErrorCode;
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return PIPE_RWSTREAM_DeviceDisconnected;
+
PIMAHeader->TransactionID = SIInterfaceInfo->State.TransactionID++;
Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);
@@ -177,6 +180,9 @@ static uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SII
{
uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return PIPE_RWSTREAM_DeviceDisconnected;
+
Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
@@ -240,6 +246,9 @@ uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, voi
{
uint8_t ErrorCode;
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return PIPE_RWSTREAM_DeviceDisconnected;
+
Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
@@ -255,6 +264,9 @@ uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, voi
{
uint8_t ErrorCode;
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return PIPE_RWSTREAM_DeviceDisconnected;
+
Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
@@ -269,6 +281,9 @@ bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo)
{
bool IsEventReceived = false;
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return false;
+
Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber);
Pipe_Unfreeze();
@@ -284,6 +299,9 @@ uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfac
{
uint8_t ErrorCode;
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return PIPE_RWSTREAM_DeviceDisconnected;
+
Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber);
Pipe_Unfreeze();
@@ -298,7 +316,7 @@ uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfac
uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
- return HOST_SENDCONTROL_DeviceDisconnect;
+ return HOST_SENDCONTROL_DeviceDisconnected;
uint8_t ErrorCode;
@@ -328,7 +346,7 @@ uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
- return HOST_SENDCONTROL_DeviceDisconnect;
+ return HOST_SENDCONTROL_DeviceDisconnected;
uint8_t ErrorCode;
@@ -358,7 +376,7 @@ uint8_t SImage_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
const uint8_t TotalParams, uint32_t* Params)
{
if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
- return HOST_SENDCONTROL_DeviceDisconnect;
+ return HOST_SENDCONTROL_DeviceDisconnected;
uint8_t ErrorCode;
@@ -382,6 +400,9 @@ uint8_t SImage_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceIn
uint8_t ErrorCode;
SI_PIMA_Container_t PIMABlock;
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
+ return HOST_SENDCONTROL_DeviceDisconnected;
+
if ((ErrorCode = SImage_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode;