View on Github

Sysclock

System clock driver support for hardware abstraction layer.

This driver manage all clock providers.

Minimalist code

// init sysclock
sysclock_setClock(120000000); // set clock to 120MHz

uint32_t timer_freq = sysclock_periphFreq();

API

Global clock to set performance

sysclock_setClock

int sysclock_setClock(uint32_t fosc);

Sets the system clock of the CPU, the system clock may be different of CPU

Peripheral clocks and tree clocks

sysclock_periphFreq

uint32_t sysclock_periphFreq(SYSCLOCK_CLOCK busClock);

Gets the actual frequency on a particular peripheral bus clock

sysclock_setClockDiv

int sysclock_setClockDiv(SYSCLOCK_CLOCK busClock, uint16_t div);

Change the divisor of the busClock given as argument

Source clock

sysclock_sourceFreq

int32_t sysclock_sourceFreq(SYSCLOCK_SOURCE source);

Return the actual frequency of the clock source

sysclock_setSourceFreq

int sysclock_setSourceFreq(SYSCLOCK_SOURCE source, uint32_t freq);

Change a frequency of a source if it can be modified

sysclock_source

SYSCLOCK_SOURCE sysclock_source();

Return the actual clock source for system clock

sysclock_switchSourceTo

int sysclock_switchSourceTo(SYSCLOCK_SOURCE source);

Switch the source clock of sysclock to another one and wait for the change effective

Development status

TODO

Supported architectures

Header file : sysclock.h

Device specific

FRC OSCTUNE