1 /*!
2  * @file       apm32e10x_rtc.h
3  *
4  * @brief      This file contains all the functions prototypes for the RTC firmware library
5  *
6  * @version     V1.0.2
7  *
8  * @date        2022-12-31
9  *
10  * @attention
11  *
12  *  Copyright (C) 2021-2023 Geehy Semiconductor
13  *
14  *  You may not use this file except in compliance with the
15  *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
16  *
17  *  The program is only for reference, which is distributed in the hope
18  *  that it will be useful and instructional for customers to develop
19  *  their software. Unless required by applicable law or agreed to in
20  *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
21  *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
22  *  See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
23  *  and limitations under the License.
24  */
25 
26 /* Define to prevent recursive inclusion */
27 #ifndef __APM32E10X_RTC_H
28 #define __APM32E10X_RTC_H
29 
30 /* Includes */
31 #include "apm32e10x.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /** @addtogroup APM32E10x_StdPeriphDriver
38   @{
39 */
40 
41 /** @addtogroup RTC_Driver
42   @{
43 */
44 
45 /** @defgroup RTC_Enumerations Enumerations
46   @{
47 */
48 
49 typedef enum
50 {
51     RTC_FLAG_OC    = 0x0020,    /*!< RTC Operation Complete flag */
52     RTC_FLAG_RSYNC = 0x0008,    /*!< Registers Synchronized flag */
53     RTC_FLAG_OVR   = 0x0004,    /*!< Overflow flag */
54     RTC_FLAG_ALR   = 0x0002,    /*!< Alarm flag */
55     RTC_FLAG_SEC   = 0x0001     /*!< Second flag */
56 } RTC_FLAG_T;
57 
58 typedef enum
59 {
60     RTC_INT_OVR = 0x0004,       /*!< Overflow interrupt */
61     RTC_INT_ALR = 0x0002,       /*!< Alarm interrupt */
62     RTC_INT_SEC = 0x0001        /*!< Second interrupt */
63 } RTC_INT_T;
64 
65 /**@} end of group RTC_Enumerations*/
66 
67 
68 /** @defgroup RTC_Functions Functions
69   @{
70 */
71 
72 /* Operation modes */
73 void RTC_EnableConfigMode(void);
74 void RTC_DisableConfigMode(void);
75 
76 /* Configuration */
77 uint32_t RTC_ReadCounter(void);
78 void RTC_ConfigCounter(uint32_t value);
79 void RTC_ConfigPrescaler(uint32_t value);
80 void RTC_ConfigAlarm(uint32_t value);
81 uint32_t RTC_ReadDivider(void);
82 void RTC_WaitForLastTask(void);
83 void RTC_WaitForSynchro(void);
84 
85 /* Interrupts and flags */
86 void RTC_EnableInterrupt(uint16_t interrupt);
87 void RTC_DisableInterrupt(uint16_t interrupt);
88 uint8_t RTC_ReadStatusFlag(RTC_FLAG_T flag);
89 void RTC_ClearStatusFlag(uint16_t flag);
90 uint8_t RTC_ReadIntFlag(RTC_INT_T flag);
91 void RTC_ClearIntFlag(uint16_t flag);
92 
93 /**@} end of group RTC_Functions*/
94 /**@} end of group RTC_Driver*/
95 /**@} end of group APM32E10x_StdPeriphDriver*/
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* __APM32E10X_RTC_H */
102