Herzog Library 00.00.01  rel_libdev.herzog.00.00.01.10606
rtc_sfrs.h
Go to the documentation of this file.
1 
12 #ifndef __RTC_SFRS_H__
13 #define __RTC_SFRS_H__
14 
15 #define E_RTC_MAX_COUNT 0x0003FFFF
16 
20 typedef struct {
21  struct {
22  uint32_t LOCK:1;
23  uint32_t EN:1;
24  uint32_t OWIE:1;
25  uint32_t ALRIE:1;
26  uint32_t OWF:1;
27  uint32_t ALRF0:1;
28  uint32_t ALRF1:1;
29  uint32_t :1;
30  } CTRL;
31  struct {
32  uint32_t CNT:18;
33  uint32_t :14;
34  } COUNTER;
35  struct {
36  uint32_t CNT:18;
37  uint32_t :14;
38  } ALARM0;
39  struct {
40  uint32_t CNT:18;
41  uint32_t :14;
42  } ALARM1;
43 } RTC_SFRS_t;
44 
48 #define RTC_SFRS ((__IO RTC_SFRS_t *) (0x50000040))
49 
53 typedef struct {
54  uint8_t TRIM:2;
55  uint8_t :6;
57 
61 #define RTC_TRIM_SFRS ((__IO RTC_TRIM_SFRS_t *) (0x5001800B))
62 
66 static __INLINE void f_RTC_Enable(void)
67 {
68  RTC_SFRS->CTRL.EN = 1;
69 }
70 
74 static __INLINE void f_RTC_Disable(void)
75 {
76  RTC_SFRS->CTRL.EN = 0;
77 }
78 
82 static __INLINE void f_RTC_Unlock(void)
83 {
84  RTC_SFRS->CTRL.LOCK = 0;
85 }
86 
90 static __INLINE void f_RTC_Lock(void)
91 {
92  RTC_SFRS->CTRL.LOCK = 1;
93 }
94 
98 static __INLINE void f_RTC_EnableAlarmIRQ(void)
99 {
100  RTC_SFRS->CTRL.ALRIE = 1;
101 }
102 
106 static __INLINE void f_RTC_DisableAlarmIRQ(void)
107 {
108  RTC_SFRS->CTRL.ALRIE = 0;
109 }
110 
114 static __INLINE void f_RTC_EnableOverflowIRQ(void)
115 {
116  RTC_SFRS->CTRL.OWIE = 1;
117 }
118 
122 static __INLINE void f_RTC_DisableOverflowIRQ(void)
123 {
124  RTC_SFRS->CTRL.OWIE = 0;
125 }
126 
130 static __INLINE uint8_t f_RTC_IsOverflow(void)
131 {
132  return RTC_SFRS->CTRL.OWF;
133 }
134 
138 static __INLINE uint8_t f_RTC_IsAlarm0(void)
139 {
140  return RTC_SFRS->CTRL.ALRF0;
141 }
142 
146 static __INLINE uint8_t f_RTC_IsAlarm1(void)
147 {
148  return RTC_SFRS->CTRL.ALRF1;
149 }
150 
154 static __INLINE uint32_t f_RTC_GetCurrentCounter(void)
155 {
156  return RTC_SFRS->COUNTER.CNT;
157 }
158 
162 static __INLINE void f_RTC_SetCurrentCounter(uint32_t val)
163 {
164  RTC_SFRS->COUNTER.CNT = val;
165 }
166 
170 static __INLINE uint32_t f_RTC_GetAlarm0Counter(void)
171 {
172  return RTC_SFRS->ALARM0.CNT;
173 }
174 
178 static __INLINE void f_RTC_SetAlarm0Counter(uint32_t val)
179 {
180  RTC_SFRS->ALARM0.CNT = val;
181 }
182 
186 static __INLINE uint32_t f_RTC_GetAlarm1Counter(void)
187 {
188  return RTC_SFRS->ALARM1.CNT;
189 }
190 
194 static __INLINE void f_RTC_SetAlarm1Counter(uint32_t val)
195 {
196  RTC_SFRS->ALARM1.CNT = val;
197 }
198 
202 static __INLINE void f_RTC_SetRTCTrim(uint8_t val)
203 {
204  RTC_TRIM_SFRS->TRIM = val;
205 }
206 
207 #endif /* __RTC_SFRS_H__ */
A structure to represent Special Function Registers for RTC.
Definition: rtc_sfrs.h:20
#define RTC_SFRS
The starting address of RTC SFRS.
Definition: rtc_sfrs.h:48
static __INLINE void f_RTC_Enable(void)
Enable RTC timers.
Definition: rtc_sfrs.h:66
static __INLINE void f_RTC_DisableOverflowIRQ(void)
Disable RTC overflow interrupt.
Definition: rtc_sfrs.h:122
static __INLINE void f_RTC_EnableOverflowIRQ(void)
Enable RTC overflow interrupt.
Definition: rtc_sfrs.h:114
static __INLINE void f_RTC_DisableAlarmIRQ(void)
Disable RTC alarm interrupt.
Definition: rtc_sfrs.h:106
static __INLINE void f_RTC_Lock(void)
Lock RTC configuration mode.
Definition: rtc_sfrs.h:90
static __INLINE uint8_t f_RTC_IsAlarm0(void)
Check if RTC alarm0 detected.
Definition: rtc_sfrs.h:138
static __INLINE void f_RTC_Unlock(void)
Unlock RTC configuration mode.
Definition: rtc_sfrs.h:82
static __INLINE uint32_t f_RTC_GetAlarm1Counter(void)
Read RTC alarm 1 counter.
Definition: rtc_sfrs.h:186
static __INLINE void f_RTC_SetAlarm0Counter(uint32_t val)
Set RTC alarm 0 counter.
Definition: rtc_sfrs.h:178
static __INLINE void f_RTC_EnableAlarmIRQ(void)
Enable RTC alarm interrupt.
Definition: rtc_sfrs.h:98
static __INLINE uint32_t f_RTC_GetAlarm0Counter(void)
Read RTC alarm 0 counter.
Definition: rtc_sfrs.h:170
static __INLINE void f_RTC_SetAlarm1Counter(uint32_t val)
Set RTC alarm 1 counter.
Definition: rtc_sfrs.h:194
static __INLINE void f_RTC_SetRTCTrim(uint8_t val)
Set RTC trim setting.
Definition: rtc_sfrs.h:202
static __INLINE uint8_t f_RTC_IsAlarm1(void)
Check if RTC alarm1 detected.
Definition: rtc_sfrs.h:146
static __INLINE void f_RTC_SetCurrentCounter(uint32_t val)
Set RTC current counter.
Definition: rtc_sfrs.h:162
#define RTC_TRIM_SFRS
The starting address of RTC TRIM SFRS.
Definition: rtc_sfrs.h:61
static __INLINE uint32_t f_RTC_GetCurrentCounter(void)
Read RTC current counter.
Definition: rtc_sfrs.h:154
A structure to represent Special Function Registers for RTC trim.
Definition: rtc_sfrs.h:53
static __INLINE void f_RTC_Disable(void)
Disable RTC timers.
Definition: rtc_sfrs.h:74
static __INLINE uint8_t f_RTC_IsOverflow(void)
Check if RTC overflow occured.
Definition: rtc_sfrs.h:130