Remove MIDI ClassDriver device demo's accidental inclusion of the unused ADC peripher...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Device.h
index c30da9c..03440d2 100644 (file)
                         *        issued if the host is currently allowing remote wakeup events from the device (i.e.,
                         *        the \ref USB_RemoteWakeupEnabled flag is set). When the NO_DEVICE_REMOTE_WAKEUP compile
                         *        time option is used, this macro is unavailable.
-                        *        \n
+                        *        \n\n
                         *
                         *  \note The USB clock must be running for this function to operate. If the stack is initialized with
                         *        the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running
                        };
                        
                /* 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.
+                       /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)
+                        *  the frame number is incremented by one.
                         */
-                       static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
-                       static inline void USB_Device_EnableSOFEvents(void)
+                       static inline uint16_t USB_Device_GetFrameNumber(void)
                        {
-                               USB_INT_Enable(USB_INT_SOFI);
-                       }
-                               
-                       /** Disables the device mode Start Of Frame events. When disabled, this stops 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);
+                               return UDFNUM;
                        }
+               
+                       #if !defined(NO_SOF_EVENTS)
+                               /** 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.
+                                *
+                                *  \note Not available when the NO_SOF_EVENTS compile time token is defined.
+                                */
+                               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 stops the firing of the
+                                *  \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
+                                *
+                                *  \note Not available when the NO_SOF_EVENTS compile time token is defined.
+                                */
+                               static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
+                               static inline void USB_Device_DisableSOFEvents(void)
+                               {
+                                       USB_INT_Disable(USB_INT_SOFI);
+                               }
+                       #endif
                        
                /* Function Prototypes: */
                        /** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
                         */
                        uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
                                                            const uint8_t wIndex,
-                                                           void** const DescriptorAddress
+                                                           const void** const DescriptorAddress
                        #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
                                                            , uint8_t* MemoryAddressSpace
                        #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));
-                       }                       
+                               UDADDR  = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F));
+                               UDADDR |= (1 << ADDEN);
+                       }
+
+                       static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE;
+                       static inline bool USB_Device_IsAddressSet(void)
+                       {
+                               return (UDADDR & (1 << ADDEN));
+                       }
        #endif
 
 #endif