EVE 1.0
Clock management
Collaboration diagram for Clock management:

Data Structures

struct  clk_lock_t
 

Macros

#define CLK_PERSISTENT(x)   ((enum clk_level_t) ((x) | 0x80))
 
#define CLK_LOCK_INIT(l, clk)
 
#define CLK_LOCK(clk)   clk_lock(&clk)
 
#define CLK_UNLOCK(clk)   clk_unlock(&clk)
 
#define CLK_AUTO_LOCK(l)
 
#define DECLARE_CLK_LOCK(l, clk)   static struct clk_lock_t clk = CLK_LOCK_INIT(l, clk)
 

Enumerations

Functions

void clk_init (void)
 
void clk_relax (void)
 
void clk_lock (struct clk_lock_t *clk)
 
void clk_unlock (struct clk_lock_t *clk)
 

Detailed Description

EVE clock management framework.

Macro Definition Documentation

#define CLK_PERSISTENT (   x)    ((enum clk_level_t) ((x) | 0x80))

Indicates that the given clock should be kept running when system is in the suspend state.

The modifier can be applied to level field of the clk_lock_t instantiation to indicate that the clock should not be switched off at system suspend.

Usage:

1 struct clk_lock_t MyPersistentClockLock = CLK_LOCK_INIT(CLK_PERSISTENT(CLK_LEVEL_XO), MyPersistentClockLock);
Parameters
xThe actual clock level, clk_level_t.

Definition at line 66 of file clk.h.

#define CLK_LOCK_INIT (   l,
  clk 
)
Value:
{ \
.link = DLIST_INIT(clk.link), \
.level = l, \
.locked = 0, \
}
#define DLIST_INIT(dlist)
Definition: dlist.h:51

Initializes a clock lock structure.

The macro is used to initialize a clock lock structure instance.

Parameters
lclock level
clkclock lock structure

Usage:

1 struct clk_lock_t MyXOClockLock = CLK_LOCK_INIT(CLK_LEVEL_XO, MyXOClockLock);

Definition at line 188 of file clk.h.

#define CLK_LOCK (   clk)    clk_lock(&clk)

Request the clock

The macro is used to request clock at the given clock level.

Parameters
clkclock lock structure

Usage:

1 CLK_LOCK(MyXOClockLock);

Definition at line 194 of file clk.h.

#define CLK_UNLOCK (   clk)    clk_unlock(&clk)

Release the clock

The macro is used to release clock at the given clock level.

The clock actually continues to run after the last lock is released until clk_relax() is called explicitly or by pm_relax().

Parameters
clkclock lock structure

Usage:

1 CLK_UNLOCK(MyXOClockLock);

Definition at line 195 of file clk.h.

#define CLK_AUTO_LOCK (   l)
Value:
struct clk_lock_t EveClkAutoLock __attribute__((cleanup(clk_unlock))); \
do { EveClkAutoLock = (struct clk_lock_t) CLK_LOCK_INIT(l, EveClkAutoLock); } while (0)
__attribute__((always_inline)) static inline void swint_enable_indirect_adapter(swint_state_t *state)
Definition: work.h:245
Definition: clk.h:95
#define CLK_LOCK_INIT(l, clk)
Definition: clk.h:188
void clk_unlock(struct clk_lock_t *clk)

Declares an anonymous auto lock, which holds clock request in the auto variable visibility block

Parameters
lclock level

Usage:

1 {
2  CLK_AUTO_LOCK(CLK_LEVEL_XO);
3  // Do something protected by the lock
4 }
5 // The lock is released here

Note: taking in mind lazy nature of releasing the clock locks, use of auto clock locks is negligible.

Definition at line 196 of file clk.h.

#define DECLARE_CLK_LOCK (   l,
  clk 
)    static struct clk_lock_t clk = CLK_LOCK_INIT(l, clk)

Instantiates a clock lock structure.

The macro is used to instantiate a clock lock structure.

Parameters
lclock level
clkclock lock structure

Usage:

1 DECLARE_CLK_LOCK(CLK_LEVEL_XO, MyXOClockLock);

Definition at line 215 of file clk.h.

Enumeration Type Documentation

Clock level.

The system can use one two high frequency clock sources: a 64 MHz internal oscillator (RC) or a 32 MHz crystal oscillator (XO). The crystal oscillator typically gives better stability, but drains more power from battery.

Clock level is an abstraction for the clock source the system is running on.

Enumerator
CLK_LEVEL_MIN 

Minimal possible clock level.

CLK_LEVEL_RC 

System uses 64 MHz internal oscillator as a clock source.

CLK_LEVEL_XO 

System uses 32 MHz crystal oscillator as a clock source.

CLK_LEVEL__COUNT 

Number of elements in the clk_level_t enum.

Definition at line 78 of file clk.h.

Function Documentation

void clk_init ( void  )

Initializes the clock management framework.

void clk_relax ( void  )

Switches off released clocks and enters the lowest allowed clock level.

void clk_lock ( struct clk_lock_t clk)

Requests the clock.

Parameters
clkpointer to the clock lock structure
void clk_unlock ( struct clk_lock_t clk)

Releases the clock.

Parameters
clkpointer to the clock lock structure