1 /********************************** (C) COPYRIGHT  *******************************
2 * File Name          : ch32f20x_rtc.h
3 * Author             : WCH
4 * Version            : V1.0.0
5 * Date               : 2021/08/08
6 * Description        : This file contains all the functions prototypes for the RTC
7 *                      firmware library.
8 *******************************************************************************/
9 #ifndef __CH32F20x_RTC_H
10 #define __CH32F20x_RTC_H
11 
12 #ifdef __cplusplus
13  extern "C" {
14 #endif
15 
16 #include "ch32f20x.h"
17 
18 
19 /* RTC_interrupts_define */
20 #define RTC_IT_OW            ((uint16_t)0x0004)  /* Overflow interrupt */
21 #define RTC_IT_ALR           ((uint16_t)0x0002)  /* Alarm interrupt */
22 #define RTC_IT_SEC           ((uint16_t)0x0001)  /* Second interrupt */
23 
24 /* RTC_interrupts_flags */
25 #define RTC_FLAG_RTOFF       ((uint16_t)0x0020)  /* RTC Operation OFF flag */
26 #define RTC_FLAG_RSF         ((uint16_t)0x0008)  /* Registers Synchronized flag */
27 #define RTC_FLAG_OW          ((uint16_t)0x0004)  /* Overflow flag */
28 #define RTC_FLAG_ALR         ((uint16_t)0x0002)  /* Alarm flag */
29 #define RTC_FLAG_SEC         ((uint16_t)0x0001)  /* Second flag */
30 
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
52 
53