*/\r
\r
========== TODO: ===========\r
- - Document new device class drivers\r
- Make new host class drivers\r
- Document new host class drivers\r
- Convert Host mode demos to class drivers\r
uint16_t LockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry */\r
} USB_AudioStreamEndpoint_Spc_t; \r
\r
- /** Type define for an Audio Class interface configuration and state structure. This structure should be used for each Audio\r
- * Class unit within the device, and passed (per-interface) to the Audio Class driver functions so that each Audio interface\r
- * has seperate state and configuration data and can be controlled seperately.\r
+ /** Class state structure. An instance of this structure should be made for each Audio interface\r
+ * within the user application, and passed to each of the Audio class driver functions as the\r
+ * AudioInterfaceInfo parameter. The contents of this structure should be set to their correct\r
+ * values when used, or ommitted to force the library to use default values.\r
*/\r
typedef struct\r
{\r
};\r
\r
/* Type Defines: */\r
- /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration\r
- * as set by the host via a class specific request.\r
+ /** Class state structure. An instance of this structure should be made for each CDC interface\r
+ * within the user application, and passed to each of the CDC class driver functions as the\r
+ * CDCInterfaceInfo parameter. The contents of this structure should be set to their correct\r
+ * values when used, or ommitted to force the library to use default values.\r
*/\r
typedef struct\r
{\r
uint8_t AssociatedJackID[1]; /**< IDs of each jack inside the endpoint */\r
} USB_MIDI_Jack_Endpoint_t;\r
\r
+ /** Type define for a USB MIDI event packet, used to encapsulate sent and received MIDI messages from a USB MIDI interface. */\r
typedef struct\r
{\r
- unsigned char Command : 4;\r
- unsigned char CableNumber : 4;\r
+ unsigned char Command : 4; /**< MIDI command being sent or received in the event packet */\r
+ unsigned char CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface */\r
\r
- uint8_t Data1;\r
- uint8_t Data2;\r
- uint8_t Data3; \r
+ uint8_t Data1; /**< First byte of data in the MIDI event */\r
+ uint8_t Data2; /**< Second byte of data in the MIDI event */\r
+ uint8_t Data3; /**< Third byte of data in the MIDI event */ \r
} USB_MIDI_EventPacket_t;\r
\r
+ /** Class state structure. An instance of this structure should be made for each MIDI interface\r
+ * within the user application, and passed to each of the MIDI class driver functions as the\r
+ * MIDIInterfaceInfo parameter. The contents of this structure should be set to their correct\r
+ * values when used, or ommitted to force the library to use default values.\r
+ */\r
typedef struct\r
{\r
- uint8_t StreamingInterfaceNumber;\r
-\r
- uint8_t DataINEndpointNumber;\r
- uint16_t DataINEndpointSize;\r
+ uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls */\r
\r
- uint8_t DataOUTEndpointNumber;\r
- uint16_t DataOUTEndpointSize;\r
+ uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming MIDI data, if available (zero if unused) */\r
+ uint16_t DataINEndpointSize; /**< Size in bytes of the incomming MIDI data endpoint, if available (zero if unused) */\r
\r
- bool InterfaceEnabled;\r
+ uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing MIDI data, if available (zero if unused) */\r
+ uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing MIDI data endpoint, if available (zero if unused) */\r
} USB_ClassInfo_MIDI_t;\r
\r
/* Function Prototypes: */\r
+ /** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
+ * containing the given MIDI interface is selected.\r
+ *\r
+ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ *\r
+ * \return Boolean true if the endpoints were sucessfully configured, false otherwise\r
+ */\r
bool USB_MIDI_ConfigureEndpoints(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo);\r
+ \r
+ /** Processes incomming control requests from the host, that are directed to the given MIDI class interface. This should be\r
+ * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.\r
+ *\r
+ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ */ \r
void USB_MIDI_ProcessControlPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo);\r
+\r
+ /** General management task for a given MIDI class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ */\r
void USB_MIDI_USBTask(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo);\r
\r
+ /** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded.\r
+ *\r
+ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ * \param Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send\r
+ */\r
void USB_MIDI_SendEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);\r
+\r
+ /** Receives a MIDI event packet from the host.\r
+ *\r
+ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ * \param Event Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed\r
+ *\r
+ * \return Boolean true if a MIDI event packet was received, false otherwise\r
+ */\r
bool USB_MIDI_ReceiveEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);\r
\r
/* Disable C linkage for C++ Compilers: */\r
};\r
\r
/* Type Defines: */\r
- /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration\r
- * as set by the host via a class specific request.\r
+ /** Class state structure. An instance of this structure should be made for each Mass Storage interface\r
+ * within the user application, and passed to each of the Mass Storage class driver functions as the\r
+ * MSInterfaceInfo parameter. The contents of this structure should be set to their correct\r
+ * values when used, or ommitted to force the library to use default values.\r
*/\r
typedef struct\r
{\r
uint8_t DataOUTEndpointNumber; /**< Endpoint number of the Mass Storage interface's OUT data endpoint */\r
uint16_t DataOUTEndpointSize; /**< Size in bytes of the Mass Storage interface's OUT data endpoint */\r
\r
- uint8_t TotalLUNs;\r
+ uint8_t TotalLUNs; /**< Total number of logical drives in the Mass Storage interface */\r
\r
- CommandBlockWrapper_t CommandBlock;\r
- CommandStatusWrapper_t CommandStatus;\r
+ CommandBlockWrapper_t CommandBlock; /**< Mass Storage class command block structure, used internally\r
+ * by the class driver\r
+ */\r
+ CommandStatusWrapper_t CommandStatus; /**< Mass Storage class command status structure, used internally\r
+ * by the class driver\r
+ */\r
\r
- bool IsMassStoreReset;\r
+ bool IsMassStoreReset; /**< Flag indicating that the host has requested that the Mass Storage interface be reset\r
+ * and that all current Mass Storage operations should immediately abort\r
+ */\r
} USB_ClassInfo_MS_t;\r
\r
/* Function Prototypes: */\r
static uint8_t StreamCallback_AbortOnMassStoreReset(void);\r
#endif\r
\r
+ /** Configures the endpoints of a given Mass Storage interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
+ * containing the given Mass Storage interface is selected.\r
+ *\r
+ * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.\r
+ *\r
+ * \return Boolean true if the endpoints were sucessfully configured, false otherwise\r
+ */\r
bool USB_MS_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
+ \r
+ /** Processes incomming control requests from the host, that are directed to the given Mass Storage class interface. This should be\r
+ * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.\r
+ *\r
+ * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.\r
+ */ \r
void USB_MS_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
+\r
+ /** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state.\r
+ */\r
void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
\r
+ /** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the\r
+ * host sends a SCSI command which requires processing by the user application. Inside this callback the user is responsible\r
+ * for the processing of the received SCSI command from the host. The SCSI command is available in the CommandBlock structure\r
+ * inside the Mass Storage class state structure passed as a parameter to the callback function.\r
+ *\r
+ * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.\r
+ *\r
+ * \return Boolean true if the SCSI command was successfully processed, false otherwise\r
+ */\r
bool CALLBACK_USB_MS_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
\r
/* Disable C linkage for C++ Compilers: */\r
case OID_GEN_HARDWARE_STATUS:\r
*ResponseSize = sizeof(uint32_t);\r
\r
- *((uint32_t*)ResponseData) = NdisHardwareStatusReady;\r
+ *((uint32_t*)ResponseData) = NDIS_HardwareStatus_Ready;\r
\r
return true;\r
case OID_GEN_MEDIA_SUPPORTED:\r
*\r
* \section Sec_Dependencies Module Source Dependencies\r
* The following files must be built with any user project that uses this module:\r
- * - LUFA/Drivers/USB/Class/Device/HID.c\r
+ * - LUFA/Drivers/USB/Class/Device/RNDIS.c\r
*\r
* \section Module Description\r
* Functions, macros, variables, enums and types related to the management of USB RNDIS Ethernet\r
/** RNDIS request to issue a device-to-host NDIS response */\r
#define REQ_GetEncapsulatedResponse 0x01\r
\r
+ /** Maximum size in bytes of a RNDIS control message which can be sent or received */\r
#define RNDIS_MESSAGE_BUFFER_SIZE 128\r
\r
+ /** Maximum size in bytes of an Ethernet frame which can be sent or received */\r
#define ETHERNET_FRAME_SIZE_MAX 1500\r
\r
+ /** Notification request value for a RNDIS Response Available notification */\r
#define NOTIF_ResponseAvailable 1\r
\r
/* Enums: */\r
/** Enum for the NDIS hardware states */\r
enum NDIS_Hardware_Status_t\r
{\r
- NdisHardwareStatusReady, /**< Hardware Ready to accept commands from the host */\r
- NdisHardwareStatusInitializing, /**< Hardware busy initializing */\r
- NdisHardwareStatusReset, /**< Hardware reset */\r
- NdisHardwareStatusClosing, /**< Hardware currently closing */\r
- NdisHardwareStatusNotReady /**< Hardware not ready to accept commands from the host */\r
+ NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host */\r
+ NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing */\r
+ NDIS_HardwareStatus_Reset, /**< Hardware reset */\r
+ NDIS_HardwareStatus_Closing, /**< Hardware currently closing */\r
+ NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host */\r
};\r
\r
/* Type Defines: */\r
uint32_t Reserved;\r
} RNDIS_PACKET_MSG_t;\r
\r
- typedef struct\r
- {\r
- uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */\r
-\r
- uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint */\r
- uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint */\r
-\r
- uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint */\r
- uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint */\r
-\r
- uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */\r
- uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */\r
- \r
- char* AdapterVendorDescription;\r
- MAC_Address_t AdapterMACAddress;\r
-\r
- uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE];\r
- bool ResponseReady;\r
- uint8_t CurrRNDISState;\r
- uint32_t CurrPacketFilter;\r
- Ethernet_Frame_Info_t FrameIN;\r
- Ethernet_Frame_Info_t FrameOUT;\r
- } USB_ClassInfo_RNDIS_t;\r
- \r
/** Type define for a RNDIS Initialize command message */\r
typedef struct\r
{\r
uint32_t InformationBufferLength;\r
uint32_t InformationBufferOffset;\r
} RNDIS_QUERY_CMPLT_t;\r
- \r
+\r
+ /** Class state structure. An instance of this structure should be made for each RNDIS interface\r
+ * within the user application, and passed to each of the RNDIS class driver functions as the\r
+ * RNDISInterfaceInfo parameter. The contents of this structure should be set to their correct\r
+ * values when used, or ommitted to force the library to use default values.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */\r
+\r
+ uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint */\r
+ uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint */\r
+\r
+ uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint */\r
+ uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint */\r
+\r
+ uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */\r
+ uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */\r
+ \r
+ char* AdapterVendorDescription; /**< String description of the adapter vendor */\r
+ MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter */\r
+\r
+ uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host,\r
+ * managed by the class driver\r
+ */\r
+ bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host */\r
+ uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the RNDIS_States_t enum */\r
+ uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver */\r
+ Ethernet_Frame_Info_t FrameIN; /**< Structure holding the last received Ethernet frame from the host, for user\r
+ * processing\r
+ */\r
+ Ethernet_Frame_Info_t FrameOUT; /**< Structure holding the next Ethernet frame to send to the host, populated by the\r
+ * user application\r
+ */\r
+ } USB_ClassInfo_RNDIS_t;\r
+ \r
/* Function Prototypes: */\r
#if defined(INCLUDE_FROM_RNDIS_CLASS_C)\r
static void USB_RNDIS_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
void* SetData, uint16_t SetSize); \r
#endif\r
\r
+ /** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
+ * containing the given HID interface is selected.\r
+ *\r
+ * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.\r
+ *\r
+ * \return Boolean true if the endpoints were sucessfully configured, false otherwise\r
+ */\r
bool USB_RNDIS_ConfigureEndpoints(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
+\r
+ /** Processes incomming control requests from the host, that are directed to the given RNDIS class interface. This should be\r
+ * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.\r
+ *\r
+ * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.\r
+ */ \r
void USB_RNDIS_ProcessControlPacket(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
+ \r
+ /** General management task for a given HID class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.\r
+ */\r
void USB_RNDIS_USBTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
\r
/* Disable C linkage for C++ Compilers: */\r