Add descriptor class, subclass and protocol constants to the class drivers, modify all demos to use them where possible.

Move out private/internal host class driver constants to the common class driver headers, so that they can be used in the Low Level host mode demos.

Ensure all demos, projects and bootloaders use the class driver constants where possible to minimise code repetition.
This commit is contained in:
Dean Camera 2010-10-25 12:42:55 +00:00
parent b37d77eab3
commit 55538dcef3
96 changed files with 650 additions and 631 deletions

View file

@ -142,9 +142,9 @@ static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescrip
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == CDC_CONTROL_CLASS) &&
(CurrentInterface->SubClass == CDC_CONTROL_SUBCLASS) &&
(CurrentInterface->Protocol == CDC_CONTROL_PROTOCOL))
if ((CurrentInterface->Class == CDC_CSCP_CDCClass) &&
(CurrentInterface->SubClass == CDC_CSCP_ACMSubclass) &&
(CurrentInterface->Protocol == CDC_CSCP_ATCommandProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}
@ -160,9 +160,9 @@ static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == CDC_DATA_CLASS) &&
(CurrentInterface->SubClass == CDC_DATA_SUBCLASS) &&
(CurrentInterface->Protocol == CDC_DATA_PROTOCOL))
if ((CurrentInterface->Class == CDC_CSCP_CDCDataClass) &&
(CurrentInterface->SubClass == CDC_CSCP_NoDataSubclass) &&
(CurrentInterface->Protocol == CDC_CSCP_NoDataProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}

View file

@ -306,14 +306,6 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define CDC_CONTROL_CLASS 0x02
#define CDC_CONTROL_SUBCLASS 0x02
#define CDC_CONTROL_PROTOCOL 0x01
#define CDC_DATA_CLASS 0x0A
#define CDC_DATA_SUBCLASS 0x00
#define CDC_DATA_PROTOCOL 0x00
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_CDC_HOST_C)
static int CDC_Host_putchar(char c,

View file

@ -118,7 +118,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;
HIDInterfaceInfo->State.HIDReportSize = HIDDescriptor->HIDReportLength;
HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_BOOTP_NonBootProtocol);
HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol);
HIDInterfaceInfo->State.LargestReportSize = 8;
HIDInterfaceInfo->State.IsActive = true;
@ -132,7 +132,7 @@ static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if (CurrentInterface->Class == HID_INTERFACE_CLASS)
if (CurrentInterface->Class == HID_CSCP_HIDClass)
return DESCRIPTOR_SEARCH_Found;
}

View file

@ -297,9 +297,6 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define HID_INTERFACE_CLASS 0x03
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_HID_HOST_C)
static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);

View file

@ -110,9 +110,9 @@ static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDes
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == MIDI_STREAMING_CLASS) &&
(CurrentInterface->SubClass == MIDI_STREAMING_SUBCLASS) &&
(CurrentInterface->Protocol == MIDI_STREAMING_PROTOCOL))
if ((CurrentInterface->Class == AUDIO_CSCP_AudioClass) &&
(CurrentInterface->SubClass == AUDIO_CSCP_MIDIStreamingSubclass) &&
(CurrentInterface->Protocol == AUDIO_CSCP_StreamingProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}

View file

@ -188,11 +188,6 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define MIDI_STREAMING_CLASS 0x01
#define MIDI_STREAMING_SUBCLASS 0x03
#define MIDI_STREAMING_PROTOCOL 0x00
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_MIDI_HOST_C)
static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);

View file

@ -110,9 +110,9 @@ static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == MASS_STORE_CLASS) &&
(CurrentInterface->SubClass == MASS_STORE_SUBCLASS) &&
(CurrentInterface->Protocol == MASS_STORE_PROTOCOL))
if ((CurrentInterface->Class == MS_CSCP_MassStorageClass) &&
(CurrentInterface->SubClass == MS_CSCP_SCSITransparentSubclass) &&
(CurrentInterface->Protocol == MS_CSCP_BulkOnlyTransportProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}
@ -150,7 +150,7 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
{
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
SCSICommandBlock->Signature = CBW_SIGNATURE;
SCSICommandBlock->Signature = MS_CBW_SIGNATURE;
SCSICommandBlock->Tag = ++MSInterfaceInfo->State.TransactionTag;
if (MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF)
@ -180,7 +180,7 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)
{
uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
uint16_t TimeoutMSRem = MS_COMMAND_DATA_TIMEOUT_MS;
uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
@ -240,7 +240,7 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfac
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint16_t BytesRem = SCSICommandBlock->DataTransferLength;
if (SCSICommandBlock->Flags & COMMAND_DIRECTION_DATA_IN)
if (SCSICommandBlock->Flags & MS_COMMAND_DIR_DATA_IN)
{
if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)
{
@ -357,7 +357,7 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
.DataTransferLength = sizeof(SCSI_Inquiry_Response_t),
.Flags = COMMAND_DIRECTION_DATA_IN,
.Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex,
.SCSICommandLength = 6,
.SCSICommandData =
@ -393,7 +393,7 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
.DataTransferLength = 0,
.Flags = COMMAND_DIRECTION_DATA_IN,
.Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex,
.SCSICommandLength = 6,
.SCSICommandData =
@ -430,7 +430,7 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
.DataTransferLength = sizeof(SCSI_Capacity_t),
.Flags = COMMAND_DIRECTION_DATA_IN,
.Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex,
.SCSICommandLength = 10,
.SCSICommandData =
@ -474,7 +474,7 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
.DataTransferLength = sizeof(SCSI_Request_Sense_Response_t),
.Flags = COMMAND_DIRECTION_DATA_IN,
.Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex,
.SCSICommandLength = 6,
.SCSICommandData =
@ -511,7 +511,7 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInter
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
.DataTransferLength = 0,
.Flags = COMMAND_DIRECTION_DATA_OUT,
.Flags = MS_COMMAND_DIR_DATA_OUT,
.LUN = LUNIndex,
.SCSICommandLength = 6,
.SCSICommandData =
@ -551,7 +551,7 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
.DataTransferLength = ((uint32_t)Blocks * BlockSize),
.Flags = COMMAND_DIRECTION_DATA_IN,
.Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex,
.SCSICommandLength = 10,
.SCSICommandData =
@ -595,7 +595,7 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{
.DataTransferLength = ((uint32_t)Blocks * BlockSize),
.Flags = COMMAND_DIRECTION_DATA_OUT,
.Flags = MS_COMMAND_DIR_DATA_OUT,
.LUN = LUNIndex,
.SCSICommandLength = 10,
.SCSICommandData =

View file

@ -313,17 +313,7 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define MASS_STORE_CLASS 0x08
#define MASS_STORE_SUBCLASS 0x06
#define MASS_STORE_PROTOCOL 0x50
#define CBW_SIGNATURE 0x43425355UL
#define CSW_SIGNATURE 0x53425355UL
#define COMMAND_DIRECTION_DATA_OUT (0 << 7)
#define COMMAND_DIRECTION_DATA_IN (1 << 7)
#define COMMAND_DATA_TIMEOUT_MS 10000
#define MS_COMMAND_DATA_TIMEOUT_MS 10000
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_MASSSTORAGE_HOST_C)

View file

@ -111,9 +111,9 @@ static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor)
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == PRINTER_CLASS) &&
(CurrentInterface->SubClass == PRINTER_SUBCLASS) &&
(CurrentInterface->Protocol == PRINTER_PROTOCOL))
if ((CurrentInterface->Class == PRNT_CSCP_PrinterClass) &&
(CurrentInterface->SubClass == PRNT_CSCP_PrinterSubclass) &&
(CurrentInterface->Protocol == PRNT_CSCP_BidirectionalProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}

View file

@ -264,11 +264,6 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define PRINTER_CLASS 0x07
#define PRINTER_SUBCLASS 0x01
#define PRINTER_PROTOCOL 0x02
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_PRINTER_HOST_C)
static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);

View file

@ -142,9 +142,9 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDes
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == RNDIS_CONTROL_CLASS) &&
(CurrentInterface->SubClass == RNDIS_CONTROL_SUBCLASS) &&
(CurrentInterface->Protocol == RNDIS_CONTROL_PROTOCOL))
if ((CurrentInterface->Class == CDC_CSCP_CDCClass) &&
(CurrentInterface->SubClass == CDC_CSCP_ACMSubclass) &&
(CurrentInterface->Protocol == CDC_CSCP_VendorSpecificProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}
@ -160,9 +160,9 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescri
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == RNDIS_DATA_CLASS) &&
(CurrentInterface->SubClass == RNDIS_DATA_SUBCLASS) &&
(CurrentInterface->Protocol == RNDIS_DATA_PROTOCOL))
if ((CurrentInterface->Class == CDC_CSCP_CDCDataClass) &&
(CurrentInterface->SubClass == CDC_CSCP_NoDataSubclass) &&
(CurrentInterface->Protocol == CDC_CSCP_NoDataProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}

View file

@ -262,14 +262,6 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define RNDIS_CONTROL_CLASS 0x02
#define RNDIS_CONTROL_SUBCLASS 0x02
#define RNDIS_CONTROL_PROTOCOL 0xFF
#define RNDIS_DATA_CLASS 0x0A
#define RNDIS_DATA_SUBCLASS 0x00
#define RNDIS_DATA_PROTOCOL 0x00
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_RNDIS_HOST_C)
static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,

View file

@ -128,9 +128,9 @@ uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor)
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == STILL_IMAGE_CLASS) &&
(CurrentInterface->SubClass == STILL_IMAGE_SUBCLASS) &&
(CurrentInterface->Protocol == STILL_IMAGE_PROTOCOL))
if ((CurrentInterface->Class == SI_CSCP_StillImageClass) &&
(CurrentInterface->SubClass == SI_CSCP_StillImageSubclass) &&
(CurrentInterface->Protocol == SI_CSCP_BulkOnlyProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}
@ -196,7 +196,7 @@ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
PIMA_Container_t* const PIMAHeader)
{
uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
uint16_t TimeoutMSRem = SI_COMMAND_DATA_TIMEOUT_MS;
uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))

View file

@ -311,11 +311,7 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define STILL_IMAGE_CLASS 0x06
#define STILL_IMAGE_SUBCLASS 0x01
#define STILL_IMAGE_PROTOCOL 0x01
#define COMMAND_DATA_TIMEOUT_MS 10000
#define SI_COMMAND_DATA_TIMEOUT_MS 10000
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_STILLIMAGE_HOST_C)