aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/Device.h
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-07-22 15:38:12 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-07-22 15:38:12 +0000
commit9b0e4b8356eb79003a806d010f4b00123350ed90 (patch)
treebf3c74f3cf45da2990995252dd74226fe793d755 /LUFA/Drivers/USB/LowLevel/Device.h
parent2461ae508c32914ff8aa0920ed99d4fceb18b141 (diff)
downloadlufa-9b0e4b8356eb79003a806d010f4b00123350ed90.tar.gz
lufa-9b0e4b8356eb79003a806d010f4b00123350ed90.tar.bz2
lufa-9b0e4b8356eb79003a806d010f4b00123350ed90.zip
Convert over internal pseudo-function macros to true inline functions for added type-safety and compile-checking.
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/Device.h')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Device.h62
1 files changed, 40 insertions, 22 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Device.h b/LUFA/Drivers/USB/LowLevel/Device.h
index c6c2e9fdd..2c9dc2810 100644
--- a/LUFA/Drivers/USB/LowLevel/Device.h
+++ b/LUFA/Drivers/USB/LowLevel/Device.h
@@ -50,11 +50,13 @@
#define __USBDEVICE_H__
/* Includes: */
+ #include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "../../../Common/Common.h"
#include "../HighLevel/StdDescriptors.h"
+ #include "USBInterrupt.h"
#include "Endpoint.h"
/* Preprocessor Checks: */
@@ -107,24 +109,6 @@
* \see \ref Group_Descriptors for more information on the RMWAKEUP feature and device descriptors.
*/
void USB_Device_SendRemoteWakeup(void);
-
- /* Pseudo-Function Macros: */
- #if defined(__DOXYGEN__)
- /** Enables the device mode Start Of Frame events. When enabled, this causes the
- * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
- * at the start of each USB frame when enumerated in device mode.
- */
- static inline bool USB_Device_EnableSOFEvents(void);
-
- /** Disables the device mode Start Of Frame events. When disabled, this stop the firing of the
- * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
- */
- static inline bool USB_Device_DisableSOFEvents(void);
- #else
- #define USB_Device_EnableSOFEvents() MACROS{ USB_INT_Enable(USB_INT_SOFI); }MACROE
-
- #define USB_Device_DisableSOFEvents() MACROS{ USB_INT_Disable(USB_INT_SOFI); }MACROE
- #endif
/* Type Defines: */
enum USB_Device_States_t
@@ -155,6 +139,26 @@
*/
};
+ /* Inline Functions: */
+ /** Enables the device mode Start Of Frame events. When enabled, this causes the
+ * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
+ * at the start of each USB frame when enumerated in device mode.
+ */
+ static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_EnableSOFEvents(void)
+ {
+ USB_INT_Enable(USB_INT_SOFI);
+ }
+
+ /** Disables the device mode Start Of Frame events. When disabled, this stop the firing of the
+ * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
+ */
+ static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_DisableSOFEvents(void)
+ {
+ USB_INT_Disable(USB_INT_SOFI);
+ }
+
/* Function Prototypes: */
/** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
* index and language ID. This function MUST be overridden in the user application (added with full, identical
@@ -191,12 +195,26 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
- /* Macros: */
- #define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE
- #define USB_Device_SetFullSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE
+ /* Inline Functions: */
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_SetLowSpeed(void)
+ {
+ UDCON |= (1 << LSM);
+ }
- #define USB_Device_SetDeviceAddress(addr) MACROS{ UDADDR = ((1 << ADDEN) | (addr & 0x7F)); }MACROE
+ static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_SetFullSpeed(void)
+ {
+ UDCON &= ~(1 << LSM);
+ }
+ #endif
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
+ {
+ UDADDR = ((1 << ADDEN) | (Address & 0x7F));
+ }
#endif
#endif