From 4e601207a7bcf5d909a2a896afdcf333c35bbfa6 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 6 Jul 2011 02:50:08 +0000 Subject: Tighten up the implementations of the USB_Device_SetDeviceAddress(), USB_Controller_Reset() and USB_PLL_On() functions for the AVR8 devices. Minor corrections to the documentation of the USB_Control_Request_t enum. --- LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h | 48 +++++++++++++------------ LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h | 14 ++++---- LUFA/Drivers/USB/Core/StdRequestType.h | 18 +++++----- LUFA/Drivers/USB/Core/UC3/Device_UC3.h | 42 +++++++++++----------- 4 files changed, 61 insertions(+), 61 deletions(-) (limited to 'LUFA/Drivers/USB') diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index e9696089f..9899251ee 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -155,28 +155,28 @@ } #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 \c 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); - } + /** 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 \c 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 \c 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); - } + /** 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 \c 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 /* Private Interface - For use in library only: */ @@ -199,8 +199,10 @@ static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; static inline void USB_Device_SetDeviceAddress(const uint8_t Address) { - UDADDR = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F)); - UDADDR |= (1 << ADDEN); + uint8_t Temp = (UDADDR & (1 << ADDEN)) | (Address & 0x7F); + + UDADDR = Temp; + UDADDR = Temp | (1 << ADDEN); } static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; diff --git a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h index 6be41fd96..f29a5c60d 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h @@ -359,20 +359,20 @@ static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE; static inline void USB_PLL_On(void) { - PLLCSR = USB_PLL_PSC; - PLLCSR |= (1 << PLLE); + PLLCSR = USB_PLL_PSC; + PLLCSR = (USB_PLL_PSC | (1 << PLLE)); } static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE; static inline void USB_PLL_Off(void) { - PLLCSR = 0; + PLLCSR = 0; } static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool USB_PLL_IsReady(void) { - return ((PLLCSR & (1 << PLOCK)) ? true : false); + return ((PLLCSR & (1 << PLOCK)) ? true : false); } static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE; @@ -436,10 +436,8 @@ static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE; static inline void USB_Controller_Reset(void) { - const uint8_t Temp = USBCON; - - USBCON = (Temp & ~(1 << USBE)); - USBCON = (Temp | (1 << USBE)); + USBCON &= ~(1 << USBE); + USBCON |= (1 << USBE); } #if defined(USB_CAN_BE_BOTH) diff --git a/LUFA/Drivers/USB/Core/StdRequestType.h b/LUFA/Drivers/USB/Core/StdRequestType.h index 4b3bf33fb..356606e3a 100644 --- a/LUFA/Drivers/USB/Core/StdRequestType.h +++ b/LUFA/Drivers/USB/Core/StdRequestType.h @@ -178,17 +178,17 @@ */ enum USB_Control_Request_t { - REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface - * recipients. Passed to the user application for other recipients - * via the \ref EVENT_USB_Device_ControlRequest() event when received in + REQ_GetStatus = 0, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ - REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface - * recipients. Passed to the user application for other recipients - * via the \ref EVENT_USB_Device_ControlRequest() event when received in + REQ_ClearFeature = 1, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ - REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface - * recipients. Passed to the user application for other recipients - * via the \ref EVENT_USB_Device_ControlRequest() event when received in + REQ_SetFeature = 3, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed * to the user application for other recipients via the diff --git a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h index 53d497a68..f5a89221f 100644 --- a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h @@ -145,28 +145,28 @@ } #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 \c 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); - } + /** 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 \c 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 \c 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); - } + /** 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 \c 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 /* Private Interface - For use in library only: */ -- cgit v1.2.3