- /* Macros: */\r
- enum Extern_OSC_ClockStartup_t\r
- {\r
- EXOSC_START_0CLK = 0,\r
- EXOSC_START_64CLK = 1,\r
- EXOSC_START_128CLK = 2,\r
- EXOSC_START_2048CLK = 3,\r
- EXOSC_START_4096CLK = 4,\r
- EXOSC_START_8192CLK = 5,\r
- EXOSC_START_16384CLK = 6,\r
- };\r
- \r
- enum Extern_OSC_ClockMode_t\r
- {\r
- EXOSC_MODE_CLOCK = 0,\r
- EXOSC_MODE_900KHZ_MAX = 1,\r
- EXOSC_MODE_3MHZ_MAX = 2,\r
- EXOSC_MODE_8MHZ_MAX = 3,\r
- EXOSC_MODE_8MHZ_OR_MORE = 4, \r
- };\r
- \r
- enum\r
- {\r
- CLOCK_SRC_SLOW_CLK = 0,\r
- CLOCK_SRC_OSC0 = 1,\r
- CLOCK_SRC_OSC1 = 2,\r
- CLOCK_SRC_PLL0 = 3,\r
- CLOCK_SRC_PLL1 = 4,\r
- };\r
-\r
- /* Inline Functions: */\r
- static inline bool AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
- const uint8_t Type,\r
- const uint8_t Startup)\r
- {\r
- AVR32_PM.OSCCTRL0.startup = Startup;\r
- AVR32_PM.OSCCTRL0.mode = Type;\r
- AVR32_PM.mcctrl |= (1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
-\r
- while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_OSC0RDY_OFFSET + Channel))));\r
- return true;\r
- }\r
-\r
- static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel)\r
- {\r
- AVR32_PM.mcctrl &= ~(1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
- }\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)\r
- {\r
- switch (Source)\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 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
+ };\r
+\r
+ /** Enum for the possible external oscillator statup times. */\r
+ enum 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
+ };\r
+ \r
+ /** Enum for the possible module clock sources. */\r
+ enum 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
+ CLOCK_SRC_OSC1 = 2, /**< Clock sourced from the Oscillator 1 clock. */\r
+ CLOCK_SRC_PLL0 = 3, /**< Clock sourced from the PLL 0 clock. */\r
+ CLOCK_SRC_PLL1 = 4, /**< Clock sourced from the PLL 1 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 Extern_OSC_ClockTypes_t.\r
+ * \param[in] Startup Statup time of the external oscillator, a value from \ref 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 void AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup)\r
+ {\r
+ switch (Channel)\r
+ {\r
+ case 0:\r
+ AVR32_PM.OSCCTRL0.startup = Startup;\r
+ AVR32_PM.OSCCTRL0.mode = Type;\r
+ break;\r
+ case 1:\r
+ AVR32_PM.OSCCTRL1.startup = Startup;\r
+ AVR32_PM.OSCCTRL1.mode = Type;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ AVR32_PM.mcctrl |= (1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
+\r
+ while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_OSC0RDY_OFFSET + Channel))));\r
+ return true;\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