aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Host
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
commitf896c00c48f04fb9273555ab8d9b1af99f865d25 (patch)
treeb76827a0467c77ddeb30e11748c02a4f53779a14 /LUFA/Drivers/USB/Class/Host
parente338cb6f329d6bf948abad88637f81436ee90daf (diff)
downloadlufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.gz
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.bz2
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.zip
Break device mode class driver interfaces into seperate config and state structs which are then combined, for clarity. Move device mode class driver interfaces back into the device mode class driver headers from the common class headers to make room for host class interfaces.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Host')
-rw-r--r--LUFA/Drivers/USB/Class/Host/CDC.c38
-rw-r--r--LUFA/Drivers/USB/Class/Host/CDC.h19
2 files changed, 28 insertions, 29 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c
index 32cc9e6eb..6eca8ae67 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.c
+++ b/LUFA/Drivers/USB/Class/Host/CDC.c
@@ -41,22 +41,22 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
uint8_t FoundEndpoints = 0;
if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
- return ControlError;
+ return CDC_ENUMERROR_ControlError;
if (ConfigDescriptorSize > 512)
- return DescriptorTooLarge;
+ return CDC_ENUMERROR_DescriptorTooLarge;
ConfigDescriptorData = alloca(ConfigDescriptorSize);
USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, ConfigDescriptorData);
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
- return InvalidConfigDataReturned;
+ return CDC_ENUMERROR_InvalidConfigDataReturned;
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DComp_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
- return NoCDCInterfaceFound;
+ return CDC_ENUMERROR_NoCDCInterfaceFound;
}
while (FoundEndpoints != ((1 << CDC_NOTIFICATIONPIPE) | (1 << CDC_DATAPIPE_IN) | (1 << CDC_DATAPIPE_OUT)))
@@ -72,7 +72,7 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
DComp_CDC_Host_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
/* Descriptor not found, error out */
- return NoCDCInterfaceFound;
+ return CDC_ENUMERROR_NoCDCInterfaceFound;
}
}
else
@@ -89,14 +89,14 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DComp_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
- return NoCDCInterfaceFound;
+ return CDC_ENUMERROR_NoCDCInterfaceFound;
}
}
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DComp_CDC_Host_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{
- return NoEndpointFound;
+ return CDC_ENUMERROR_NoEndpointFound;
}
}
@@ -139,7 +139,7 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
}
}
- return SuccessfulConfigRead;
+ return CDC_ENUMERROR_NoError;
}
static uint8_t DComp_CDC_Host_NextCDCControlInterface(void* CurrentDescriptor)
@@ -192,25 +192,19 @@ static uint8_t DComp_CDC_Host_NextInterfaceCDCDataEndpoint(void* CurrentDescript
return DESCRIPTOR_SEARCH_NotFound;
}
-void CDC_Host_Task(void)
+void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
{
uint8_t ErrorCode;
switch (USB_HostState)
{
case HOST_STATE_Addressed:
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_SetConfiguration,
- .wValue = 1,
- .wIndex = 0,
- .wLength = 0,
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
+ if ((ErrorCode = CDC_Host_ProcessConfigDescriptor()) != SuccessfulConfigRead)
+ {
+ USB_HostState = HOST_STATE_Unattached;
+ }
- if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
+ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
{
USB_HostState = HOST_STATE_Unattached;
}
@@ -218,10 +212,6 @@ void CDC_Host_Task(void)
USB_HostState = HOST_STATE_Configured;
break;
case HOST_STATE_Configured:
- if ((ErrorCode = CDC_Host_ProcessConfigDescriptor()) != SuccessfulConfigRead)
- {
- USB_HostState = HOST_STATE_Unattached;
- }
USB_HostState = HOST_STATE_Ready;
break;
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.h b/LUFA/Drivers/USB/Class/Host/CDC.h
index 3bc814daf..e39333ee8 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.h
+++ b/LUFA/Drivers/USB/Class/Host/CDC.h
@@ -53,8 +53,6 @@
/* Type Defines: */
typedef struct
{
- bool IsActive; /**< Indicates if this class driver is currently attached to the device */
-
uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */
uint8_t DataINPipeNumber; /**< Pipe number of the CDC interface's IN data pipe */
@@ -63,8 +61,8 @@
uint8_t DataOUTPipeNumber; /**< Pipe number of the CDC interface's OUT data pipe */
uint16_t DataOUTPipeSize; /**< Size in bytes of the CDC interface's OUT data pipe */
- uint8_t NotificationEndpointNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used */
- uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
+ uint8_t NotificationPipeNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used */
+ uint16_t NotificationPipeSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
uint8_t ControlLineState; /**< Current control line states */
@@ -80,9 +78,20 @@
uint8_t DataBits; /**< Bits of data per character of the virtual serial port */
} LineEncoding;
} USB_ClassInfo_CDC_Host_t;
+
+ /* Enums: */
+ typedef enum
+ {
+ CDC_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully */
+ CDC_ENUMERROR_ControlError = 1, /**< A control request to the device failed to complete successfully */
+ CDC_ENUMERROR_DescriptorTooLarge = 2, /**< The device's Configuration Descriptor is too large to process */
+ CDC_ENUMERROR_InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */
+ CDC_ENUMERROR_NoCDCInterfaceFound = 4, /**< A compatible CDC interface was not found in the device's Configuration Descriptor */
+ CDC_ENUMERROR_NoEndpointFound = 5, /**< Compatible CDC endpoints were not found in the device's CDC interface */
+ } CDCHost_EnumerationFailure_ErrorCodes_t;
/* Function Prototypes: */
- void CDC_Host_Task(void);
+ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)