app_bod.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file app_bod.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of BOD app 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 #ifndef _APP_BOD_H_
38 #define _APP_BOD_H_
39
40 #include "grx_hal.h"
41 #include "app_drv_error.h"
42 #include "app_drv_config.h"
43
44 #ifdef HAL_BOD_MODULE_ENABLED
45 /** @addtogroup PERIPHERAL Peripheral Driver
46 * @{
47 */
48
49 /** @addtogroup APP_DRIVER APP DRIVER
50 * @{
51 */
52
53 /** @defgroup APP_BOD BOD
54 * @brief BOD APP module driver.
55 * @{
56 */
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 /** @addtogroup APP_BOD_ENUM Enumerations
63 * @{
64 */
65 /**
66 * @brief BOD event Enumerations definition
67 */
68 typedef enum
69 {
70 APP_BOD_EVT_TRIGGERED, /**< BOD interrupt trigger event. */
71 APP_BOD_EVT_REMOVED, /**< BOD interrupt condition removed event. */
72 } app_bod_evt_type_t;
73
74 /**@brief App bod state types. */
75 typedef enum
76 {
77 APP_BOD_INVALID = 0,
78 APP_BOD_ACTIVITY,
79 } app_bod_state_t;
80
81 /** @} */
82
83 /**
84 * @defgroup APP_BOD_MACRO Defines
85 * @{
86 */
87
88 /** @defgroup APP_BOD_Exported_Constants BOD Exported Constants
89 * @{
90 */
91
92 /** @defgroup APP_BOD_ENABLE BOD enable defines
93 * @{
94 */
95 #define APP_BOD_ENABLE HAL_BOD_ENABLE /**< BOD enable */
96 #define APP_BOD_DISABLE HAL_BOD_DISABLE /**< BOD disable */
97 /** @} */
98
99 /** @defgroup APP_BOD_EVENT_ENABLE BOD event enable
100 * @{
101 */
102 #define APP_BOD_EVENT_ENABLE HAL_BOD2_ENABLE /**< BOD event enable */
103 #define APP_BOD_EVENT_DISABLE HAL_BOD2_DISABLE /**< BOD event disable */
104 /** @} */
105
106 /** @defgroup APP_BOD_STATIC_ENABLE BOD STATIC ENABLE
107 * @{
108 */
109 #define APP_BOD_STATIC_ENABLE HAL_BOD_STATIC_ENABLE /**< BOD STATIC enable */
110 #define APP_BOD_STATIC_DISABLE HAL_BOD_STATIC_DISABLE /**< BOD STATIC disable */
111 /** @} */
112
113 /** @defgroup APP_BOD_EVENT_LEVEL BOD event level
114 * @{
115 */
116 #define APP_BOD_EVENT_LEVEL_0 HAL_BOD2_LEVEL_0 /**< BOD event Level 0 */
117 #define APP_BOD_EVENT_LEVEL_1 HAL_BOD2_LEVEL_1 /**< BOD event Level 1 */
118 #define APP_BOD_EVENT_LEVEL_2 HAL_BOD2_LEVEL_2 /**< BOD event Level 2 */
119 #define APP_BOD_EVENT_LEVEL_3 HAL_BOD2_LEVEL_3 /**< BOD event Level 3 */
120 #define APP_BOD_EVENT_LEVEL_4 HAL_BOD2_LEVEL_4 /**< BOD event Level 4 */
121 #define APP_BOD_EVENT_LEVEL_5 HAL_BOD2_LEVEL_5 /**< BOD event Level 5 */
122 #define APP_BOD_EVENT_LEVEL_6 HAL_BOD2_LEVEL_6 /**< BOD event Level 6 */
123 #define APP_BOD_EVENT_LEVEL_7 HAL_BOD2_LEVEL_7 /**< BOD event Level 7 */
124 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR5526X)
125 #define APP_BOD_EVENT_LEVEL_8 HAL_BOD2_LEVEL_8 /**< BOD event Level 8 */
126 #define APP_BOD_EVENT_LEVEL_9 HAL_BOD2_LEVEL_9 /**< BOD event Level 9 */
127 #define APP_BOD_EVENT_LEVEL_10 HAL_BOD2_LEVEL_10 /**< BOD event Level 10 */
128 #define APP_BOD_EVENT_LEVEL_11 HAL_BOD2_LEVEL_11 /**< BOD event Level 11 */
129 #define APP_BOD_EVENT_LEVEL_12 HAL_BOD2_LEVEL_12 /**< BOD event Level 12 */
130 #define APP_BOD_EVENT_LEVEL_13 HAL_BOD2_LEVEL_13 /**< BOD event Level 13 */
131 #define APP_BOD_EVENT_LEVEL_14 HAL_BOD2_LEVEL_14 /**< BOD event Level 14 */
132 #define APP_BOD_EVENT_LEVEL_15 HAL_BOD2_LEVEL_15 /**< BOD event Level 15 */
133 #endif
134 /** @} */
135
136 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR5332X)
137 /** @defgroup APP_BOD_EVENT_AUTO_POWER_BYPASS_ENABLE event enable
138 * @{
139 */
140 #define APP_BOD_EVENT_AUTO_POWER_BYPASS_ENABLE HAL_BOD2_AUTO_POWER_BYPASS_ENABLE /**< BOD event enable */
141 #define APP_BOD_EVENT_AUTO_POWER_BYPASS_DISABLE HAL_BOD2_AUTO_POWER_BYPASS_DISABLE /**< BOD event disable */
142 /** @} */
143
144
145 #endif
146
147 /** @} */
148 /** @} */
149
150 /** @addtogroup APP_BOD_STRUCTURES Structures
151 * @{
152 */
153
154 /**
155 * @brief BOD event structure definition
156 */
157 typedef struct
158 {
159 app_bod_evt_type_t type; /**< Type of event. */
160 } app_bod_evt_t;
161
162 /** @} */
163
164 /** @addtogroup APP_BOD_TYPEDEFS Type definitions
165 * @{
166 */
167 /**
168 * @brief BOD event callback definition
169 */
170 typedef void (*app_bod_evt_handler_t)(app_bod_evt_t *p_evt);
171
172 /** @} */
173
174 /** @addtogroup APP_BOD_STRUCTURES Structures
175 * @{
176 */
177
178 /**
179 * @brief BOD device structure definition
180 */
181 typedef struct
182 {
183 app_bod_evt_handler_t evt_handler; /**< BOD event callback. */
184 bod_handle_t handle; /**< BOD handle Structure. */
185 app_bod_state_t bod_state; /**< App bod state types. */
186 }bod_env_t;
187
188 /**
189 * @brief BOD parameters structure definition
190 */
191 typedef struct
192 {
193 bod_init_t init; /**< BOD init parameters. */
194 bod_env_t bod_env; /**< BOD device structure. */
195 } app_bod_params_t;
196
197 /** @} */
198
199
200 /* Exported functions --------------------------------------------------------*/
201 /** @addtogroup APP_BOD_DRIVER_FUNCTIONS Functions
202 * @{
203 */
204 /**
205 ****************************************************************************************
206 * @brief Initialize the APP BOD DRIVER.
207 *
208 * @param[in] p_params: Pointer to app_bod_params_t parameter which contains the
209 * configuration information for the specified BOD module.
210 * @param[in] evt_handler: BOD user callback function.
211 *
212 * @return Result of initialization.
213 ****************************************************************************************
214 */
215 uint16_t app_bod_init(app_bod_params_t *p_params, app_bod_evt_handler_t evt_handler);
216
217 /**
218 ****************************************************************************************
219 * @brief De-initialize the APP BOD DRIVER.
220 *
221 * @return Result of De-initialization.
222 ****************************************************************************************
223 */
224 uint16_t app_bod_deinit(void);
225
226 /**
227 ****************************************************************************************
228 * @brief Enable or disable hardware BOD.
229 *
230 * @param[in] enable: bod enable flag. the value can be APP_BOD_ENABLE or APP_BOD_DISABLE.
231 *
232 * @return Result of operation.
233 ****************************************************************************************
234 */
235 uint16_t app_bod_enable(uint8_t enable);
236
237 /**
238 ****************************************************************************************
239 * @brief Enable or disable BOD Event.
240 *
241 * @param[in] enable: bod event enable flag. the value can be APP_BOD_EVENT_ENABLE or APP_BOD_EVENT_DISABLE.
242 *
243 * @return Result of operation.
244 ****************************************************************************************
245 */
246 uint16_t app_bod_event_enable(uint8_t enable);
247
248 /**
249 ****************************************************************************************
250 * @brief Set BOD EVENT control level..
251 *
252 * @param[in] level: the level of bod event control.the value range between 0x0 ~ 0xF.
253 *
254 * @return Result of operation.
255 ****************************************************************************************
256 */
257 uint16_t app_bod_event_set_level(uint8_t level);
258
259 /**
260 ****************************************************************************************
261 * @brief Enable or disable static mode.
262 *
263 * @param[in] enable: static mode enable flag. the value can be APP_BOD_STATIC_ENABLE or APP_BOD_STATIC_DISABLE.
264 *
265 * @return Result of operation.
266 ****************************************************************************************
267 */
268 uint16_t app_bod_static_mode_enable(uint8_t enable);
269
270 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR5332X)
271 /**
272 ****************************************************************************************
273 * @brief Enable or disable BOD EVENT auto power bypass mode.
274 *
275 * @param[in] enable: static mode enable flag. the value can be APP_BOD_EVENT_AUTO_POWER_BYPASS_ENABLE or APP_BOD_EVENT_AUTO_POWER_BYPASS_DISABLE.
276 *
277 * @return Result of operation.
278 ****************************************************************************************
279 */
280 uint16_t app_bod_event_auto_power_bypass_enable(uint8_t enable);
281
282 #endif
283
284 /** @} */
285
286 #ifdef __cplusplus
287 }
288 #endif
289
290 /** @} */
291 /** @} */
292 /** @} */
293
294 #endif //END #ifdef HAL_BOD_MODULE_ENABLED
295 #endif //END #ifndef _APP_BOD_H_
_bod_handle
BOD handle Structure definition.
Definition: gr533x_hal_bod.h:78
app_bod_init
uint16_t app_bod_init(app_bod_params_t *p_params, app_bod_evt_handler_t evt_handler)
Initialize the APP BOD DRIVER.
app_bod_static_mode_enable
uint16_t app_bod_static_mode_enable(uint8_t enable)
Enable or disable static mode.
app_bod_evt_t
BOD event structure definition.
Definition: app_bod.h:158
APP_BOD_EVT_REMOVED
@ APP_BOD_EVT_REMOVED
Definition: app_bod.h:71
bod_env_t::handle
bod_handle_t handle
Definition: app_bod.h:184
app_bod_params_t::init
bod_init_t init
Definition: app_bod.h:193
app_bod_params_t
BOD parameters structure definition.
Definition: app_bod.h:192
app_bod_enable
uint16_t app_bod_enable(uint8_t enable)
Enable or disable hardware BOD.
bod_env_t
BOD device structure definition.
Definition: app_bod.h:182
_ll_bod_init
LL BOD init Structure definition.
Definition: gr533x_ll_bod.h:75
app_bod_event_set_level
uint16_t app_bod_event_set_level(uint8_t level)
Set BOD EVENT control level..
APP_BOD_INVALID
@ APP_BOD_INVALID
Definition: app_bod.h:77
bod_env_t::bod_state
app_bod_state_t bod_state
Definition: app_bod.h:185
app_bod_params_t::bod_env
bod_env_t bod_env
Definition: app_bod.h:194
grx_hal.h
This file contains all the functions prototypes for the HAL module driver.
APP_BOD_EVT_TRIGGERED
@ APP_BOD_EVT_TRIGGERED
Definition: app_bod.h:70
app_bod_event_enable
uint16_t app_bod_event_enable(uint8_t enable)
Enable or disable BOD Event.
app_bod_evt_t::type
app_bod_evt_type_t type
Definition: app_bod.h:159
app_bod_evt_handler_t
void(* app_bod_evt_handler_t)(app_bod_evt_t *p_evt)
BOD event callback definition.
Definition: app_bod.h:170
app_bod_evt_type_t
app_bod_evt_type_t
BOD event Enumerations definition.
Definition: app_bod.h:69
app_bod_deinit
uint16_t app_bod_deinit(void)
De-initialize the APP BOD DRIVER.
app_bod_state_t
app_bod_state_t
App bod state types.
Definition: app_bod.h:76
APP_BOD_ACTIVITY
@ APP_BOD_ACTIVITY
Definition: app_bod.h:78
app_drv_error.h
Header file of app driver error code.
app_drv_config.h
Header file of app driver config code.
bod_env_t::evt_handler
app_bod_evt_handler_t evt_handler
Definition: app_bod.h:183