Add device support preprocessor checks and use symbolic bit names in the UC3 platform clock management driver.
/* Includes: */
#include "../../../../Common/Common.h"
/* Includes: */
#include "../../../../Common/Common.h"
+ #include "../USBController.h"
#include "../StdDescriptors.h"
#include "../USBInterrupt.h"
#include "../Endpoint.h"
#include "../StdDescriptors.h"
#include "../USBInterrupt.h"
#include "../Endpoint.h"
}
#if !defined(NO_SOF_EVENTS)
}
#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: */
#if !defined(__DOXYGEN__)
/* Inline Functions: */
#endif
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Inline Functions: */
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ #if defined(USB_DEVICE_OPT_LOWSPEED)
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
static inline void USB_Device_SetLowSpeed(void)
{
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
static inline void USB_Device_SetLowSpeed(void)
{
\r
/* Includes: */\r
#include "../../../../Common/Common.h"\r
\r
/* Includes: */\r
#include "../../../../Common/Common.h"\r
+ #include "../USBController.h"\r
#include "../StdDescriptors.h"\r
#include "../USBInterrupt.h"\r
#include "../Endpoint.h"\r
#include "../StdDescriptors.h"\r
#include "../USBInterrupt.h"\r
#include "../Endpoint.h"\r
* USB interface should be initialized in full speed (12Mb/s) mode.\r
*/\r
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)\r
* USB interface should be initialized in full speed (12Mb/s) mode.\r
*/\r
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)\r
+ \r
+ #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || defined(__DOXYGEN__)\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in high speed (480Mb/s) mode.\r
+ */\r
+ #define USB_DEVICE_OPT_HIGHSPEED (1 << 1) \r
+ #endif\r
//@}\r
\r
#if (!defined(NO_INTERNAL_SERIAL) && \\r
//@}\r
\r
#if (!defined(NO_INTERNAL_SERIAL) && \\r
}\r
\r
#if !defined(NO_SOF_EVENTS)\r
}\r
\r
#if !defined(NO_SOF_EVENTS)\r
- /** Enables the device mode Start Of Frame events. When enabled, this causes the\r
- * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
- * at the start of each USB frame when enumerated in device mode.\r
- *\r
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
- */\r
- static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Device_EnableSOFEvents(void)\r
- {\r
- USB_INT_Enable(USB_INT_SOFI);\r
- }\r
+ /** Enables the device mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when enumerated in device mode.\r
+ *\r
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_EnableSOFEvents(void)\r
+ {\r
+ USB_INT_Enable(USB_INT_SOFI);\r
+ }\r
- /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the\r
- * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.\r
- *\r
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
- */\r
- static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Device_DisableSOFEvents(void)\r
- {\r
- USB_INT_Disable(USB_INT_SOFI);\r
- }\r
+ /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.\r
+ *\r
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_DisableSOFEvents(void)\r
+ {\r
+ USB_INT_Disable(USB_INT_SOFI);\r
+ }\r
#endif\r
\r
/* Private Interface - For use in library only: */\r
#endif\r
\r
/* Private Interface - For use in library only: */\r
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Device_SetLowSpeed(void)\r
{\r
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Device_SetLowSpeed(void)\r
{\r
- AVR32_USBB.UDCON.ls = true;\r
+ AVR32_USBB.UDCON.ls = true;\r
}\r
\r
static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Device_SetFullSpeed(void)\r
{\r
}\r
\r
static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Device_SetFullSpeed(void)\r
{\r
- AVR32_USBB.UDCON.ls = false;\r
+ AVR32_USBB.UDCON.ls = false;\r
+ #if defined(USB_DEVICE_OPT_HIGHSPEED)\r
+ AVR32_USBB.UDCON.spdconf = 3;\r
+ #endif\r
+ #if defined(USB_DEVICE_OPT_HIGHSPEED)\r
+ static inline void USB_Device_SetHighSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetHighSpeed(void)\r
+ {\r
+ AVR32_USBB.UDCON.ls = false;\r
+ AVR32_USBB.UDCON.spdconf = 0;\r
+ }\r
+ #endif\r
+\r
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)\r
{\r
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)\r
{\r
#endif\r
\r
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
#endif\r
\r
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
- USB_Device_SetLowSpeed();\r
+ {\r
+ USB_Device_SetLowSpeed();\r
+ }\r
- USB_Device_SetFullSpeed();\r
+ {\r
+ #if defined(USB_DEVICE_OPT_HIGHSPEED)\r
+ if (USB_Options & USB_DEVICE_OPT_HIGHSPEED) \r
+ USB_Device_SetHighSpeed();\r
+ else\r
+ USB_Device_SetFullSpeed();\r
+ #else\r
+ USB_Device_SetFullSpeed();\r
+ #endif \r
+ }\r
\r
USB_INT_Enable(USB_INT_VBUSTI);\r
\r
\r
USB_INT_Enable(USB_INT_VBUSTI);\r
\r
* generation module. This indicates that an external oscillator should be used directly instead of an\r
* internal PLL clock source.\r
*/\r
* generation module. This indicates that an external oscillator should be used directly instead of an\r
* internal PLL clock source.\r
*/\r
- #define USB_OPT_GCLK_SRC_OSC (1 << 1)\r
+ #define USB_OPT_GCLK_SRC_OSC (1 << 2)\r
\r
/** Selects one of the system's PLL oscillators as the input clock to the USB Generic Clock source\r
* generation module. This indicates that one of the device's PLL outputs should be used instead of an\r
* external oscillator source.\r
*/\r
\r
/** Selects one of the system's PLL oscillators as the input clock to the USB Generic Clock source\r
* generation module. This indicates that one of the device's PLL outputs should be used instead of an\r
* external oscillator source.\r
*/\r
- #define USB_OPT_GCLK_SRC_PLL (0 << 1)\r
+ #define USB_OPT_GCLK_SRC_PLL (0 << 2)\r
\r
/** Selects PLL or External Oscillator 0 as the USB Generic Clock source module input clock. */\r
\r
/** Selects PLL or External Oscillator 0 as the USB Generic Clock source module input clock. */\r
- #define USB_OPT_GCLK_CHANNEL_0 (1 << 2)\r
+ #define USB_OPT_GCLK_CHANNEL_0 (1 << 3)\r
\r
/** Selects PLL or External Oscillator 1 as the USB Generic Clock source module input clock. */\r
\r
/** Selects PLL or External Oscillator 1 as the USB Generic Clock source module input clock. */\r
- #define USB_OPT_GCLK_CHANNEL_1 (0 << 2)\r
+ #define USB_OPT_GCLK_CHANNEL_1 (0 << 3)\r
//@}\r
\r
/** \name Endpoint/Pipe Type Masks */\r
//@}\r
\r
/** \name Endpoint/Pipe Type Masks */\r
switch (Source)\r
{\r
case CLOCK_SRC_OSC0:\r
switch (Source)\r
{\r
case CLOCK_SRC_OSC0:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 0;\r
+ AVR32_PM.GCCTRL[Channel].pllsel = false;\r
AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
break;\r
case CLOCK_SRC_OSC1:\r
AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
break;\r
case CLOCK_SRC_OSC1:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 0;\r
+ AVR32_PM.GCCTRL[Channel].pllsel = false;\r
AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
break;\r
case CLOCK_SRC_PLL0:\r
AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
break;\r
case CLOCK_SRC_PLL0:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 1;\r
+ AVR32_PM.GCCTRL[Channel].pllsel = true;\r
AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
break;\r
case CLOCK_SRC_PLL1:\r
AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
break;\r
case CLOCK_SRC_PLL1:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 1;\r
+ AVR32_PM.GCCTRL[Channel].pllsel = true;\r
AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
break;\r
default:\r
AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
break;\r
default:\r
+ #if defined(AVR32_PM_MCCTRL_MCSEL_SLOW)\r
case CLOCK_SRC_SLOW_CLK:\r
case CLOCK_SRC_SLOW_CLK:\r
- AVR32_PM.MCCTRL.mcsel = 0;\r
+ AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_SLOW;\r
+ #endif\r
+ #if defined(AVR32_PM_MCCTRL_MCSEL_OSC0)\r
- AVR32_PM.MCCTRL.mcsel = 1;\r
+ AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_OSC0;\r
+ #endif\r
+ #if defined(AVR32_PM_MCCTRL_MCSEL_PLL0)\r
- AVR32_PM.MCCTRL.mcsel = 2;\r
+ AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_PLL0;\r
default:\r
return false;\r
}\r
default:\r
return false;\r
}\r