diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-04 02:55:30 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-04 02:55:30 +0000 |
commit | a67bd74e3e8aad87dcee8cf0c0eaaccbe7d00552 (patch) | |
tree | fdf670b5b93e2e192d19ca71138a667d7f3ba4f9 /LUFA/Drivers/USB/Class | |
parent | 7c5444b89a49df7cb671b0b041567990d2a3012e (diff) | |
download | lufa-a67bd74e3e8aad87dcee8cf0c0eaaccbe7d00552.tar.gz lufa-a67bd74e3e8aad87dcee8cf0c0eaaccbe7d00552.tar.bz2 lufa-a67bd74e3e8aad87dcee8cf0c0eaaccbe7d00552.zip |
Minor documentation page updates.
Redocumented all device demos, now that they have changed over to the new USB class drivers.
Added C linkage to class drivers for C++ support.
Added prefixes to most of the class driver constants to prevent name clashes.
Diffstat (limited to 'LUFA/Drivers/USB/Class')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/Audio.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/Audio.h | 15 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.h | 53 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.h | 10 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MIDI.h | 16 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorage.c | 14 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorage.h | 31 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/RNDIS.h | 12 |
8 files changed, 105 insertions, 48 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.c b/LUFA/Drivers/USB/Class/Device/Audio.c index d9162ff2d..acd9f6956 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.c +++ b/LUFA/Drivers/USB/Class/Device/Audio.c @@ -35,7 +35,7 @@ void USB_Audio_ProcessControlPacket(USB_ClassInfo_Audio_t* AudioInterfaceInfo) if (!(Endpoint_IsSETUPReceived()))
return;
- if (USB_ControlRequest.wIndex != AudioInterfaceInfo->InterfaceNumber)
+ if (USB_ControlRequest.wIndex != AudioInterfaceInfo->StreamingInterfaceNumber)
return;
switch (USB_ControlRequest.bRequest)
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h index 0ea74864a..f92b9ab91 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.h +++ b/LUFA/Drivers/USB/Class/Device/Audio.h @@ -36,6 +36,11 @@ #include <string.h>
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
/* Macros: */
/** Descriptor header constant to indicate a Audio class interface descriptor. */
#define DTYPE_AudioInterface 0x24
@@ -120,7 +125,7 @@ *
* \param freq Required audio sampling frequency in HZ
*/
- #define SAMPLE_FREQ(freq) {LowWord: ((uint32_t)freq & 0x00FFFF), HighByte: (((uint32_t)freq >> 16) & 0x0000FF)}
+ #define AUDIO_SAMPLE_FREQ(freq) {LowWord: ((uint32_t)freq & 0x00FFFF), HighByte: (((uint32_t)freq >> 16) & 0x0000FF)}
/** Mask for the attributes parameter of an Audio class specific Endpoint descriptor, indicating that the endpoint
* accepts only filled endpoint packets of audio samples.
@@ -277,7 +282,7 @@ typedef struct
{
- uint8_t InterfaceNumber;
+ uint8_t StreamingInterfaceNumber;
uint8_t DataINEndpointNumber;
uint16_t DataINEndpointSize;
@@ -301,4 +306,10 @@ void USB_Audio_WriteSample24(int32_t Sample);
bool USB_Audio_IsSampleReceived(USB_ClassInfo_Audio_t* AudioInterfaceInfo);
bool USB_Audio_IsReadyForNextSample(USB_ClassInfo_Audio_t* AudioInterfaceInfo);
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
#endif
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index bbe1c9838..b1d7c6dda 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -36,66 +36,71 @@ #include <string.h>
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
/* Macros: */
/** CDC Class specific request to get the current virtual serial port configuration settings. */
- #define REQ_GetLineEncoding 0x21
+ #define REQ_GetLineEncoding 0x21
/** CDC Class specific request to set the current virtual serial port configuration settings. */
- #define REQ_SetLineEncoding 0x20
+ #define REQ_SetLineEncoding 0x20
/** CDC Class specific request to set the current virtual serial port handshake line states. */
- #define REQ_SetControlLineState 0x22
+ #define REQ_SetControlLineState 0x22
/** Notification type constant for a change in the virtual serial port handshake line states, for
* use with a USB_Notification_Header_t notification structure when sent to the host via the CDC
* notification endpoint.
*/
- #define NOTIF_SerialState 0x20
+ #define NOTIF_SerialState 0x20
/** Mask for the DTR handshake line for use with the REQ_SetControlLineState class specific request
* from the host, to indicate that the DTR line state should be high.
*/
- #define CONTROL_LINE_OUT_DTR (1 << 0)
+ #define CDC_CONTROL_LINE_OUT_DTR (1 << 0)
/** Mask for the RTS handshake line for use with the REQ_SetControlLineState class specific request
* from the host, to indicate that theRTS line state should be high.
*/
- #define CONTROL_LINE_OUT_RTS (1 << 1)
+ #define CDC_CONTROL_LINE_OUT_RTS (1 << 1)
/** Mask for the DCD handshake line for use with the a NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the DCD line state is currently high.
*/
- #define CONTROL_LINE_IN_DCD (1 << 0)
+ #define CDC_CONTROL_LINE_IN_DCD (1 << 0)
/** Mask for the DSR handshake line for use with the a NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the DSR line state is currently high.
*/
- #define CONTROL_LINE_IN_DSR (1 << 1)
+ #define CDC_CONTROL_LINE_IN_DSR (1 << 1)
/** Mask for the BREAK handshake line for use with the a NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the BREAK line state is currently high.
*/
- #define CONTROL_LINE_IN_BREAK (1 << 2)
+ #define CDC_CONTROL_LINE_IN_BREAK (1 << 2)
/** Mask for the RING handshake line for use with the a NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the RING line state is currently high.
*/
- #define CONTROL_LINE_IN_RING (1 << 3)
+ #define CDC_CONTROL_LINE_IN_RING (1 << 3)
/** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,
* to indicate that a framing error has occurred on the virtual serial port.
*/
- #define CONTROL_LINE_IN_FRAMEERROR (1 << 4)
+ #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4)
/** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,
* to indicate that a parity error has occurred on the virtual serial port.
*/
- #define CONTROL_LINE_IN_PARITYERROR (1 << 5)
+ #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5)
/** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,
* to indicate that a data overrun error has occurred on the virtual serial port.
*/
- #define CONTROL_LINE_IN_OVERRUNERROR (1 << 6)
+ #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6)
/** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a
* uniform structure but variable sized data payloads, thus cannot be represented accurately by
@@ -116,19 +121,19 @@ /** Enum for the possible line encoding formats of a virtual serial port. */
enum CDCDevice_CDC_LineCodingFormats_t
{
- OneStopBit = 0, /**< Each frame contains one stop bit */
- OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
- TwoStopBits = 2, /**< Each frame contains two stop bits */
+ CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit */
+ CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
+ CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits */
};
/** Enum for the possible line encoding parity settings of a virtual serial port. */
enum CDCDevice_LineCodingParity_t
{
- Parity_None = 0, /**< No parity bit mode on each frame */
- Parity_Odd = 1, /**< Odd parity bit mode on each frame */
- Parity_Even = 2, /**< Even parity bit mode on each frame */
- Parity_Mark = 3, /**< Mark parity bit mode on each frame */
- Parity_Space = 4, /**< Space parity bit mode on each frame */
+ CDC_PARITY_None = 0, /**< No parity bit mode on each frame */
+ CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame */
+ CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame */
+ CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame */
+ CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame */
};
/* Type Defines: */
@@ -171,7 +176,6 @@ void EVENT_USB_CDC_ControLineStateChanged(void) ATTR_WEAK ATTR_ALIAS(USB_CDC_Event_Stub);;
#endif
- void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
bool USB_CDC_ConfigureEndpoints(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
void USB_CDC_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
@@ -184,5 +188,10 @@ uint16_t USB_CDC_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
void USB_CDC_SendSerialLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask);
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
#endif
diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index 4501fcb1c..9a2f803a4 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -36,6 +36,11 @@ #include <string.h>
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
/* Macros: */
/** HID Class Specific Request to get the current HID report from the device. */
#define REQ_GetReport 0x01
@@ -111,4 +116,9 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize);
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
#endif
diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.h b/LUFA/Drivers/USB/Class/Device/MIDI.h index 17823938c..890d3bb55 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.h +++ b/LUFA/Drivers/USB/Class/Device/MIDI.h @@ -37,6 +37,11 @@ #include <string.h>
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
/* Macros: */
/** Audio class descriptor subtype value for a Audio class specific MIDI input jack descriptor. */
#define DSUBTYPE_InputJack 0x02
@@ -45,10 +50,10 @@ #define DSUBTYPE_OutputJack 0x03
/** Audio class descriptor jack type value for an embedded (logical) MIDI input or output jack. */
- #define JACKTYPE_EMBEDDED 0x01
+ #define MIDI_JACKTYPE_EMBEDDED 0x01
/** Audio class descriptor jack type value for an external (physical) MIDI input or output jack. */
- #define JACKTYPE_EXTERNAL 0x02
+ #define MIDI_JACKTYPE_EXTERNAL 0x02
/** MIDI command for a note on (activation) event */
#define MIDI_COMMAND_NOTE_ON 0x09
@@ -137,7 +142,7 @@ typedef struct
{
- uint8_t InterfaceNumber;
+ uint8_t StreamingInterfaceNumber;
uint8_t DataINEndpointNumber;
uint16_t DataINEndpointSize;
@@ -155,4 +160,9 @@ void USB_MIDI_SendEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);
bool USB_MIDI_ReceiveEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
#endif
diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.c b/LUFA/Drivers/USB/Class/Device/MassStorage.c index 1c41f6046..62c5f0407 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.c @@ -102,16 +102,16 @@ void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo) {
if (USB_MS_ReadInCommandBlock(MSInterfaceInfo))
{
- if (MSInterfaceInfo->CommandBlock.Flags & COMMAND_DIRECTION_DATA_IN)
+ if (MSInterfaceInfo->CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN)
Endpoint_SelectEndpoint(MSInterfaceInfo->DataINEndpointNumber);
MSInterfaceInfo->CommandStatus.Status = CALLBACK_USB_MS_SCSICommandReceived(MSInterfaceInfo) ?
- Command_Pass : Command_Fail;
- MSInterfaceInfo->CommandStatus.Signature = CSW_SIGNATURE;
+ SCSI_Command_Pass : SCSI_Command_Fail;
+ MSInterfaceInfo->CommandStatus.Signature = MS_CSW_SIGNATURE;
MSInterfaceInfo->CommandStatus.Tag = MSInterfaceInfo->CommandBlock.Tag;
MSInterfaceInfo->CommandStatus.DataTransferResidue = MSInterfaceInfo->CommandBlock.DataTransferLength;
- if ((MSInterfaceInfo->CommandStatus.Status == Command_Fail) && (MSInterfaceInfo->CommandStatus.DataTransferResidue))
+ if ((MSInterfaceInfo->CommandStatus.Status == SCSI_Command_Fail) && (MSInterfaceInfo->CommandStatus.DataTransferResidue))
Endpoint_StallTransaction();
USB_MS_ReturnCommandStatus(MSInterfaceInfo);
@@ -138,12 +138,12 @@ static bool USB_MS_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo) CallbackMSInterfaceInfo = MSInterfaceInfo;
Endpoint_Read_Stream_LE(&MSInterfaceInfo->CommandBlock,
- (sizeof(CommandBlockWrapper_t) - MAX_SCSI_COMMAND_LENGTH),
+ (sizeof(CommandBlockWrapper_t) - 16),
StreamCallback_AbortOnMassStoreReset);
- if ((MSInterfaceInfo->CommandBlock.Signature != CBW_SIGNATURE) ||
+ if ((MSInterfaceInfo->CommandBlock.Signature != MS_CBW_SIGNATURE) ||
(MSInterfaceInfo->CommandBlock.LUN >= MSInterfaceInfo->TotalLUNs) ||
- (MSInterfaceInfo->CommandBlock.SCSICommandLength > MAX_SCSI_COMMAND_LENGTH))
+ (MSInterfaceInfo->CommandBlock.SCSICommandLength > 16))
{
Endpoint_StallTransaction();
Endpoint_SelectEndpoint(MSInterfaceInfo->DataINEndpointNumber);
diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.h b/LUFA/Drivers/USB/Class/Device/MassStorage.h index c1874b218..cf2b5749a 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.h @@ -36,27 +36,29 @@ #include <string.h>
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
/* Macros: */
/** Mass Storage Class specific request to reset the Mass Storage interface, ready for the next command. */
#define REQ_MassStorageReset 0xFF
/** Mass Storage Class specific request to retrieve the total number of Logical Units (drives) in the SCSI device. */
#define REQ_GetMaxLUN 0xFE
-
- /** Maximum length of a SCSI command which can be issued by the device or host in a Mass Storage bulk wrapper. */
- #define MAX_SCSI_COMMAND_LENGTH 16
/** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */
- #define CBW_SIGNATURE 0x43425355UL
+ #define MS_CBW_SIGNATURE 0x43425355UL
/** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */
- #define CSW_SIGNATURE 0x53425355UL
+ #define MS_CSW_SIGNATURE 0x53425355UL
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */
- #define COMMAND_DIRECTION_DATA_OUT (0 << 7)
+ #define MS_COMMAND_DIR_DATA_OUT (0 << 7)
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host. */
- #define COMMAND_DIRECTION_DATA_IN (1 << 7)
+ #define MS_COMMAND_DIR_DATA_IN (1 << 7)
/* Type defines: */
/** Type define for a Command Block Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */
@@ -68,7 +70,7 @@ uint8_t Flags; /**< Command block flags, indicating command data direction */
uint8_t LUN; /**< Logical Unit number this command is issued to */
uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array */
- uint8_t SCSICommandData[MAX_SCSI_COMMAND_LENGTH]; /**< Issued SCSI command in the Command Block */
+ uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block */
} CommandBlockWrapper_t;
/** Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */
@@ -84,9 +86,9 @@ /** Enum for the possible command status wrapper return status codes. */
enum MassStorage_CommandStatusCodes_t
{
- Command_Pass = 0, /**< Command completed with no error */
- Command_Fail = 1, /**< Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command */
- Phase_Error = 2 /**< Command failed due to being invalid in the current phase */
+ SCSI_Command_Pass = 0, /**< Command completed with no error */
+ SCSI_Command_Fail = 1, /**< Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command */
+ SCSI_Phase_Error = 2 /**< Command failed due to being invalid in the current phase */
};
/* Type Defines: */
@@ -118,10 +120,15 @@ static uint8_t StreamCallback_AbortOnMassStoreReset(void);
#endif
- void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo);
bool USB_MS_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo);
void USB_MS_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo);
+ void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo);
bool CALLBACK_USB_MS_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo);
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
#endif
diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.h b/LUFA/Drivers/USB/Class/Device/RNDIS.h index 708f57d34..09d48c31e 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDIS.h +++ b/LUFA/Drivers/USB/Class/Device/RNDIS.h @@ -37,6 +37,11 @@ #include "../../USB.h"
#include "RNDISConstants.h"
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
/* Macros: */
/** Implemented RNDIS Version Major */
#define REMOTE_NDIS_VERSION_MAJOR 0x01
@@ -252,8 +257,13 @@ void* SetData, uint16_t SetSize);
#endif
- void USB_RNDIS_USBTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);
bool USB_RNDIS_ConfigureEndpoints(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);
void USB_RNDIS_ProcessControlPacket(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);
+ void USB_RNDIS_USBTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
#endif
|