1 /*!
2  * @file        apm32e10x_bakr.h
3  *
4  * @brief       This file contains all the functions prototypes for the BAKPR 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_BAKPR_H
28 #define __APM32E10X_BAKPR_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 BAKPR_Driver
42   @{
43 */
44 
45 /** @defgroup BAKPR_Enumerations Enumerations
46   @{
47 */
48 
49 /**
50  * @brief BAKPR TAMPER Pin Active Level
51  */
52 typedef enum
53 {
54     BAKPR_TAMPER_PIN_LEVEL_HIGH,
55     BAKPR_TAMPER_PIN_LEVEL_LOW
56 } BAKPR_TAMPER_PIN_LEVEL_T;
57 
58 /**
59  * @brief BAKPR RTC output source
60  */
61 typedef enum
62 {
63     BAKPR_RTC_OUTPUT_SOURCE_NONE,
64     BAKPR_RTC_OUTPUT_SOURCE_CALIBRATION_CLOCK,
65     BAKPR_RTC_OUTPUT_SOURCE_ALARM,
66     BAKPR_RTC_OUTPUT_SOURCE_SECOND
67 } BAKPR_RTC_OUTPUT_SOURCE_T;
68 
69 /**
70  * @brief BAKPR DATA register Addr
71  */
72 typedef enum
73 {
74     BAKPR_DATA1  = ((uint16_t)0x0004),
75     BAKPR_DATA2  = ((uint16_t)0x0008),
76     BAKPR_DATA3  = ((uint16_t)0x000C),
77     BAKPR_DATA4  = ((uint16_t)0x0010),
78     BAKPR_DATA5  = ((uint16_t)0x0014),
79     BAKPR_DATA6  = ((uint16_t)0x0018),
80     BAKPR_DATA7  = ((uint16_t)0x001C),
81     BAKPR_DATA8  = ((uint16_t)0x0020),
82     BAKPR_DATA9  = ((uint16_t)0x0024),
83     BAKPR_DATA10 = ((uint16_t)0x0028),
84     BAKPR_DATA11 = ((uint16_t)0x0040),
85     BAKPR_DATA12 = ((uint16_t)0x0044),
86     BAKPR_DATA13 = ((uint16_t)0x0048),
87     BAKPR_DATA14 = ((uint16_t)0x004C),
88     BAKPR_DATA15 = ((uint16_t)0x0050),
89     BAKPR_DATA16 = ((uint16_t)0x0054),
90     BAKPR_DATA17 = ((uint16_t)0x0058),
91     BAKPR_DATA18 = ((uint16_t)0x005C),
92     BAKPR_DATA19 = ((uint16_t)0x0060),
93     BAKPR_DATA20 = ((uint16_t)0x0064),
94     BAKPR_DATA21 = ((uint16_t)0x0068),
95     BAKPR_DATA22 = ((uint16_t)0x006C),
96     BAKPR_DATA23 = ((uint16_t)0x0070),
97     BAKPR_DATA24 = ((uint16_t)0x0074),
98     BAKPR_DATA25 = ((uint16_t)0x0078),
99     BAKPR_DATA26 = ((uint16_t)0x007C),
100     BAKPR_DATA27 = ((uint16_t)0x0080),
101     BAKPR_DATA28 = ((uint16_t)0x0084),
102     BAKPR_DATA29 = ((uint16_t)0x0088),
103     BAKPR_DATA30 = ((uint16_t)0x008C),
104     BAKPR_DATA31 = ((uint16_t)0x0090),
105     BAKPR_DATA32 = ((uint16_t)0x0094),
106     BAKPR_DATA33 = ((uint16_t)0x0098),
107     BAKPR_DATA34 = ((uint16_t)0x009C),
108     BAKPR_DATA35 = ((uint16_t)0x00A0),
109     BAKPR_DATA36 = ((uint16_t)0x00A4),
110     BAKPR_DATA37 = ((uint16_t)0x00A8),
111     BAKPR_DATA38 = ((uint16_t)0x00AC),
112     BAKPR_DATA39 = ((uint16_t)0x00B0),
113     BAKPR_DATA40 = ((uint16_t)0x00B4),
114     BAKPR_DATA41 = ((uint16_t)0x00B8),
115     BAKPR_DATA42 = ((uint16_t)0x00BC)
116 } BAKPR_DATA_T;
117 
118 /**@} end of group BAKPR_Enumerations*/
119 
120 
121 /** @defgroup BAKPR_Functions Functions
122   @{
123 */
124 
125 /* BAKPR reset and configuration */
126 void BAKPR_Reset(void);
127 void BAKPR_ConfigTamperPinLevel(BAKPR_TAMPER_PIN_LEVEL_T value);
128 void BAKPR_EnableTamperPin(void);
129 void BAKPR_DisableTamperPin(void);
130 void BAKPR_ConfigRTCOutput(BAKPR_RTC_OUTPUT_SOURCE_T soure);
131 void BAKPR_ConfigRTCCalibrationValue(uint8_t calibrationValue);
132 void BAKPR_ConfigBackupRegister(BAKPR_DATA_T bakrData, uint16_t data);
133 uint16_t BAKPR_ReadBackupRegister(BAKPR_DATA_T bakrData);
134 
135 /** Interrupts and flags */
136 void BAKPR_EnableInterrupt(void);
137 void BAKPR_DisableInterrupt(void);
138 uint8_t BAKPR_ReadStatusFlag(void);
139 void BAKPR_ClearStatusFlag(void);
140 uint8_t BAKPR_ReadIntFlag(void);
141 void BAKPR_ClearIntFlag(void);
142 
143 /**@} end of group BAKPR_Functions */
144 /**@} end of group BAKPR_Driver */
145 /**@} end of group APM32E10x_StdPeriphDriver */
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* __APM32E10X_BAKPR_H */
152