this software.\r
*/\r
\r
-/** \file\r
+/** \ingroup Group_USB\r
+ * @defgroup Group_Host Host Management\r
*\r
* USB Host mode related macros and enums. This module contains macros and enums which are used when\r
* the USB controller is initialized in host mode.\r
+ *\r
+ * @{\r
*/\r
-\r
+ \r
#ifndef __USBHOST_H__\r
#define __USBHOST_H__\r
\r
* library will return a timeout error code.\r
*\r
* This value may be overridden in the user project makefile as the value of the \r
- * USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
+ * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
*/\r
#define USB_HOST_TIMEOUT_MS 1000\r
#endif\r
*/\r
#define HOST_DEVICE_SETTLE_DELAY_MS 1500\r
#endif\r
- \r
- /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.\r
- * USB bus resets leave the default control pipe configured (if already configured).\r
- *\r
- * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be\r
- * woken up automatically and the bus resumed after the reset has been correctly issued.\r
- */\r
- #define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE\r
+ \r
+ /* Pseudo-Function Macros: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.\r
+ * USB bus resets leave the default control pipe configured (if already configured).\r
+ *\r
+ * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be\r
+ * woken up automatically and the bus resumed after the reset has been correctly issued.\r
+ */\r
+ static inline void USB_Host_ResetBus(void);\r
\r
- /** Determines if a previously issued bus reset (via the USB_Host_ResetBus() macro) has\r
- * completed. This macro returns true if no bus reset is currently being sent, false\r
- * otherwise.\r
- */\r
- #define USB_Host_IsResetBusDone() ((UHCON & (1 << RESET)) ? false : true)\r
- \r
- /** Resumes USB communications with an attached and enumerated device, by resuming the transmission\r
- * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the\r
- * host and attached device may occur.\r
- */\r
- #define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE \r
+ /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has\r
+ * completed.\r
+ *\r
+ * \return Boolean true if no bus reset is currently being sent, false otherwise.\r
+ */\r
+ static inline void USB_Host_IsBusResetComplete(void);\r
\r
- /** Suspends the USB bus, preventing any communications from occuring between the host and attached\r
- * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame\r
- * messages to the device.\r
- */\r
- #define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE \r
- \r
- /** Returns true if the USB bus has been suspended via the use of the USB_Host_SuspendBus() macro,\r
- * false otherwise. While suspended, no USB communications can occur until the bus is resumed,\r
- * except for the Remote Wakeup event from the device if supported.\r
- */\r
- #define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)\r
- \r
- /** Returns true if the attached device is currently enumerated in Full Speed mode (12Mb/s), or\r
- * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).\r
- */\r
- #define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)\r
+ /** Resumes USB communications with an attached and enumerated device, by resuming the transmission\r
+ * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the\r
+ * host and attached device may occur.\r
+ */\r
+ static inline void USB_Host_ResumeBus(void);\r
\r
- /** Returns true if the attached device is currently issuing a Remote Wakeup request, requesting\r
- * that the host resume the USB bus and wake up the device, false otherwise.\r
- */\r
- #define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)\r
+ /** Suspends the USB bus, preventing any communications from occurring between the host and attached\r
+ * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame\r
+ * messages to the device.\r
+ */\r
+ static inline void USB_Host_SuspendBus(void);\r
+ \r
+ /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,\r
+ * false otherwise. While suspended, no USB communications can occur until the bus is resumed,\r
+ * except for the Remote Wakeup event from the device if supported.\r
+ *\r
+ * \return Boolean true if the bus is currently suspended, false otherwise\r
+ */\r
+ static inline bool USB_Host_IsBusSuspended(void);\r
+ \r
+ /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or\r
+ * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).\r
+ *\r
+ * \return Boolean true if the attached device is enumerated in Full Speed mode, false otherwise\r
+ */\r
+ static inline bool USB_Host_IsDeviceFullSpeed(void);\r
\r
- /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached\r
- * device.\r
- */\r
- #define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE\r
+ /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting\r
+ * that the host resume the USB bus and wake up the device, false otherwise.\r
+ *\r
+ * \return Boolean true if the attached device has sent a Remote Wakeup request, false otherwise\r
+ */\r
+ static inline bool USB_Host_IsRemoteWakeupSent(void);\r
\r
- /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to\r
- * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to\r
- * be resumed.\r
- */\r
- #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE\r
+ /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */\r
+ static inline void USB_Host_ClearRemoteWakeupSent(void);\r
+\r
+ /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to\r
+ * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to\r
+ * be resumed.\r
+ */\r
+ static inline void USB_Host_ResumeFromWakeupRequest(void);\r
+ \r
+ /** Determines if a resume from Remote Wakeup request is currently being sent to an attached\r
+ * device.\r
+ *\r
+ * \return Boolean true if no resume request is currently being sent, false otherwise\r
+ */\r
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void);\r
+ #else\r
+ #define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE\r
+\r
+ #define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true)\r
+\r
+ #define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE \r
+\r
+ #define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE \r
+ \r
+ #define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)\r
\r
- /** Returns true if no resume from Remote Wakeup request is currently being sent to an attached\r
- * device, false otherwise.\r
- */\r
- #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)\r
+ #define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)\r
+\r
+ #define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)\r
+\r
+ #define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE\r
+\r
+ #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE\r
+ \r
+ #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)\r
+ #endif\r
\r
/* Enums: */\r
/** Enum for the various states of the USB Host state machine. Only some states are\r
*\r
* For information on each state, refer to the USB 2.0 specification. Some states have\r
*\r
- * \see USBTask.h for information on the global variable USB_HostState, which stores the\r
- * current host state machine state.\r
+ * \see \ref USB_HostState, which stores the current host state machine state.\r
*/\r
enum USB_Host_States_t\r
{\r
HOST_STATE_Suspended = 13, /**< May be implemented by the user project. */\r
};\r
\r
- /** Enum for the error codes for the USB_HostError event.\r
+ /** Enum for the error codes for the \ref USB_HostError event.\r
*\r
- * \see Events.h for more information on this event.\r
+ * \see \ref Group_Events for more information on this event.\r
*/\r
enum USB_Host_ErrorCodes_t\r
{\r
HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This\r
- * error may be the result of an attached device drawing\r
+ * error may be the result of an attached device drawing\r
* too much current from the VBUS line, or due to the\r
* AVR's power source being unable to supply sufficient\r
* current.\r
*/\r
};\r
\r
- /** Enum for the error codes for the USB_DeviceEnumerationFailed event.\r
+ /** Enum for the error codes for the \ref USB_DeviceEnumerationFailed event.\r
*\r
- * \see Events.h for more information on this event.\r
+ * \see \ref Group_Events for more information on this event.\r
*/\r
enum USB_Host_EnumerationErrorCodes_t\r
{\r
HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid\r
- * ErrorCode parameter value for the USB_DeviceEnumerationFailed\r
+ * ErrorCode parameter value for the \ref USB_DeviceEnumerationFailed\r
* event.\r
*/\r
HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed\r
- * to complete successfuly, due to a timeout or other\r
+ * to complete successfully, due to a timeout or other\r
* error.\r
*/\r
HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines\r
* indicating the attachment of a device.\r
*/\r
HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to\r
- * complete successfuly.\r
+ * complete successfully.\r
*/\r
HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to\r
* configure correctly.\r
#define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE\r
#define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE\r
\r
- #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = (addr & 0b01111111); }MACROE\r
+ #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = (addr & 0x7F); }MACROE\r
\r
/* Enums: */\r
enum USB_Host_WaitMSErrorCodes_t\r
#if defined(__cplusplus)\r
}\r
#endif\r
-\r
+ \r
#endif\r
+\r
+/** @} */\r