X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/cd4c10fefad1b19e3bf9e326abc43711ea1d0fd4..d36c96d6a526f74e3853466bcecf49261c58b9bd:/LUFA/Drivers/USB/LowLevel/Device.h?ds=sidebyside diff --git a/LUFA/Drivers/USB/LowLevel/Device.h b/LUFA/Drivers/USB/LowLevel/Device.h index 17984c719..2f54d1dd4 100644 --- a/LUFA/Drivers/USB/LowLevel/Device.h +++ b/LUFA/Drivers/USB/LowLevel/Device.h @@ -140,6 +140,14 @@ }; /* Inline Functions: */ + /** 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 uint16_t USB_Device_GetFrameNumber(void) + { + return UDFNUM; + } + /** 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. @@ -213,8 +221,15 @@ 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