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. */
73 
74 /**@brief App bod state types. */
75 typedef enum
76 {
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 #ifdef APP_BOD_LEVEL_8_15_ENABLE
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 #ifdef APP_BOD_AUTO_POWER_BYPASS_ENABLE
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 #endif
144 
145 /** @} */
146 /** @} */
147 
148 /** @addtogroup APP_BOD_STRUCTURES Structures
149  * @{
150  */
151 
152 /**
153  * @brief BOD event structure definition
154  */
155 typedef struct
156 {
157  app_bod_evt_type_t type; /**< Type of event. */
158 } app_bod_evt_t;
159 
160 /** @} */
161 
162 /** @addtogroup APP_BOD_TYPEDEFS Type definitions
163  * @{
164  */
165 /**
166  * @brief BOD event callback definition
167  */
168 typedef void (*app_bod_evt_handler_t)(app_bod_evt_t *p_evt);
169 
170 /** @} */
171 
172 /** @addtogroup APP_BOD_STRUCTURES Structures
173  * @{
174  */
175 
176 /**
177  * @brief BOD device structure definition
178  */
179 typedef struct
180 {
181  app_bod_evt_handler_t evt_handler; /**< BOD event callback. */
182  bod_handle_t handle; /**< BOD handle Structure. */
183  app_bod_state_t bod_state; /**< App bod state types. */
184 }bod_env_t;
185 
186 /**
187  * @brief BOD parameters structure definition
188  */
189 typedef struct
190 {
191  bod_init_t init; /**< BOD init parameters. */
192  bod_env_t bod_env; /**< BOD device structure. */
194 
195 /** @} */
196 
197 
198 /* Exported functions --------------------------------------------------------*/
199 /** @addtogroup APP_BOD_DRIVER_FUNCTIONS Functions
200  * @{
201  */
202 /**
203  ****************************************************************************************
204  * @brief Initialize the APP BOD DRIVER.
205  *
206  * @param[in] p_params: Pointer to app_bod_params_t parameter which contains the
207  * configuration information for the specified BOD module.
208  * @param[in] evt_handler: BOD user callback function.
209  *
210  * @return Result of initialization.
211  ****************************************************************************************
212  */
213 uint16_t app_bod_init(app_bod_params_t *p_params, app_bod_evt_handler_t evt_handler);
214 
215 /**
216  ****************************************************************************************
217  * @brief De-initialize the APP BOD DRIVER.
218  *
219  * @return Result of De-initialization.
220  ****************************************************************************************
221  */
222 uint16_t app_bod_deinit(void);
223 
224 /**
225  ****************************************************************************************
226  * @brief Enable or disable hardware BOD.
227  *
228  * @param[in] enable: bod enable flag. the value can be APP_BOD_ENABLE or APP_BOD_DISABLE.
229  *
230  * @return Result of operation.
231  ****************************************************************************************
232  */
233 uint16_t app_bod_enable(uint8_t enable);
234 
235 /**
236  ****************************************************************************************
237  * @brief Enable or disable BOD Event.
238  *
239  * @param[in] enable: bod event enable flag. the value can be APP_BOD_EVENT_ENABLE or APP_BOD_EVENT_DISABLE.
240  *
241  * @return Result of operation.
242  ****************************************************************************************
243  */
244 uint16_t app_bod_event_enable(uint8_t enable);
245 
246 /**
247  ****************************************************************************************
248  * @brief Set BOD EVENT control level..
249  *
250  * @param[in] level: the level of bod event control.the value range between 0x0 ~ 0xF.
251  *
252  * @return Result of operation.
253  ****************************************************************************************
254  */
255 uint16_t app_bod_event_set_level(uint8_t level);
256 
257 /**
258  ****************************************************************************************
259  * @brief Enable or disable static mode.
260  *
261  * @param[in] enable: static mode enable flag. the value can be APP_BOD_STATIC_ENABLE or APP_BOD_STATIC_DISABLE.
262  *
263  * @return Result of operation.
264  ****************************************************************************************
265  */
266 uint16_t app_bod_static_mode_enable(uint8_t enable);
267 
268 #ifdef APP_BOD_AUTO_POWER_BYPASS_ENABLE
269 /**
270  ****************************************************************************************
271  * @brief Enable or disable BOD EVENT auto power bypass mode.
272  *
273  * @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.
274  *
275  * @return Result of operation.
276  ****************************************************************************************
277  */
278 uint16_t app_bod_event_auto_power_bypass_enable(uint8_t enable);
279 
280 #endif
281 
282 /** @} */
283 
284 #ifdef __cplusplus
285 }
286 #endif
287 
288 /** @} */
289 /** @} */
290 /** @} */
291 
292 #endif //END #ifdef HAL_BOD_MODULE_ENABLED
293 #endif //END #ifndef _APP_BOD_H_
_bod_handle
BOD handle Structure definition.
Definition: 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:156
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:182
app_bod_params_t::init
bod_init_t init
Definition: app_bod.h:191
app_bod_params_t
BOD parameters structure definition.
Definition: app_bod.h:190
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:180
_ll_bod_init
LL BOD init Structure definition.
Definition: 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:183
app_bod_params_t::bod_env
bod_env_t bod_env
Definition: app_bod.h:192
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:157
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:168
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:181