1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
/**
**************************************************************************
* @file at32f413_rtc.h
* @version v2.0.5
* @date 2022-05-20
* @brief at32f413 rtc header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
*
**************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __AT32F413_RTC_H
#define __AT32F413_RTC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "at32f413.h"
/** @addtogroup AT32F413_periph_driver
* @{
*/
/** @addtogroup RTC
* @{
*/
/** @defgroup RTC_interrupts_definition
* @brief rtc interrupt
* @{
*/
#define RTC_TS_INT ((uint16_t)0x0001) /*!< rtc time second interrupt */
#define RTC_TA_INT ((uint16_t)0x0002) /*!< rtc time alarm interrupt */
#define RTC_OVF_INT ((uint16_t)0x0004) /*!< rtc overflow interrupt */
/**
* @}
*/
/** @defgroup RTC_flags_definition
* @brief rtc flag
* @{
*/
#define RTC_TS_FLAG ((uint16_t)0x0001) /*!< rtc time second flag */
#define RTC_TA_FLAG ((uint16_t)0x0002) /*!< rtc time alarm flag */
#define RTC_OVF_FLAG ((uint16_t)0x0004) /*!< rtc overflow flag */
#define RTC_UPDF_FLAG ((uint16_t)0x0008) /*!< rtc update finish flag */
#define RTC_CFGF_FLAG ((uint16_t)0x0020) /*!< rtc configuration finish flag */
/**
* @}
*/
/** @defgroup RTC_exported_types
* @{
*/
/**
* @brief type define rtc register all
*/
typedef struct
{
/**
* @brief rtc ctrlh register, offset:0x00
*/
union
{
__IO uint32_t ctrlh;
struct
{
__IO uint32_t tsien : 1; /* [0] */
__IO uint32_t taien : 1; /* [1] */
__IO uint32_t ovfien : 1; /* [2] */
__IO uint32_t reserved1 : 29;/* [31:3] */
} ctrlh_bit;
};
/**
* @brief rtc ctrll register, offset:0x04
*/
union
{
__IO uint32_t ctrll;
struct
{
__IO uint32_t tsf : 1; /* [0] */
__IO uint32_t taf : 1; /* [1] */
__IO uint32_t ovff : 1; /* [2] */
__IO uint32_t updf : 1; /* [3] */
__IO uint32_t cfgen : 1; /* [4] */
__IO uint32_t cfgf : 1; /* [5] */
__IO uint32_t reserved1 : 26;/* [31:6] */
} ctrll_bit;
};
/**
* @brief rtc divh register, offset:0x08
*/
union
{
__IO uint32_t divh;
struct
{
__IO uint32_t div : 4; /* [3:0] */
__IO uint32_t reserved1 : 28;/* [31:4] */
} divh_bit;
};
/**
* @brief rtc divl register, offset:0x0C
*/
union
{
__IO uint32_t divl;
struct
{
__IO uint32_t div : 16;/* [15:0] */
__IO uint32_t reserved1 : 16;/* [31:15] */
} divl_bit;
};
/**
* @brief rtc divcnth register, offset:0x10
*/
union
{
__IO uint32_t divcnth;
struct
{
__IO uint32_t divcnt : 4; /* [3:0] */
__IO uint32_t reserved1 : 28;/* [31:15] */
} divcnth_bit;
};
/**
* @brief rtc divcntl register, offset:0x14
*/
union
{
__IO uint32_t divcntl;
struct
{
__IO uint32_t divcnt : 16;/* [15:0] */
__IO uint32_t reserved1 : 16;/* [31:15] */
} divcntl_bit;
};
/**
* @brief rtc cnth register, offset:0x18
*/
union
{
__IO uint32_t cnth;
struct
{
__IO uint32_t cnt : 16;/* [15:0] */
__IO uint32_t reserved1 : 16;/* [31:15] */
} cnth_bit;
};
/**
* @brief rtc cntl register, offset:0x1C
*/
union
{
__IO uint32_t cntl;
struct
{
__IO uint32_t cnt : 16;/* [15:0] */
__IO uint32_t reserved1 : 16;/* [31:15] */
} cntl_bit;
};
/**
* @brief rtc tah register, offset:0x20
*/
union
{
__IO uint32_t tah;
struct
{
__IO uint32_t ta : 16;/* [15:0] */
__IO uint32_t reserved1 : 16;/* [31:15] */
} tah_bit;
};
/**
* @brief rtc tal register, offset:0x24
*/
union
{
__IO uint32_t tal;
struct
{
__IO uint32_t ta : 16;/* [15:0] */
__IO uint32_t reserved1 : 16;/* [31:15] */
} tal_bit;
};
} rtc_type;
/**
* @}
*/
#define RTC ((rtc_type *) RTC_BASE)
/** @defgroup RTC_exported_functions
* @{
*/
void rtc_counter_set(uint32_t counter_value);
uint32_t rtc_counter_get(void);
void rtc_divider_set(uint32_t div_value);
uint32_t rtc_divider_get(void);
void rtc_alarm_set(uint32_t alarm_value);
void rtc_interrupt_enable(uint16_t source, confirm_state new_state);
flag_status rtc_flag_get(uint16_t flag);
void rtc_flag_clear(uint16_t flag);
void rtc_wait_config_finish(void);
void rtc_wait_update_finish(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
|