1 /********************************** (C) COPYRIGHT  *******************************
2  * File Name          : ch32v10x_rtc.h
3  * Author             : WCH
4  * Version            : V1.0.0
5  * Date               : 2020/04/30
6  * Description        : This file contains all the functions prototypes for the RTC
7  *                      firmware library.
8  * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
9  * SPDX-License-Identifier: Apache-2.0
10  *******************************************************************************/
11 #ifndef __CH32V10x_RTC_H
12 #define __CH32V10x_RTC_H
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #include "ch32v10x.h"
19 
20 /* RTC_interrupts_define */
21 #define RTC_IT_OW         ((uint16_t)0x0004) /* Overflow interrupt */
22 #define RTC_IT_ALR        ((uint16_t)0x0002) /* Alarm interrupt */
23 #define RTC_IT_SEC        ((uint16_t)0x0001) /* Second interrupt */
24 
25 /* RTC_interrupts_flags */
26 #define RTC_FLAG_RTOFF    ((uint16_t)0x0020) /* RTC Operation OFF flag */
27 #define RTC_FLAG_RSF      ((uint16_t)0x0008) /* Registers Synchronized flag */
28 #define RTC_FLAG_OW       ((uint16_t)0x0004) /* Overflow flag */
29 #define RTC_FLAG_ALR      ((uint16_t)0x0002) /* Alarm flag */
30 #define RTC_FLAG_SEC      ((uint16_t)0x0001) /* Second flag */
31 
32 void       RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState);
33 void       RTC_EnterConfigMode(void);
34 void       RTC_ExitConfigMode(void);
35 uint32_t   RTC_GetCounter(void);
36 void       RTC_SetCounter(uint32_t CounterValue);
37 void       RTC_SetPrescaler(uint32_t PrescalerValue);
38 void       RTC_SetAlarm(uint32_t AlarmValue);
39 uint32_t   RTC_GetDivider(void);
40 void       RTC_WaitForLastTask(void);
41 void       RTC_WaitForSynchro(void);
42 FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG);
43 void       RTC_ClearFlag(uint16_t RTC_FLAG);
44 ITStatus   RTC_GetITStatus(uint16_t RTC_IT);
45 void       RTC_ClearITPendingBit(uint16_t RTC_IT);
46 
47 #ifdef __cplusplus
48 }
49 #endif
50 
51 #endif /* __CH32V10x_RTC_H */
52