Choco OS  V.0.16.9.0
Join to the chocolate world
(CLOCK-LLD) Clock Low Level Driver

System clock related operations. More...

Typedefs

typedef void(* oC_CLOCK_LLD_Interrupt_t) (oC_Frequency_t Frequency)
 type for storing interrupts pointers More...
 

Enumerations

Functions

oC_ErrorCode_t oC_CLOCK_LLD_TurnOnDriver (void)
 initializes the driver to work More...
 
oC_ErrorCode_t oC_CLOCK_LLD_TurnOffDriver (void)
 release the driver More...
 
oC_CLOCK_LLD_ClockSource_t oC_CLOCK_LLD_GetClockSource (void)
 returns source of the system clock More...
 
oC_Frequency_t oC_CLOCK_LLD_GetClockFrequency (void)
 returns frequency of the system clock More...
 
oC_Frequency_t oC_CLOCK_LLD_GetOscillatorFrequency (void)
 returns frequency of the oscillator More...
 
oC_Frequency_t oC_CLOCK_LLD_GetMaximumClockFrequency (void)
 returns maximum frequency permissible for the machine More...
 
oC_ErrorCode_t oC_CLOCK_LLD_SetClockConfiguredInterrupt (oC_CLOCK_LLD_Interrupt_t Interrupt)
 configures an interrupt for clock configured event More...
 
bool oC_CLOCK_LLD_DelayForMicroseconds (oC_UInt_t Microseconds)
 perform a delay for us More...
 
oC_ErrorCode_t oC_CLOCK_LLD_ConfigureInternalClock (oC_Frequency_t TargetFrequency, oC_Frequency_t PermissibleDifference)
 configures system clock in internal mode More...
 
oC_ErrorCode_t oC_CLOCK_LLD_ConfigureExternalClock (oC_Frequency_t TargetFrequency, oC_Frequency_t PermissibleDifference, oC_Frequency_t OscillatorFrequency)
 configures system clock to work in external mode More...
 
oC_ErrorCode_t oC_CLOCK_LLD_ConfigureHibernationClock (oC_Frequency_t TargetFrequency, oC_Frequency_t PermissibleDifference, oC_Frequency_t OscillatorFrequency)
 configures system clock to work in hibernation mode More...
 

Detailed Description

The driver is for operations that are based on the system clock, such as configuring it as internal/external, simple delaying operations by using special loops, and so on. This layer also provide an special interrupt, that occurs, when the system clock is reconfigured, what can be used for example for reconfiguring drivers that are clock related, such as #SPI or #UART.
The module must be turned on before usage by using the function oC_CLOCK_LLD_TurnOnDriver. When it is not needed anymore, the oC_CLOCK_LLD_TurnOffDriver function can be used for turning it off. The default state will be restored (clock will be configured to work in default state).
The clock can be configured to work with internal or external oscillator by functions oC_CLOCK_LLD_ConfigureInternalClock and oC_CLOCK_LLD_ConfigureExternalClock. There is also a possibility to configure extra external hibernation oscillator by function oC_CLOCK_LLD_ConfigureHibernationClock. Every time, when the clock is configured, the special interrupt named Clock Configured Interrupt occurs. The handler of this interrupt can be set by function oC_CLOCK_LLD_SetClockConfiguredInterrupt, but it can be done only once after enabling of the module.
The module provide also a function for delay operations. It is called oC_CLOCK_LLD_DelayForMicroseconds and it allow to block a CPU for the time given in microseconds.

Typedef Documentation

typedef void(* oC_CLOCK_LLD_Interrupt_t) (oC_Frequency_t Frequency)
Parameters
FrequencyNew frequency, that was configured

The type is for storing pointers to interrupts for the CLOCK-LLD module.

Definition at line 88 of file oc_clock_lld.h.

Enumeration Type Documentation

The type is for storing source of the system clock.

Enumerator
oC_CLOCK_LLD_ClockSource_Internal 

an internal clock source is used

oC_CLOCK_LLD_ClockSource_External 

an external source of the clock is used

Definition at line 73 of file oc_clock_lld.h.

Function Documentation

oC_ErrorCode_t oC_CLOCK_LLD_ConfigureExternalClock ( oC_Frequency_t  TargetFrequency,
oC_Frequency_t  PermissibleDifference,
oC_Frequency_t  OscillatorFrequency 
)
Parameters
TargetFrequencyThe frequency to achieve for the system clock.
PermissibleDifferenceMaximum difference between real frequency and the wanted frequency that is acceptable by the user
OscillatorFrequencyThe frequency of the external oscillator that is connected to the machine
Returns
code of error or #oC_ErrorCode_None if success
Note
stm32f7 notes:
lm4f notes:

Definition at line 405 of file oc_clock_lld.c.

oC_ErrorCode_t oC_CLOCK_LLD_ConfigureHibernationClock ( oC_Frequency_t  TargetFrequency,
oC_Frequency_t  PermissibleDifference,
oC_Frequency_t  OscillatorFrequency 
)
Parameters
TargetFrequencyThe frequency to achieve for the system clock.
PermissibleDifferenceMaximum difference between real frequency and the wanted frequency that is acceptable by the user
OscillatorFrequencyThe frequency of the external oscillator connected to the correct pins in the machine
Returns
code of error
Note
stm32f7 notes: not implemented - it's only turn on power for hibernation clock
lm4f notes:

Definition at line 510 of file oc_clock_lld.c.

oC_ErrorCode_t oC_CLOCK_LLD_ConfigureInternalClock ( oC_Frequency_t  TargetFrequency,
oC_Frequency_t  PermissibleDifference 
)

The function configures the system clock to work with internal oscillator with given frequency.

Parameters
TargetFrequencyThe frequency to achieve for the system clock.
PermissibleDifferenceMaximum difference between real frequency and the wanted frequency that is acceptable by the user
Returns
code of error or #oC_ErrorCode_None if success
Note
stm32f7 notes:
lm4f notes:

Definition at line 312 of file oc_clock_lld.c.

bool oC_CLOCK_LLD_DelayForMicroseconds ( oC_UInt_t  Microseconds)

The function is for performing a delay in microseconds. It is important, that this function should be implemented as simple as possible (for example by using a loop) to provide shortest time that is possible. Note, that when this function is used, there is no guarantee, that some other system task will not interrupt this process, so there is a possible that this delay will stay for more time that expected. It is recommended only for short delays, that can not be achieved by using other delay functions.

Note
It uses clock frequency to count number of cycles, that should be delayed.
Parameters
MicrosecondsNumber of microseconds to delay
Returns
true if success, false if this function is not implemented already in the target machine.
Note
stm32f7 notes:
lm4f notes:

Definition at line 297 of file oc_clock_lld.c.

oC_Frequency_t oC_CLOCK_LLD_GetClockFrequency ( void  )

The function is for reading actual clock frequency configuration

Returns
configured frequency of the system clock
Note
stm32f7 notes:
lm4f notes:

Definition at line 237 of file oc_clock_lld.c.

oC_CLOCK_LLD_ClockSource_t oC_CLOCK_LLD_GetClockSource ( void  )

The function returns actual configured clock source.

Returns
source of the system clock
Note
stm32f7 notes:
lm4f notes:

Definition at line 226 of file oc_clock_lld.c.

oC_Frequency_t oC_CLOCK_LLD_GetMaximumClockFrequency ( void  )

The function returns maximum frequency that is possible for the given machine.

Note
stm32f7 notes:
lm4f notes:

Definition at line 259 of file oc_clock_lld.c.

oC_Frequency_t oC_CLOCK_LLD_GetOscillatorFrequency ( void  )
Returns
configured oscillator frequency
Note
stm32f7 notes:

Definition at line 248 of file oc_clock_lld.c.

oC_ErrorCode_t oC_CLOCK_LLD_SetClockConfiguredInterrupt ( oC_CLOCK_LLD_Interrupt_t  Interrupt)

The function is for setting a function handler for an interrupt that occurs, when the system clock is configured. The handler is called every time, when some module will change the clock configuration. It can be useful for some frequency related modules, such as #UART and #SPI, that use a system clock for its internal transmission clocks.

Note
The interrupt can be set only once after turning on the module! When it is needed to reconfigure it, the module must be restarted.
Parameters
InterruptPointer to the interrupt handler function
Returns
code of error, or #oC_ErrorCode_None if success
Note
stm32f7 notes:
lm4f notes:

Definition at line 270 of file oc_clock_lld.c.

oC_ErrorCode_t oC_CLOCK_LLD_TurnOffDriver ( void  )

The function is for releasing resources needed for the driver. The main driver should call it every time, when it is turned off. This function should restore default states in all resources, that are handled and was initialized by the driver. It must not protect by itself again turning off the driver when it is not turned on.

Returns
code of error, or #oC_ErrorCode_None if there is no error.
Note
stm32f7 notes:
lm4f notes:

Definition at line 197 of file oc_clock_lld.c.

oC_ErrorCode_t oC_CLOCK_LLD_TurnOnDriver ( void  )

The function is for initializing the low level driver. It will be called every time when the driver will turned on. There is no need to protect again returning because the main driver should protect it by itself.

Returns
code of error, or #oC_ErrorCode_None if there is no error.
Note
stm32f7 notes:
lm4f notes:

Definition at line 160 of file oc_clock_lld.c.