LUFA Library  120219
Clock Management Driver - LUFA/Platform/UC3/ClockManagement.h

Module Clock Driver for the AVR32 UC3 microcontrollers. More...

Enumerations

enum  UC3_Extern_OSC_ClockTypes_t {
  EXOSC_MODE_CLOCK = AVR32_PM_OSCCTRL0_MODE_EXT_CLOCK,
  EXOSC_MODE_900KHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G0,
  EXOSC_MODE_3MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G1,
  EXOSC_MODE_8MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G2,
  EXOSC_MODE_8MHZ_OR_MORE = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G3
}
enum  UC3_Extern_OSC_ClockStartup_t {
  EXOSC_START_0CLK = AVR32_PM_OSCCTRL0_STARTUP_0_RCOSC,
  EXOSC_START_64CLK = AVR32_PM_OSCCTRL0_STARTUP_64_RCOSC,
  EXOSC_START_128CLK = AVR32_PM_OSCCTRL0_STARTUP_128_RCOSC,
  EXOSC_START_2048CLK = AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC,
  EXOSC_START_4096CLK = AVR32_PM_OSCCTRL0_STARTUP_4096_RCOSC,
  EXOSC_START_8192CLK = AVR32_PM_OSCCTRL0_STARTUP_8192_RCOSC,
  EXOSC_START_16384CLK = AVR32_PM_OSCCTRL0_STARTUP_16384_RCOSC
}
enum  UC3_System_ClockSource_t {
  CLOCK_SRC_SLOW_CLK = 0,
  CLOCK_SRC_OSC0 = 1,
  CLOCK_SRC_OSC1 = 2,
  CLOCK_SRC_PLL0 = 3,
  CLOCK_SRC_PLL1 = 4
}

Functions

static bool AVR32CLK_StartExternalOscillator (const uint8_t Channel, const uint8_t Type, const uint8_t Startup) ATTR_ALWAYS_INLINE
static void AVR32CLK_StopExternalOscillator (const uint8_t Channel) ATTR_ALWAYS_INLINE
static bool AVR32CLK_StartPLL (const uint8_t Channel, const uint8_t Source, const uint32_t SourceFreq, const uint32_t Frequency) ATTR_ALWAYS_INLINE
static void AVR32CLK_StopPLL (const uint8_t Channel) ATTR_ALWAYS_INLINE
static bool AVR32CLK_StartGenericClock (const uint8_t Channel, const uint8_t Source, const uint32_t SourceFreq, const uint32_t Frequency) ATTR_ALWAYS_INLINE
static void AVR32CLK_StopGenericClock (const uint8_t Channel) ATTR_ALWAYS_INLINE
static bool AVR32CLK_SetCPUClockSource (const uint8_t Source, const uint32_t SourceFreq) ATTR_ALWAYS_INLINE

Detailed Description

Module Source Dependencies

The following files must be built with any user project that uses this module:

Module Description

Clock management driver for the AVR32 UC3 microcontrollers. This driver allows for the configuration of the various clocks within the device to clock the various peripherals.

Usage Example:

        #include <LUFA/Platform/UC3/ClockManagement.h>

        void main(void)
        {
            // Start the master external oscillator which will be used as the main clock reference
            AVR32CLK_StartExternalOscillator(0, EXOSC_MODE_8MHZ_OR_MORE, EXOSC_START_0CLK);

            // Start the PLL for the CPU clock, switch CPU to it
            AVR32CLK_StartPLL(0, CLOCK_SRC_OSC0, 12000000, F_CPU);
            AVR32CLK_SetCPUClockSource(CLOCK_SRC_PLL0, F_CPU);

            // Start the PLL for the USB Generic Clock module
            AVR32CLK_StartPLL(1, CLOCK_SRC_OSC0, 12000000, 48000000);
        }

Enumeration Type Documentation

Enum for the possible external oscillator statup times.

Enumerator:
EXOSC_START_0CLK 

Immediate startup, no delay.

EXOSC_START_64CLK 

Wait 64 clock cyles before startup for stability.

EXOSC_START_128CLK 

Wait 128 clock cyles before startup for stability.

EXOSC_START_2048CLK 

Wait 2048 clock cyles before startup for stability.

EXOSC_START_4096CLK 

Wait 4096 clock cyles before startup for stability.

EXOSC_START_8192CLK 

Wait 8192 clock cyles before startup for stability.

EXOSC_START_16384CLK 

Wait 16384 clock cyles before startup for stability.

Enum for the possible external oscillator types.

Enumerator:
EXOSC_MODE_CLOCK 

External clock (non-crystal) mode.

EXOSC_MODE_900KHZ_MAX 

External crystal oscillator equal to or slower than 900KHz.

EXOSC_MODE_3MHZ_MAX 

External crystal oscillator equal to or slower than 3MHz.

EXOSC_MODE_8MHZ_MAX 

External crystal oscillator equal to or slower than 8MHz.

EXOSC_MODE_8MHZ_OR_MORE 

External crystal oscillator equal to or faster than 8MHz.

Enum for the possible module clock sources.

Enumerator:
CLOCK_SRC_SLOW_CLK 

Clock sourced from the internal slow clock.

CLOCK_SRC_OSC0 

Clock sourced from the Oscillator 0 clock.

CLOCK_SRC_OSC1 

Clock sourced from the Oscillator 1 clock.

CLOCK_SRC_PLL0 

Clock sourced from the PLL 0 clock.

CLOCK_SRC_PLL1 

Clock sourced from the PLL 1 clock.


Function Documentation

static bool AVR32CLK_SetCPUClockSource ( const uint8_t  Source,
const uint32_t  SourceFreq 
) [inline, static]

Sets the clock source for the main microcontroller core. The given clock source should be configured and ready for use before this function is called.

This function will configure the FLASH controller's wait states automatically to suit the given clock source.

Parameters:
[in]SourceClock source for the CPU core, a value from UC3_System_ClockSource_t.
[in]SourceFreqFrequency of the CPU core's clock source, in Hz.
Returns:
Boolean true if the CPU core clock was sucessfully altered, false if invalid parameters specified.
static bool AVR32CLK_StartExternalOscillator ( const uint8_t  Channel,
const uint8_t  Type,
const uint8_t  Startup 
) [inline, static]

Starts the given external oscillator of the UC3 microcontroller, with the given options. This routine blocks until the oscillator is ready for use.

Parameters:
[in]ChannelIndex of the external oscillator to start.
[in]TypeType of clock attached to the given oscillator channel, a value from UC3_Extern_OSC_ClockTypes_t.
[in]StartupStatup time of the external oscillator, a value from UC3_Extern_OSC_ClockStartup_t.
Returns:
Boolean true if the external oscillator was successfully started, false if invalid parameters specified.
static bool AVR32CLK_StartGenericClock ( const uint8_t  Channel,
const uint8_t  Source,
const uint32_t  SourceFreq,
const uint32_t  Frequency 
) [inline, static]

Starts the given Generic Clock of the UC3 microcontroller, with the given options.

Parameters:
[in]ChannelIndex of the Generic Clock to start.
[in]SourceClock source for the Generic Clock, a value from UC3_System_ClockSource_t.
[in]SourceFreqFrequency of the Generic Clock's clock source, in Hz.
[in]FrequencyTarget frequency of the Generic Clock's output.
Returns:
Boolean true if the Generic Clock was successfully started, false if invalid parameters specified.
static bool AVR32CLK_StartPLL ( const uint8_t  Channel,
const uint8_t  Source,
const uint32_t  SourceFreq,
const uint32_t  Frequency 
) [inline, static]

Starts the given PLL of the UC3 microcontroller, with the given options. This routine blocks until the PLL is ready for use.

Note:
The output frequency must be equal to or greater than the source frequency.
Parameters:
[in]ChannelIndex of the PLL to start.
[in]SourceClock source for the PLL, a value from UC3_System_ClockSource_t.
[in]SourceFreqFrequency of the PLL's clock source, in Hz.
[in]FrequencyTarget frequency of the PLL's output.
Returns:
Boolean true if the PLL was successfully started, false if invalid parameters specified.
static void AVR32CLK_StopExternalOscillator ( const uint8_t  Channel) [inline, static]

Stops the given external oscillator of the UC3 microcontroller.

Parameters:
[in]ChannelIndex of the external oscillator to stop.
static void AVR32CLK_StopGenericClock ( const uint8_t  Channel) [inline, static]

Stops the given generic clock of the UC3 microcontroller.

Parameters:
[in]ChannelIndex of the generic clock to stop.
static void AVR32CLK_StopPLL ( const uint8_t  Channel) [inline, static]

Stops the given PLL of the UC3 microcontroller.

Parameters:
[in]ChannelIndex of the PLL to stop.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines