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_EVENT_LEVEL BOD event level
107  * @{
108  */
109 #define APP_BOD_EVENT_LEVEL_0 HAL_BOD2_LEVEL_0 /**< BOD event Level 0 */
110 #define APP_BOD_EVENT_LEVEL_1 HAL_BOD2_LEVEL_1 /**< BOD event Level 1 */
111 #define APP_BOD_EVENT_LEVEL_2 HAL_BOD2_LEVEL_2 /**< BOD event Level 2 */
112 #define APP_BOD_EVENT_LEVEL_3 HAL_BOD2_LEVEL_3 /**< BOD event Level 3 */
113 #define APP_BOD_EVENT_LEVEL_4 HAL_BOD2_LEVEL_4 /**< BOD event Level 4 */
114 #define APP_BOD_EVENT_LEVEL_5 HAL_BOD2_LEVEL_5 /**< BOD event Level 5 */
115 #define APP_BOD_EVENT_LEVEL_6 HAL_BOD2_LEVEL_6 /**< BOD event Level 6 */
116 #define APP_BOD_EVENT_LEVEL_7 HAL_BOD2_LEVEL_7 /**< BOD event Level 7 */
117 #define APP_BOD_EVENT_LEVEL_8 HAL_BOD2_LEVEL_8 /**< BOD event Level 8 */
118 #define APP_BOD_EVENT_LEVEL_9 HAL_BOD2_LEVEL_9 /**< BOD event Level 9 */
119 #define APP_BOD_EVENT_LEVEL_10 HAL_BOD2_LEVEL_10 /**< BOD event Level 10 */
120 #define APP_BOD_EVENT_LEVEL_11 HAL_BOD2_LEVEL_11 /**< BOD event Level 11 */
121 #define APP_BOD_EVENT_LEVEL_12 HAL_BOD2_LEVEL_12 /**< BOD event Level 12 */
122 #define APP_BOD_EVENT_LEVEL_13 HAL_BOD2_LEVEL_13 /**< BOD event Level 13 */
123 #define APP_BOD_EVENT_LEVEL_14 HAL_BOD2_LEVEL_14 /**< BOD event Level 14 */
124 #define APP_BOD_EVENT_LEVEL_15 HAL_BOD2_LEVEL_15 /**< BOD event Level 15 */
125 /** @} */
126 /** @} */
127 /** @} */
128 
129 
130 /** @addtogroup APP_BOD_STRUCTURES Structures
131  * @{
132  */
133 
134 /**
135  * @brief BOD event structure definition
136  */
137 typedef struct
138 {
139  app_bod_evt_type_t type; /**< Type of event. */
140 } app_bod_evt_t;
141 
142 /** @} */
143 
144 /** @addtogroup APP_BOD_TYPEDEFS Type definitions
145  * @{
146  */
147 /**
148  * @brief BOD event callback definition
149  */
150 typedef void (*app_bod_evt_handler_t)(app_bod_evt_t *p_evt);
151 
152 /** @} */
153 
154 /** @addtogroup APP_BOD_STRUCTURES Structures
155  * @{
156  */
157 
158 /**
159  * @brief BOD device structure definition
160  */
161 typedef struct
162 {
163  app_bod_evt_handler_t evt_handler; /**< BOD event callback. */
164  bod_handle_t handle; /**< BOD handle Structure. */
165  app_bod_state_t bod_state; /**< App bod state types. */
166 }bod_env_t;
167 
168 /**
169  * @brief BOD parameters structure definition
170  */
171 typedef struct
172 {
173  bod_init_t init; /**< BOD init parameters. */
174  bod_env_t bod_env; /**< BOD device structure. */
176 
177 /** @} */
178 
179 
180 /* Exported functions --------------------------------------------------------*/
181 /** @addtogroup APP_BOD_DRIVER_FUNCTIONS Functions
182  * @{
183  */
184 /**
185  ****************************************************************************************
186  * @brief Initialize the APP BOD DRIVER.
187  *
188  * @param[in] p_params: Pointer to app_bod_params_t parameter which contains the
189  * configuration information for the specified BOD module.
190  * @param[in] evt_handler: BOD user callback function.
191  *
192  * @return Result of initialization.
193  ****************************************************************************************
194  */
195 uint16_t app_bod_init(app_bod_params_t *p_params, app_bod_evt_handler_t evt_handler);
196 
197 /**
198  ****************************************************************************************
199  * @brief De-initialize the APP BOD DRIVER.
200  *
201  * @return Result of De-initialization.
202  ****************************************************************************************
203  */
204 uint16_t app_bod_deinit(void);
205 
206 /**
207  ****************************************************************************************
208  * @brief Enable or disable hardware BOD.
209  *
210  * @param[in] enable: bod enable flag. the value can be APP_BOD_ENABLE or APP_BOD_DISABLE.
211  *
212  * @return Result of operation.
213  ****************************************************************************************
214  */
215 uint16_t app_bod_enable(uint8_t enable);
216 
217 /**
218  ****************************************************************************************
219  * @brief Enable or disable BOD Event.
220  *
221  * @param[in] enable: bod event enable flag. the value can be APP_BOD_EVENT_ENABLE or APP_BOD_EVENT_DISABLE.
222  *
223  * @return Result of operation.
224  ****************************************************************************************
225  */
226 uint16_t app_bod_event_enable(uint8_t enable);
227 
228 /**
229  ****************************************************************************************
230  * @brief Set BOD EVENT control level..
231  *
232  * @param[in] level: the level of bod event control.the value range between 0x0 ~ 0xF.
233  *
234  * @return Result of operation.
235  ****************************************************************************************
236  */
237 uint16_t app_bod_event_set_level(uint8_t level);
238 
239 /** @} */
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 
245 /** @} */
246 /** @} */
247 /** @} */
248 
249 #endif //END #ifdef HAL_BOD_MODULE_ENABLED
250 #endif //END #ifndef _APP_BOD_H_
_bod_handle
BOD handle Structure definition.
Definition: gr55xx_hal_bod.h:84
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_evt_t
BOD event structure definition.
Definition: app_bod.h:138
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:164
app_bod_params_t::init
bod_init_t init
Definition: app_bod.h:173
app_bod_params_t
BOD parameters structure definition.
Definition: app_bod.h:172
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:162
_ll_bod_init
LL BOD init Structure definition.
Definition: gr55xx_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:165
app_bod_params_t::bod_env
bod_env_t bod_env
Definition: app_bod.h:174
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:139
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:150
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:163