Rewritten event system to remove all macros, to make user code clearer.
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / OTG.h
index e1a92f1..d3dee96 100644 (file)
   arising out of or in connection with the use or performance of\r
   this software.\r
 */\r
-\r
-/** \file\r
\r
+/** \ingroup Group_USB\r
+ *  @defgroup Group_OTGManagement USB On The Go (OTG) Management\r
  *\r
- *  Macros for embedded USB hosts with dual role On The Go capabilities, for managing role exchange. OTG\r
- *  is a way for two USB dual role devices to talk to one another directly without fixed device/host roles.\r
+ *  This module contains macros for embedded USB hosts with dual role On The Go capabilities, for managing role\r
+ *  exchange. OTG is a way for two USB dual role devices to talk to one another directly without fixed device/host\r
+ *  roles.\r
  *\r
- *  \note These macros are only for AVRs which support the OTG protocol, and do not exist for device-only AVRs.\r
+ *  @{\r
  */\r
 \r
 #ifndef __USBOTG_H__\r
 \r
        /* Public Interface - May be used in end-application: */\r
                /* Macros: */\r
-                       /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device\r
-                        *  that the device wishes to change device/host roles.\r
-                        */\r
-                       #define USB_OTG_DEV_Request_HNP()          MACROS{ OTGCON |=  (1 << HNPREQ); }MACROE\r
-\r
-                       /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other\r
-                        *  connected device.\r
-                        */\r
-                       #define USB_OTG_DEV_Cancel_HNP_Request()   MACROS{ OTGCON &= ~(1 << HNPREQ); }MACROE\r
-\r
-                       /** Returns boolean false if not currently sending a HNP to the other connected device, or true\r
-                        *  if a HNP is currently being issued.\r
-                        */\r
-                       #define USB_OTG_DEV_IsSendingHNP()               ((OTGCON &   (1 << HNPREQ)) ? true : false)\r
-                       \r
-                       /** Accepts a HNP from a connected device, indicating that both devices should exchange\r
-                        *  device/host roles.\r
-                        */\r
-                       #define USB_OTG_HOST_Accept_HNP()          USB_OTG_DEV_Request_HNP()\r
-\r
-                       /** Rejects a HNP from a connected device, indicating that both devices should remain in their\r
-                        *  current device/host roles.\r
-                        */\r
-                       #define USB_OTG_HOST_Reject_HNP()          USB_OTG_DEV_Cancel_HNP_Request()\r
-                       \r
-                       /** Returns boolean false if the connected device is not currently sending a HNP request, or true\r
-                        *  if a HNP is currently being issued by the connected device.\r
-                        */\r
-                       #define USB_OTG_HOST_IsHNPReceived()             ((OTGCON &   (1 << HNPREQ)) ? true : false)\r
-                       \r
-                       /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB\r
-                        *  interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in\r
-                        *  host mode indicates that VBUS should be applied and a session started.\r
-                        *\r
-                        *  There are two different methods of sending a SRP - either pulses on the VBUS line, or by\r
-                        *  pulsing the Data + line via the internal pullup resistor. The SRP mode is given as the\r
-                        *  "type" parameter, and can be either USB_OTG_SRP_VBUS or USB_OTG_STP_DATA.\r
-                        */\r
-                       #define USB_OTG_DEV_Initiate_SRP(type)     MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (type | (1 << SRPREQ))); }MACROE\r
-\r
                        /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.\r
                         *\r
                         *  \see USB_OTG_DEV_Initiate_SRP()\r
                         */                      \r
                        #define USB_OTG_STP_DATA                   0\r
 \r
+               /* Pseudo-Function Macros: */\r
+                       #if defined(__DOXYGEN__)\r
+                               /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device\r
+                                *  that the device wishes to change device/host roles.\r
+                                */\r
+                               static inline void USB_OTG_Device_RequestHNP(void);\r
+                               \r
+                               /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other\r
+                                *  connected device.\r
+                                */\r
+                               static inline void USB_OTG_Device_CancelHNPRequest(void);\r
+                               \r
+                               /** Determines if the device is currently sending a HNP to an attached host.\r
+                                *\r
+                                *  \return Boolean true if currently sending a HNP to the other connected device, false otherwise\r
+                                */\r
+                               static inline bool USB_OTG_Device_IsSendingHNP(void);\r
+                               \r
+                               /** Accepts a HNP from a connected device, indicating that both devices should exchange\r
+                                *  device/host roles.\r
+                                */\r
+                               static inline void USB_OTG_Host_AcceptHNP(void);\r
+                               \r
+                               /** Rejects a HNP from a connected device, indicating that both devices should remain in their\r
+                                *  current device/host roles.\r
+                                */\r
+                               static inline void USB_OTG_Host_RejectHNP(void);\r
+                               \r
+                               /** Indicates if the connected device is not currently sending a HNP request.\r
+                                *\r
+                                *  \return Boolean true if a HNP is currently being issued by the connected device, false otherwise.\r
+                                */\r
+                               static inline bool USB_OTG_Host_IsHNPReceived(void);\r
+                               \r
+                               /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB\r
+                                *  interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in\r
+                                *  host mode indicates that VBUS should be applied and a session started.\r
+                                *\r
+                                *  There are two different methods of sending a SRP - either pulses on the VBUS line, or by\r
+                                *  pulsing the Data + line via the internal pull-up resistor.\r
+                                *\r
+                                *  \param SRPTypeMask  Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or \ref USB_OTG_STP_DATA.\r
+                                */\r
+                               static inline void USB_OTG_Dev_InitiateSRP(uint8_t SRPTypeMask);\r
+                       #else\r
+                               #define USB_OTG_Device_RequestHNP()         MACROS{ OTGCON |=  (1 << HNPREQ); }MACROE\r
+\r
+                               #define USB_OTG_Device_CancelHNPRequest()   MACROS{ OTGCON &= ~(1 << HNPREQ); }MACROE\r
+\r
+                               #define USB_OTG_Device_IsSendingHNP()             ((OTGCON &   (1 << HNPREQ)) ? true : false)\r
+                               \r
+                               #define USB_OTG_Host_AcceptHNP()            MACROS{ OTGCON |=  (1 << HNPREQ); }MACROE\r
+\r
+                               #define USB_OTG_Host_RejectHNP()            MACROS{ OTGCON &= ~(1 << HNPREQ); }MACROE\r
+                               \r
+                               #define USB_OTG_Host_IsHNPReceived()              ((OTGCON &   (1 << HNPREQ)) ? true : false)\r
+                               \r
+                               #define USB_OTG_Device_InitiateSRP(type)    MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (type | (1 << SRPREQ))); }MACROE\r
+                       #endif\r
+       \r
 #endif\r
+                       \r
+/** @} */\r