Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Generic Clock Management

Generic clocks are configurable clocks which run outside the system clock domain.

They are often connected to peripherals which have an asynchronous component running independently of the bus clock, e.g. USB controllers, low-power timers and RTCs, etc.

Note that not all platforms have support for generic clocks; on such platforms, this API will not be available.

Data Structures

struct  genclk_config
 Hardware representation of a set of generic clock parameters. More...
 

Enumerations

enum  genclk_source {
  GENCLK_SRC_OSC0 = 0,
  GENCLK_SRC_OSC1 = 1,
  GENCLK_SRC_PLL0 = 2,
  GENCLK_SRC_PLL1 = 3
}
 Generic clock source ID. More...
 

Functions

static void genclk_enable_config (unsigned int id, enum genclk_source src, unsigned int divider)
 Enable the configuration defined by src and divider for the generic clock identified by id. More...
 

Generic clock configuration

static void genclk_config_defaults (struct genclk_config *cfg, unsigned int id)
 Initialize cfg to the default configuration for the clock identified by id. More...
 
static void genclk_config_read (struct genclk_config *cfg, unsigned int id)
 Read the currently active configuration of the clock identified by id into cfg. More...
 
static void genclk_config_write (const struct genclk_config *cfg, unsigned int id)
 Activate the configuration cfg on the clock identified by id. More...
 
static void genclk_config_set_source (struct genclk_config *cfg, enum genclk_source src)
 Select a new source clock src in configuration cfg. More...
 
static void genclk_config_set_divider (struct genclk_config *cfg, unsigned int divider)
 Set a new divider in configuration cfg. More...
 
static void genclk_enable_source (enum genclk_source src)
 Enable the source clock src used by a generic clock. More...
 

Enabling and disabling Generic Clocks

static void genclk_enable (const struct genclk_config *cfg, unsigned int id)
 Activate the configuration cfg on the clock identified by id and enable it. More...
 
static void genclk_disable (unsigned int id)
 Disable the generic clock identified by id. More...
 

Chip-specific generic clock definitions

#define GENCLK_DIV_MAX   ((1 << AVR32_PM_GCCTRL_DIV_SIZE) * 2)
 Maximum divider supported by the generic clock implementation. More...
 

#define GENCLK_DIV_MAX   ((1 << AVR32_PM_GCCTRL_DIV_SIZE) * 2)

Maximum divider supported by the generic clock implementation.

The max division factor applicable to the source clock of the generic clock.

Referenced by genclk_config_set_divider().

Generic clock source ID.

Each generic clock may be generated from a different clock source. These are the available alternatives provided by the chip.

Enumerator
GENCLK_SRC_OSC0 

Oscillator 0.

GENCLK_SRC_OSC1 

Oscillator 1.

GENCLK_SRC_PLL0 

PLL 0.

GENCLK_SRC_PLL1 

PLL 1.

void genclk_config_defaults ( struct genclk_config cfg,
unsigned int  id 
)
inlinestatic

Initialize cfg to the default configuration for the clock identified by id.

References genclk_config::ctrl.

Referenced by genclk_enable_config(), and run_generic_clock_test().

void genclk_config_read ( struct genclk_config cfg,
unsigned int  id 
)
inlinestatic

Read the currently active configuration of the clock identified by id into cfg.

References genclk_config::ctrl.

void genclk_config_set_divider ( struct genclk_config cfg,
unsigned int  divider 
)
inlinestatic

Set a new divider in configuration cfg.

References Assert, genclk_config::ctrl, and GENCLK_DIV_MAX.

Referenced by genclk_enable_config(), and run_generic_clock_test().

void genclk_config_set_source ( struct genclk_config cfg,
enum genclk_source  src 
)
inlinestatic

Select a new source clock src in configuration cfg.

References Assert, and genclk_config::ctrl.

Referenced by genclk_enable_config(), and run_generic_clock_test().

void genclk_config_write ( const struct genclk_config cfg,
unsigned int  id 
)
inlinestatic

Activate the configuration cfg on the clock identified by id.

References genclk_config::ctrl.

void genclk_disable ( unsigned int  id)
inlinestatic

Disable the generic clock identified by id.

Referenced by cleanup_generic_clock_test(), and sysclk_disable_usb().

void genclk_enable ( const struct genclk_config cfg,
unsigned int  id 
)
inlinestatic

Activate the configuration cfg on the clock identified by id and enable it.

References genclk_config::ctrl.

Referenced by genclk_enable_config(), and run_generic_clock_test().

static void genclk_enable_config ( unsigned int  id,
enum genclk_source  src,
unsigned int  divider 
)
inlinestatic

Enable the configuration defined by src and divider for the generic clock identified by id.

Parameters
idThe ID of the generic clock.
srcThe source clock of the generic clock.
dividerThe divider used to generate the generic clock.

References genclk_config_defaults(), genclk_config_set_divider(), genclk_config_set_source(), genclk_enable(), and genclk_enable_source().

Referenced by main(), and sysclk_enable_usb().

void genclk_enable_source ( enum genclk_source  src)
inlinestatic