\r
#define ENDPOINT_DETAILS_MAXEP 16\r
\r
+ /* Inline Functions: */\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
+ ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while (CheckBytes < Bytes)\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << USB_EP_SIZE_gp);\r
+ }\r
+\r
/* Function Prototypes: */\r
void Endpoint_ClearEndpoints(void);\r
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
* should be initialized in the OUT direction - i.e. data flows from host to device.\r
*/\r
- #define ENDPOINT_DIR_OUT 0 // TODO\r
+ #define ENDPOINT_DIR_OUT false\r
\r
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
* should be initialized in the IN direction - i.e. data flows from device to host.\r
*/\r
- #define ENDPOINT_DIR_IN 0 // TODO\r
+ #define ENDPOINT_DIR_IN true\r
//@}\r
\r
/** \name Endpoint Bank Mode Masks */\r
* in slower transfers as only one USB device (the AVR or the host) can access the endpoint's\r
* bank at the one time.\r
*/\r
- #define ENDPOINT_BANK_SINGLE 0 // TODO\r
+ #define ENDPOINT_BANK_SINGLE 0\r
\r
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
* that the endpoint should have two banks, which requires more USB FIFO memory but results\r
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other\r
* accesses the second bank.\r
*/\r
- #define ENDPOINT_BANK_DOUBLE 0 // TODO\r
+ #define ENDPOINT_BANK_DOUBLE USB_EP_BANK_bm\r
//@}\r
\r
#if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
#define _UC3_CLOCK_MANAGEMENT_H_\r
\r
/* Includes: */\r
- #include <avr32/io.h>\r
- #include <stdbool.h>\r
- #include <stdint.h>\r
-\r
#include <LUFA/Common/Common.h>\r
\r
/* Enable C linkage for C++ Compilers: */\r
/* Public Interface - May be used in end-application: */\r
/* Macros: */\r
/** Enum for the possible external oscillator types. */\r
- enum Extern_OSC_ClockTypes_t\r
+ enum UC3_Extern_OSC_ClockTypes_t\r
{\r
- EXOSC_MODE_CLOCK = 0, /**< External clock (non-crystal) mode. */\r
- EXOSC_MODE_900KHZ_MAX = 1, /**< External crystal oscillator equal to or slower than 900KHz. */\r
- EXOSC_MODE_3MHZ_MAX = 2, /**< External crystal oscillator equal to or slower than 3MHz. */\r
- EXOSC_MODE_8MHZ_MAX = 3, /**< External crystal oscillator equal to or slower than 8MHz. */\r
- EXOSC_MODE_8MHZ_OR_MORE = 4, /**< External crystal oscillator equal to or faster than 8MHz. */ \r
+ EXOSC_MODE_CLOCK = AVR32_PM_OSCCTRL0_MODE_EXT_CLOCK, /**< External clock (non-crystal) mode. */\r
+ EXOSC_MODE_900KHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G0, /**< External crystal oscillator equal to or slower than 900KHz. */\r
+ EXOSC_MODE_3MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G1, /**< External crystal oscillator equal to or slower than 3MHz. */\r
+ EXOSC_MODE_8MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G2, /**< External crystal oscillator equal to or slower than 8MHz. */\r
+ EXOSC_MODE_8MHZ_OR_MORE = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G3, /**< External crystal oscillator equal to or faster than 8MHz. */ \r
};\r
\r
/** Enum for the possible external oscillator statup times. */\r
- enum Extern_OSC_ClockStartup_t\r
+ enum UC3_Extern_OSC_ClockStartup_t\r
{\r
- EXOSC_START_0CLK = 0, /**< Immediate startup, no delay. */\r
- EXOSC_START_64CLK = 1, /**< Wait 64 clock cyles before startup for stability. */\r
- EXOSC_START_128CLK = 2, /**< Wait 128 clock cyles before startup for stability. */\r
- EXOSC_START_2048CLK = 3, /**< Wait 2048 clock cyles before startup for stability. */\r
- EXOSC_START_4096CLK = 4, /**< Wait 4096 clock cyles before startup for stability. */\r
- EXOSC_START_8192CLK = 5, /**< Wait 8192 clock cyles before startup for stability. */\r
- EXOSC_START_16384CLK = 6, /**< Wait 16384 clock cyles before startup for stability. */\r
+ EXOSC_START_0CLK = AVR32_PM_OSCCTRL0_STARTUP_0_RCOSC, /**< Immediate startup, no delay. */\r
+ EXOSC_START_64CLK = AVR32_PM_OSCCTRL0_STARTUP_64_RCOSC, /**< Wait 64 clock cyles before startup for stability. */\r
+ EXOSC_START_128CLK = AVR32_PM_OSCCTRL0_STARTUP_128_RCOSC, /**< Wait 128 clock cyles before startup for stability. */\r
+ EXOSC_START_2048CLK = AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC, /**< Wait 2048 clock cyles before startup for stability. */\r
+ EXOSC_START_4096CLK = AVR32_PM_OSCCTRL0_STARTUP_4096_RCOSC, /**< Wait 4096 clock cyles before startup for stability. */\r
+ EXOSC_START_8192CLK = AVR32_PM_OSCCTRL0_STARTUP_8192_RCOSC, /**< Wait 8192 clock cyles before startup for stability. */\r
+ EXOSC_START_16384CLK = AVR32_PM_OSCCTRL0_STARTUP_16384_RCOSC, /**< Wait 16384 clock cyles before startup for stability. */\r
};\r
\r
/** Enum for the possible module clock sources. */\r
- enum System_ClockSource_t\r
+ enum UC3_System_ClockSource_t\r
{\r
CLOCK_SRC_SLOW_CLK = 0, /**< Clock sourced from the internal slow clock. */\r
CLOCK_SRC_OSC0 = 1, /**< Clock sourced from the Oscillator 0 clock. */\r
* the oscillator is ready for use.\r
*\r
* \param[in] Channel Index of the external oscillator to start.\r
- * \param[in] Type Type of clock attached to the given oscillator channel, a value from \ref Extern_OSC_ClockTypes_t.\r
- * \param[in] Startup Statup time of the external oscillator, a value from \ref Extern_OSC_ClockStartup_t.\r
+ * \param[in] Type Type of clock attached to the given oscillator channel, a value from \ref UC3_Extern_OSC_ClockTypes_t.\r
+ * \param[in] Startup Statup time of the external oscillator, a value from \ref UC3_Extern_OSC_ClockStartup_t.\r
*\r
* \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified.\r
*/\r
/** Starts the given PLL of the UC3 microcontroller, with the given options. This routine blocks until the PLL is ready for use.\r
*\r
* \param[in] Channel Index of the PLL to start.\r
- * \param[in] Source Clock source for the PLL, a value from \ref System_ClockSource_t.\r
+ * \param[in] Source Clock source for the PLL, a value from \ref UC3_System_ClockSource_t.\r
* \param[in] SourceFreq Frequency of the PLL's clock source, in Hz.\r
* \param[in] Frequency Target frequency of the PLL's output.\r
*\r
/** Starts the given Generic Clock of the UC3 microcontroller, with the given options.\r
*\r
* \param[in] Channel Index of the Generic Clock to start.\r
- * \param[in] Source Clock source for the Generic Clock, a value from \ref System_ClockSource_t.\r
+ * \param[in] Source Clock source for the Generic Clock, a value from \ref UC3_System_ClockSource_t.\r
* \param[in] SourceFreq Frequency of the Generic Clock's clock source, in Hz.\r
* \param[in] Frequency Target frequency of the Generic Clock's output.\r
*\r
*\r
* This function will configure the FLASH controller's wait states automatically to suit the given clock source.\r
*\r
- * \param[in] Source Clock source for the CPU core, a value from \ref System_ClockSource_t.\r
+ * \param[in] Source Clock source for the CPU core, a value from \ref UC3_System_ClockSource_t.\r
* \param[in] SourceFreq Frequency of the CPU core's clock source, in Hz.\r
*\r
* \return Boolean \c true if the CPU core clock was sucessfully altered, \c false if invalid parameters specified.\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Module Clock Driver for the AVR USB XMEGA microcontrollers.\r
+ *\r
+ * Clock management driver for the AVR USB XMEGA microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ */\r
+\r
+/** \ingroup Group_PlatformDrivers\r
+ * \defgroup Group_PlatformDrivers_XMEGAClocks AVR USB XMEGA Clock Management Driver - LUFA/Platform/XMEGA/ClockManagement.h\r
+ * \brief Module Clock Driver for the AVR USB XMEGA microcontrollers.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Clock management driver for the AVR USB XMEGA microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * #include <LUFA/Platform/XMEGA/ClockManagement.h>\r
+ *\r
+ * void main(void)\r
+ * {\r
+ * [TODO]\r
+ * }\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _XMEGA_CLOCK_MANAGEMENT_H_\r
+#define _XMEGA_CLOCK_MANAGEMENT_H_\r
+\r
+ /* Includes: */\r
+ #include <LUFA/Common/Common.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Enum for the possible external oscillator types. */\r
+ enum XMEGA_Extern_OSC_ClockTypes_t\r
+ {\r
+ EXOSC_MODE_2MHZ_MAX = OSC_FRQRANGE_04TO2_gc, /**< External crystal oscillator equal to or slower than 2MHz. */\r
+ EXOSC_MODE_9MHZ_MAX = OSC_FRQRANGE_2TO9_gc, /**< External crystal oscillator equal to or slower than 9MHz. */\r
+ EXOSC_MODE_12MHZ_MAX = OSC_FRQRANGE_9TO12_gc, /**< External crystal oscillator equal to or slower than 12MHz. */\r
+ EXOSC_MODE_16MHZ_MAX = OSC_FRQRANGE_12TO16_gc, /**< External crystal oscillator equal to or slower than 16MHz. */ \r
+ };\r
+\r
+ /** Enum for the possible external oscillator statup times. */\r
+ enum XMEGA_Extern_OSC_ClockStartup_t\r
+ {\r
+ EXOSC_START_6CLK = OSC_XOSCSEL_EXTCLK_gc, /**< Wait 6 clock cycles before startup (external clock). */\r
+ EXOSC_START_32KCLK = OSC_XOSCSEL_32KHz_gc, /**< Wait 32K clock cycles before startup (32.768KHz crystal). */\r
+ EXOSC_START_256CLK = OSC_XOSCSEL_XTAL_256CLK_gc, /**< Wait 256 clock cycles before startup. */\r
+ EXOSC_START_1KCLK = OSC_XOSCSEL_XTAL_1KCLK_gc, /**< Wait 1K clock cycles before startup. */\r
+ EXOSC_START_16KCLK = OSC_XOSCSEL_XTAL_16KCLK_gc, /**< Wait 16K clock cycles before startup. */\r
+ };\r
+ \r
+ /** Enum for the possible module clock sources. */\r
+ enum XMEGA_System_ClockSource_t\r
+ {\r
+ CLOCK_SRC_INT_RC2MHZ = 0, /**< Clock sourced from the Internal 2MHz RC Oscillator clock. */\r
+ CLOCK_SRC_INT_RC32MHZ = 1, /**< Clock sourced from the Internal 32MHz RC Oscillator clock. */\r
+ CLOCK_SRC_INT_RC32KHZ = 2, /**< Clock sourced from the Internal 32KHz RC Oscillator clock. */\r
+ CLOCK_SRC_XOSC = 3, /**< Clock sourced from the External Oscillator clock. */\r
+ CLOCK_SRC_PLL = 4, /**< Clock sourced from the Internal PLL clock. */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Starts the given external oscillator of the UC3 microcontroller, with the given options. This routine blocks until\r
+ * the oscillator is ready for use.\r
+ *\r
+ * \param[in] Channel Index of the external oscillator to start.\r
+ * \param[in] Type Type of clock attached to the given oscillator channel, a value from \ref XMEGA_Extern_OSC_ClockTypes_t.\r
+ * \param[in] Startup Statup time of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockStartup_t.\r
+ *\r
+ * \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline uint8_t AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup)\r
+ {\r
+ return false; // TODO\r
+ }\r
+\r
+ /** Stops the given external oscillator of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the external oscillator to stop.\r
+ */\r
+ static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel)\r
+ {\r
+ return; // TODO\r
+ }\r
+\r
+ /** Starts the given PLL of the UC3 microcontroller, with the given options. This routine blocks until the PLL is ready for use.\r
+ *\r
+ * \param[in] Channel Index of the PLL to start.\r
+ * \param[in] Source Clock source for the PLL, a value from \ref XMEGA_System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the PLL's clock source, in Hz.\r
+ * \param[in] Frequency Target frequency of the PLL's output.\r
+ *\r
+ * \return Boolean \c true if the PLL was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StartPLL(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StartPLL(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency)\r
+ {\r
+ return false; // TODO\r
+ }\r
+\r
+ /** Stops the given PLL of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the PLL to stop.\r
+ */\r
+ static inline void AVR32CLK_StopPLL(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopPLL(const uint8_t Channel)\r
+ {\r
+ // TODO\r
+ }\r
+ \r
+ /** Starts the given Generic Clock of the UC3 microcontroller, with the given options.\r
+ *\r
+ * \param[in] Channel Index of the Generic Clock to start.\r
+ * \param[in] Source Clock source for the Generic Clock, a value from \ref XMEGA_System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the Generic Clock's clock source, in Hz.\r
+ * \param[in] Frequency Target frequency of the Generic Clock's output.\r
+ *\r
+ * \return Boolean \c true if the Generic Clock was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency)\r
+ {\r
+ return false; // TODO\r
+ }\r
+ \r
+ /** Stops the given generic clock of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the generic clock to stop.\r
+ */\r
+ static inline void AVR32CLK_StopGenericClock(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopGenericClock(const uint8_t Channel)\r
+ {\r
+ // TODO\r
+ }\r
+ \r
+ /** Sets the clock source for the main microcontroller core. The given clock source should be configured\r
+ * and ready for use before this function is called.\r
+ *\r
+ * This function will configure the FLASH controller's wait states automatically to suit the given clock source.\r
+ *\r
+ * \param[in] Source Clock source for the CPU core, a value from \ref XMEGA_System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the CPU core's clock source, in Hz.\r
+ *\r
+ * \return Boolean \c true if the CPU core clock was sucessfully altered, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source,\r
+ const uint32_t SourceFreq) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source,\r
+ const uint32_t SourceFreq)\r
+ {\r
+ return false // TODO\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r