gr55xx_ll_bod.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_ll_bod.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of CALENDAR LL library.
7 *
8 ****************************************************************************************
9 * @attention
10 #####Copyright (c) 2019 GOODIX
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of GOODIX nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 ****************************************************************************************
36 */
37
38 /** @addtogroup PERIPHERAL Peripheral Driver
39 * @{
40 */
41
42 /** @addtogroup LL_DRIVER LL Driver
43 * @{
44 */
45
46 /** @defgroup LL_BOD BOD
47 * @brief BOD LL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55XX_LL_BOD_H_
53 #define __GR55XX_LL_BOD_H_
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx.h"
61
62 /** @defgroup BOD_LL_STRUCTURES Structures
63 * @{
64 */
65
66 /* Exported types ------------------------------------------------------------*/
67 /** @defgroup BOD_LL_ES_INIT BOD Exported init structures
68 * @{
69 */
70
71 /**
72 * @brief LL BOD init Structure definition
73 */
74 typedef struct _ll_bod_init
75 {
76 uint8_t bod_en; /**< Specifies the bod enable.
77
78 This parament can be modified afterwards using unitary function @ref ll_bod_enable() and ll_bod_disable(). */
79
80 uint8_t bod2_en; /**< Specifies the bod2 enable.
81
82 This parament can be modified afterwards using unitary function @ref ll_bod2_enable() and ll_bod2_disable().. */
83
84 uint8_t bod2_lvl; /**< Specifies the bod2 level.
85
86 This parament can be modified afterwards using unitary function @ref ll_bod2_lvl_ctrl_lv_set(). */
87
88 uint8_t bod_static_en; /**< Specifies the bod static enbale.
89 This parameter can be a value of @ref LL_BOD_STATIC_ENABLE.
90 This parament can be modified afterwards using unitary function @ref ll_bod_static_lv_enable() and ll_bod_static_lv_disable(). */
91 } ll_bod_init_t;
92
93 /** @} */
94
95 /** @} */
96
97 /**
98 * @defgroup BOD_LL_MACRO Defines
99 * @{
100 */
101
102 /* Exported constants --------------------------------------------------------*/
103 /** @defgroup BOD_LL_Exported_Constants BOD Exported Constants
104 * @{
105 */
106
107 /** @defgroup BOD_LL_ENABLE BOD ENABLE
108 * @{
109 */
110 #define LL_BOD_ENABLE 0x1 /**< BOD enable */
111 #define LL_BOD_DISABLE 0x0 /**< BOD disable */
112 /** @} */
113
114 /** @defgroup BOD2_LL_ENABLE BOD2 ENABLE
115 * @{
116 */
117 #define LL_BOD2_ENABLE 0x1 /**< BOD2 enable */
118 #define LL_BOD2_DISABLE 0x0 /**< BOD2 disable */
119 /** @} */
120
121 /** @defgroup BOD_LL_STATIC_ENABLE BOD STATIC ENABLE
122 * @{
123 */
124 #define LL_BOD_STATIC_ENABLE (0x1) /**< BOD STATIC enable */
125 #define LL_BOD_STATIC_DISABLE (0x0) /**< BOD STATIC disable */
126 /** @} */
127
128 /** @defgroup BOD2_LL_LEVEL BOD2 LVEVL
129 * @{
130 */
131 #define LL_BOD2_LEVEL_0 0x0 /**< BOD2 Level 0 */
132 #define LL_BOD2_LEVEL_1 0x1 /**< BOD2 Level 1 */
133 #define LL_BOD2_LEVEL_2 0x2 /**< BOD2 Level 2 */
134 #define LL_BOD2_LEVEL_3 0x3 /**< BOD2 Level 3 */
135 #define LL_BOD2_LEVEL_4 0x4 /**< BOD2 Level 4 */
136 #define LL_BOD2_LEVEL_5 0x5 /**< BOD2 Level 5 */
137 #define LL_BOD2_LEVEL_6 0x6 /**< BOD2 Level 6 */
138 #define LL_BOD2_LEVEL_7 0x7 /**< BOD2 Level 7 */
139 /** @} */
140
141 /** @} */
142
143 /** @} */
144
145 /** @defgroup BOD_LL_DRIVER_FUNCTIONS Functions
146 * @{
147 */
148 /**
149 * @brief Enable the bod
150 *
151 * Register|BitsName
152 * --------|--------
153 * RF_REG_3 | bod_en_lv
154 *
155 */
156 __STATIC_INLINE void ll_bod_enable(void)
157 {
158 SET_BITS(AON->RF_REG_3, AON_RF_REG_3_BOD_EN);
159 }
160
161 /**
162 * @brief Disable the bod
163 *
164 * Register|BitsName
165 * --------|--------
166 * RF_REG_3 | bod_en_lv
167 *
168 */
169 __STATIC_INLINE void ll_bod_disable(void)
170 {
171 CLEAR_BITS(AON->RF_REG_3, AON_RF_REG_3_BOD_EN);
172 }
173
174 /**
175 * @brief Enable the bod2
176 *
177 * Register|BitsName
178 * --------|--------
179 * RF_REG_3 | bod2_en_lv
180 *
181 */
182 __STATIC_INLINE void ll_bod2_enable(void)
183 {
184 SET_BITS(AON->RF_REG_3, AON_RF_REG_3_BOD2_EN);
185 }
186
187 /**
188 * @brief Disable the bod2
189 *
190 * Register|BitsName
191 * --------|--------
192 * RF_REG_3 | bod2_en_lv
193 *
194 */
195 __STATIC_INLINE void ll_bod2_disable(void)
196 {
197 CLEAR_BITS(AON->RF_REG_3, AON_RF_REG_3_BOD2_EN);
198 }
199
200 /**
201 * @brief Set bod control level
202 *
203 * Register|BitsName
204 * --------|--------
205 * RF_REG_3 | bod_lvl_ctrl_lv_3_0
206 * @param lvl_ctrl_lv: 0x0 ~ 0x7
207 */
208 __STATIC_INLINE void ll_bod2_lvl_ctrl_lv_set(uint8_t lvl_ctrl_lv)
209 {
210 MODIFY_REG(AON->RF_REG_3, AON_RF_REG_3_BOD_LVL_CTRL_LV, (lvl_ctrl_lv << AON_RF_REG_3_BOD_LVL_CTRL_LV_Pos));
211 }
212
213 /**
214 * @brief enable bod static lv
215 *
216 * Register|BitsName
217 * --------|--------
218 * RF_REG_3 | bod_static_lv
219 */
220 __STATIC_INLINE void ll_bod_static_lv_enable(void)
221 {
222 SET_BITS(AON->RF_REG_3, AON_RF_REG_3_BOD_STATIC_LV_EN);
223 }
224
225 /**
226 * @brief disable bod static lv
227 *
228 * Register|BitsName
229 * --------|--------
230 * RF_REG_3 | bod_static_lv
231 */
232 __STATIC_INLINE void ll_bod_static_lv_disable(void)
233 {
234 CLEAR_BITS(AON->RF_REG_3, AON_RF_REG_3_BOD_STATIC_LV_EN);
235 }
236
237 /**
238 * @brief enable BOD FEDGE Event.
239 *
240 * Register|BitsName
241 * --------|--------
242 * AON_IRQ | PMU_BOD_FEDGE
243 *
244 * @retval State of bit (1 or 0).
245 */
246 __STATIC_INLINE void ll_bod_enable_fedge(void)
247 {
248 SET_BITS(AON->PWR_RET01, AON_PWR_REG01_WAKE_UP_SEL_PMU_BOD_FEDGE);
249 }
250
251 /**
252 * @brief disable BOD FEDGE Event.
253 *
254 * Register|BitsName
255 * --------|--------
256 * AON_IRQ | PMU_BOD_FEDGE
257 *
258 * @retval State of bit (1 or 0).
259 */
260 __STATIC_INLINE void ll_bod_disable_fedge(void)
261 {
262 CLEAR_BITS(AON->PWR_RET01, AON_PWR_REG01_WAKE_UP_SEL_PMU_BOD_FEDGE);
263 }
264
265 /**
266 * @brief Indicate if the BOD REDGE Event Flag is set or not.
267 *
268 * Register|BitsName
269 * --------|--------
270 * AON_IRQ | PMU_BOD_REDGE
271 *
272 * @retval State of bit (1 or 0).
273 */
274 __STATIC_INLINE uint32_t ll_bod_is_active_flag_fedge(void)
275 {
276 return (uint32_t)(READ_BITS(AON->SLP_EVENT, AON_SLP_EVENT_PMU_BOD_FEDGE) == AON_SLP_EVENT_PMU_BOD_FEDGE);
277 }
278
279 /**
280 * @brief Clear Interrupt Status flag.
281 *
282 * Register|BitsName
283 * --------|--------
284 * AON_IRQ| PMU_BOD_REDGE
285 *
286 * @retval None
287 */
288 __STATIC_INLINE void ll_bod_clear_flag_fedge(void)
289 {
290 GLOBAL_EXCEPTION_DISABLE();
291 WRITE_REG(AON->SLP_EVENT, ~AON_SLP_EVENT_PMU_BOD_FEDGE);
292 GLOBAL_EXCEPTION_ENABLE();
293 }
294
295 /**
296 * @brief De-initialize the BOD registers to their default reset values.
297 * @retval An error_status_t enumeration value:
298 * - SUCCESS: PDM registers are de-initialized
299 * - ERROR: PDM registers are not de-initialized
300 */
301 error_status_t ll_bod_deinit(void);
302
303 /**
304 * @brief Initialize the BOD registers according to the specified parameters.
305 * @param p_bod_init pointer to a @ref ll_bod_init_t structure.
306 * @retval An error_status_t enumeration value:
307 * - SUCCESS: BOD registers are initialized
308 * - ERROR: Not applicable
309 */
310 error_status_t ll_bod_init(ll_bod_init_t *p_bod_init);
311
312 /**
313 * @brief Set BOD initial structure to default value.
314 * @param p_bod_init Pointer to a @ref ll_bod_init_t structure
315 * whose fields will be set to default values.
316 * @retval None
317 */
318 void ll_bod_struct_init(ll_bod_init_t *p_bod_init);
319 /** @} */
320
321 #endif
322
323 /** @} */
324
325 /** @} */
326
327 /** @} */
_ll_bod_init::bod_static_en
uint8_t bod_static_en
Specifies the bod static enbale.
Definition: gr55xx_ll_bod.h:88
ll_bod_static_lv_disable
__STATIC_INLINE void ll_bod_static_lv_disable(void)
disable bod static lv
Definition: gr55xx_ll_bod.h:232
_ll_bod_init
LL BOD init Structure definition.
Definition: gr55xx_ll_bod.h:75
ll_bod_enable
__STATIC_INLINE void ll_bod_enable(void)
Enable the bod.
Definition: gr55xx_ll_bod.h:156
ll_bod2_disable
__STATIC_INLINE void ll_bod2_disable(void)
Disable the bod2.
Definition: gr55xx_ll_bod.h:195
_ll_bod_init::bod2_en
uint8_t bod2_en
Specifies the bod2 enable.
Definition: gr55xx_ll_bod.h:80
ll_bod_init_t
struct _ll_bod_init ll_bod_init_t
LL BOD init Structure definition.
_ll_bod_init::bod_en
uint8_t bod_en
Specifies the bod enable.
Definition: gr55xx_ll_bod.h:76
ll_bod_disable_fedge
__STATIC_INLINE void ll_bod_disable_fedge(void)
disable BOD FEDGE Event.
Definition: gr55xx_ll_bod.h:260
ll_bod_clear_flag_fedge
__STATIC_INLINE void ll_bod_clear_flag_fedge(void)
Clear Interrupt Status flag.
Definition: gr55xx_ll_bod.h:288
ll_bod2_lvl_ctrl_lv_set
__STATIC_INLINE void ll_bod2_lvl_ctrl_lv_set(uint8_t lvl_ctrl_lv)
Set bod control level.
Definition: gr55xx_ll_bod.h:208
ll_bod_static_lv_enable
__STATIC_INLINE void ll_bod_static_lv_enable(void)
enable bod static lv
Definition: gr55xx_ll_bod.h:220
ll_bod_struct_init
void ll_bod_struct_init(ll_bod_init_t *p_bod_init)
Set BOD initial structure to default value.
ll_bod_is_active_flag_fedge
__STATIC_INLINE uint32_t ll_bod_is_active_flag_fedge(void)
Indicate if the BOD REDGE Event Flag is set or not.
Definition: gr55xx_ll_bod.h:274
ll_bod_init
error_status_t ll_bod_init(ll_bod_init_t *p_bod_init)
Initialize the BOD registers according to the specified parameters.
ll_bod_deinit
error_status_t ll_bod_deinit(void)
De-initialize the BOD registers to their default reset values.
_ll_bod_init::bod2_lvl
uint8_t bod2_lvl
Specifies the bod2 level.
Definition: gr55xx_ll_bod.h:84
ll_bod_disable
__STATIC_INLINE void ll_bod_disable(void)
Disable the bod.
Definition: gr55xx_ll_bod.h:169
ll_bod2_enable
__STATIC_INLINE void ll_bod2_enable(void)
Enable the bod2.
Definition: gr55xx_ll_bod.h:182
ll_bod_enable_fedge
__STATIC_INLINE void ll_bod_enable_fedge(void)
enable BOD FEDGE Event.
Definition: gr55xx_ll_bod.h:246