Finished basic documentation of all device mode class drivers.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / RNDIS.h
index a8c8db9..a21a3de 100644 (file)
@@ -33,7 +33,7 @@
  *\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