Kamcho Library 02.00.03  lib.kamcho.02.00.03.287
clock_sfrs.h
Go to the documentation of this file.
1 
12 #ifndef __CLOCK_SFRS_H__
13 #define __CLOCK_SFRS_H__
14 
18 typedef struct {
19  union {
20  struct {
21  uint8_t CKSEL:2;
22  uint8_t RCEN:1;
23  uint8_t XOEN:1;
24  uint8_t RCMON:1;
25  uint8_t XOMON:1;
26  uint8_t CKD:2;
27  };
28  uint8_t BYTE;
29  } PUMCLK;
30  uint8_t RESERVED0[98322];
31  union {
32  struct {
33  uint8_t TRIM:5;
34  uint8_t RESERVED:3;
35  };
36  uint8_t BYTE;
37  } RCC10KTRIM;
38  union {
39  struct {
40  uint8_t RESERVED:5;
41  uint8_t TRIM:3;
42  };
43  uint8_t BYTE;
44  } RCTRIM0;
45  union {
46  struct {
47  uint8_t TRIM:4;
48  uint8_t RESERVED:4;
49  };
50  uint8_t BYTE;
51  } RCTRIM1;
52 } CLOCK_SFRS_t;
53 
57 #define CLOCK_SFRS ((__IO CLOCK_SFRS_t *)(ASIC_7B_BASE + 0))
58 
59 #define E_CLOCK_SOURCE_RC10KHZ 0x00
60 #define E_CLOCK_SOURCE_RC12MHZ 0x01
61 #define E_CLOCK_SOURCE_XTCLOCK 0x02
62 #define E_CLOCK_SOURCE_RCAUX 0x03
63 
69 static __INLINE void f_CLOCK_SelectSource(uint8_t src)
70 {
71  CLOCK_SFRS->PUMCLK.CKSEL = src;
72 }
73 
79 static __INLINE uint8_t f_CLOCK_GetClockSource(void)
80 {
81  return CLOCK_SFRS->PUMCLK.CKSEL;
82 }
83 
87 static __INLINE void f_CLOCK_EnableXTClock(void)
88 {
89  CLOCK_SFRS->PUMCLK.XOEN = 1;
90 }
91 
95 static __INLINE void f_CLOCK_DisableXTClock(void)
96 {
97  CLOCK_SFRS->PUMCLK.XOEN = 0;
98 }
99 
105 static __INLINE uint8_t f_CLOCK_IsXTClockEnabled(void)
106 {
107  return CLOCK_SFRS->PUMCLK.XOEN;
108 }
109 
113 static __INLINE void f_CLOCK_EnableRCClock(void)
114 {
115  CLOCK_SFRS->PUMCLK.RCEN = 1;
116 }
117 
121 static __INLINE void f_CLOCK_DisableRCClock(void)
122 {
123  CLOCK_SFRS->PUMCLK.RCEN = 0;
124 }
125 
131 static __INLINE uint8_t f_CLOCK_IsRCClockEnabled(void)
132 {
133  return CLOCK_SFRS->PUMCLK.RCEN;
134 }
135 
141 static __INLINE void f_CLOCK_RCTrim(uint8_t val)
142 {
143  CLOCK_SFRS->RCTRIM0.TRIM = val;
144  CLOCK_SFRS->RCTRIM1.TRIM = val >> 3;
145 }
146 
152 static __INLINE void f_CLOCK_RC10KTrim(uint8_t val)
153 {
154  CLOCK_SFRS->RCC10KTRIM.TRIM = val;
155 }
156 
157 #endif /* __CLOCK_SFRS_H__ */
static __INLINE uint8_t f_CLOCK_IsXTClockEnabled(void)
Check if crystal clock source enabled.
Definition: clock_sfrs.h:105
static __INLINE void f_CLOCK_DisableXTClock(void)
Disable crystal clock source.
Definition: clock_sfrs.h:95
static __INLINE void f_CLOCK_RCTrim(uint8_t val)
Trim RC clock.
Definition: clock_sfrs.h:141
uint8_t BYTE
Definition: clock_sfrs.h:28
static __INLINE void f_CLOCK_EnableRCClock(void)
Enable RC clock source.
Definition: clock_sfrs.h:113
static __INLINE void f_CLOCK_RC10KTrim(uint8_t val)
Trim 10K RC clock.
Definition: clock_sfrs.h:152
static __INLINE uint8_t f_CLOCK_GetClockSource(void)
Get clock source.
Definition: clock_sfrs.h:79
static __INLINE void f_CLOCK_DisableRCClock(void)
Disable RC clock source.
Definition: clock_sfrs.h:121
static __INLINE void f_CLOCK_SelectSource(uint8_t src)
Select clock source.
Definition: clock_sfrs.h:69
A structure to represent Special Function Registers for Clock.
Definition: clock_sfrs.h:18
static __INLINE void f_CLOCK_EnableXTClock(void)
Enable crystal clock source.
Definition: clock_sfrs.h:87
static __INLINE uint8_t f_CLOCK_IsRCClockEnabled(void)
Check if RC clock source enabled.
Definition: clock_sfrs.h:131
#define CLOCK_SFRS
The starting address of Clock SFRS.
Definition: clock_sfrs.h:57