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.
This commit is contained in:
Dean Camera committed 2011-07-06 02:50:08 +00:00
1 parent 87b57522b2
commit 4e601207a7
5 files changed
+62 -62

No files matched your search

+1 -1
View File
@@ -1 +1 @@
<Project name="LUFA"><Folder name="Demos"><Folder name="Device"><Folder name="ClassDriver"><Folder name="AudioInput"><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.c"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.h"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.txt"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioInput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioInput\makefile"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.aps"></File></Folder><Folder name="AudioOutput"><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.txt"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioOutput\makefile"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.aps"></File></Folder><Folder name="DualVirtualSerial"><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.txt"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\LUFA DualVirtualSerial.inf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\makefile"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.aps"></File></Folder><Folder name="GenericHID"><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.c"></File><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.h"></File><File path="Demos\Device\ClassDriver\GenericHID\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.c"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.h"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.txt"></File><File path="Demos\Device\ClassDriver\GenericHID\makefile"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.aps"></File></Folder><Folder name="Joystick"><File path="Demos\Device\ClassDriver\Joystick\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Joystick\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Joystick\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.c"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.h"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.txt"></File><File path="Demos\Device\ClassDriver\Joystick\makefile"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.aps"></File></Folder><Folder name="Keyboard"><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.txt"></File><File path="Demos\Device\ClassDriver\Keyboard\makefile"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.aps"></File></Folder><Folder name="KeyboardMouse"><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.txt"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\makefile"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.aps"></File></Folder><Folder name="KeyboardMouseMultiReport"><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.txt"></File><File path="Demos\DeLine truncated <Project name="LUFA"><Folder name="Demos"><Folder name="Device"><Folder name="ClassDriver"><Folder name="AudioInput"><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.c"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.h"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.txt"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioInput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioInput\makefile"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.aps"></File></Folder><Folder name="AudioOutput"><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.txt"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioOutput\makefile"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.aps"></File></Folder><Folder name="DualVirtualSerial"><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.txt"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\LUFA DualVirtualSerial.inf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\makefile"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.aps"></File></Folder><Folder name="GenericHID"><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.c"></File><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.h"></File><File path="Demos\Device\ClassDriver\GenericHID\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.c"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.h"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.txt"></File><File path="Demos\Device\ClassDriver\GenericHID\makefile"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.aps"></File></Folder><Folder name="Joystick"><File path="Demos\Device\ClassDriver\Joystick\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Joystick\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Joystick\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.c"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.h"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.txt"></File><File path="Demos\Device\ClassDriver\Joystick\makefile"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.aps"></File></Folder><Folder name="Keyboard"><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.txt"></File><File path="Demos\Device\ClassDriver\Keyboard\makefile"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.aps"></File></Folder><Folder name="KeyboardMouse"><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.txt"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\makefile"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.aps"></File></Folder><Folder name="KeyboardMouseMultiReport"><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.txt"></File><File path="Demos\DeLine truncated
+25 -23
View File
@@ -155,28 +155,28 @@
} }
#if !defined(NO_SOF_EVENTS) #if !defined(NO_SOF_EVENTS)
/** Enables the device mode Start Of Frame events. When enabled, this causes the /** 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, * \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. * 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. * \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) ATTR_ALWAYS_INLINE;
static inline void USB_Device_EnableSOFEvents(void) static inline void USB_Device_EnableSOFEvents(void)
{ {
USB_INT_Enable(USB_INT_SOFI); USB_INT_Enable(USB_INT_SOFI);
} }
/** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the /** 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. * \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. * \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) ATTR_ALWAYS_INLINE;
static inline void USB_Device_DisableSOFEvents(void) static inline void USB_Device_DisableSOFEvents(void)
{ {
USB_INT_Disable(USB_INT_SOFI); USB_INT_Disable(USB_INT_SOFI);
} }
#endif #endif
/* Private Interface - For use in library only: */ /* 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) ATTR_ALWAYS_INLINE;
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
{ {
UDADDR = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F)); uint8_t Temp = (UDADDR & (1 << ADDEN)) | (Address & 0x7F);
UDADDR |= (1 << ADDEN);
UDADDR = Temp;
UDADDR = Temp | (1 << ADDEN);
} }
static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
@@ -359,20 +359,20 @@
static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE; static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_PLL_On(void) static inline void USB_PLL_On(void)
{ {
PLLCSR = USB_PLL_PSC; PLLCSR = USB_PLL_PSC;
PLLCSR |= (1 << PLLE); PLLCSR = (USB_PLL_PSC | (1 << PLLE));
} }
static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE; static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_PLL_Off(void) 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) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_PLL_IsReady(void) 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; 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) ATTR_ALWAYS_INLINE;
static inline void USB_Controller_Reset(void) static inline void USB_Controller_Reset(void)
{ {
const uint8_t Temp = USBCON; USBCON &= ~(1 << USBE);
USBCON |= (1 << USBE);
USBCON = (Temp & ~(1 << USBE));
USBCON = (Temp | (1 << USBE));
} }
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
+9 -9
View File
@@ -178,17 +178,17 @@
*/ */
enum USB_Control_Request_t enum USB_Control_Request_t
{ {
REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface REQ_GetStatus = 0, /**< Implemented in the library for device and endpoint recipients. Passed
* recipients. Passed to the user application for other recipients * to the user application for other recipients via the
* via the \ref EVENT_USB_Device_ControlRequest() event when received in * \ref EVENT_USB_Device_ControlRequest() event when received in
* device mode. */ * device mode. */
REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface REQ_ClearFeature = 1, /**< Implemented in the library for device and endpoint recipients. Passed
* recipients. Passed to the user application for other recipients * to the user application for other recipients via the
* via the \ref EVENT_USB_Device_ControlRequest() event when received in * \ref EVENT_USB_Device_ControlRequest() event when received in
* device mode. */ * device mode. */
REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface REQ_SetFeature = 3, /**< Implemented in the library for device and endpoint recipients. Passed
* recipients. Passed to the user application for other recipients * to the user application for other recipients via the
* via the \ref EVENT_USB_Device_ControlRequest() event when received in * \ref EVENT_USB_Device_ControlRequest() event when received in
* device mode. */ * device mode. */
REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
* to the user application for other recipients via the * to the user application for other recipients via the
+21 -21
View File
@@ -145,28 +145,28 @@
} }
#if !defined(NO_SOF_EVENTS) #if !defined(NO_SOF_EVENTS)
/** Enables the device mode Start Of Frame events. When enabled, this causes the /** 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, * \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. * 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. * \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) ATTR_ALWAYS_INLINE;
static inline void USB_Device_EnableSOFEvents(void) static inline void USB_Device_EnableSOFEvents(void)
{ {
USB_INT_Enable(USB_INT_SOFI); USB_INT_Enable(USB_INT_SOFI);
} }
/** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the /** 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. * \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. * \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) ATTR_ALWAYS_INLINE;
static inline void USB_Device_DisableSOFEvents(void) static inline void USB_Device_DisableSOFEvents(void)
{ {
USB_INT_Disable(USB_INT_SOFI); USB_INT_Disable(USB_INT_SOFI);
} }
#endif #endif
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */