app_comp.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file app_comp.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of COMP 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
38 /** @addtogroup PERIPHERAL Peripheral Driver
39 * @{
40 */
41
42 /** @addtogroup APP_DRIVER APP DRIVER
43 * @{
44 */
45
46 /** @defgroup APP_COMP COMP
47 * @brief COMP APP module driver.
48 * @{
49 */
50
51
52 #ifndef _APP_COMP_PUB_H_
53 #define _APP_COMP_PUB_H_
54
55 #include "grx_hal.h"
56 #include "app_drv_error.h"
57 #include "app_drv_config.h"
58 #include "app_io.h"
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 #ifdef HAL_COMP_MODULE_ENABLED
65
66 /** @addtogroup APP_COMP_ENUM Enumerations
67 * @{
68 */
69 /**
70 * @brief APP COMP event Enumerations definition
71 */
72 typedef enum
73 {
74 #if (APP_DRIVER_CHIP_TYPE != APP_DRIVER_GR551X)
75 APP_COMP_EVT_RISING,
76 APP_COMP_EVT_FALLING,
77 #else
78 APP_COMP_EVT_DONE,
79 #endif
80 APP_COMP_EVT_ERROR
81 } app_comp_evt_t;
82 /** @} */
83
84 /** @addtogroup APP_COMP_TYPEDEFS Type definitions
85 * @{
86 */
87 /**
88 * @brief COMP event callback definition
89 */
90 typedef void (*app_comp_evt_handler_t)(app_comp_evt_t *p_evt);
91 /** @} */
92
93 /** @addtogroup APP_COMP_STRUCTURES Structures
94 * @{
95 */
96 /**
97 * @brief COMP pins Structures
98 */
99 typedef struct
100 {
101 app_io_type_t type; /**< Specifies the type of COMP IO. */
102 app_io_mux_t mux; /**< Specifies the Peripheral to be connected to the selected pins. */
103 uint32_t pin; /**< Specifies the IO pins to be configured.
104 This parameter can be any value of @ref GR5xxx_pins. */
105 } app_comp_pin_t;
106
107 /**
108 * @brief COMP pins config Structures
109 */
110 typedef struct
111 {
112 app_comp_pin_t input; /**< Set the configuration of input pin. */
113 app_comp_pin_t vref; /**< Set the configuration of reference pin. */
114 } app_comp_pin_cfg_t;
115
116 /** @} */
117
118 /** @addtogroup APP_COMP_ENUM Enumerations
119 * @{
120 */
121 /**
122 * @brief App COMP state types
123 */
124 typedef enum
125 {
126 APP_COMP_INVALID = 0,
127 APP_COMP_ACTIVITY,
128 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
129 APP_COMP_SLEEP,
130 #endif
131 } app_comp_state_t;
132
133 /** @} */
134
135 /** @addtogroup APP_COMP_STRUCTURES Structures
136 * @{
137 */
138 /**
139 * @brief COMP device structure definition
140 */
141 typedef struct
142 {
143 app_comp_evt_handler_t evt_handler; /**< COMP event callback definition. */
144 comp_handle_t handle; /**< COMP handle definition. */
145 app_comp_pin_cfg_t *p_pin_cfg; /**< COMP pins config Structures. */
146 app_comp_state_t comp_state; /**< COMP state types. */
147 }comp_env_t;
148
149 /**
150 * @brief COMP parameters structure definition
151 */
152 typedef struct
153 {
154 app_comp_pin_cfg_t pin_cfg; /**< the pin configuration information for the specified COMP module. */
155 comp_init_t init; /**< COMP configuration parameters. */
156 comp_env_t comp_env; /**< COMP device structure definition. */
157 } app_comp_params_t;
158
159
160 /** @} */
161
162
163
164 /* Exported functions --------------------------------------------------------*/
165 /** @addtogroup APP_COMP_DRIVER_FUNCTIONS Functions
166 * @{
167 */
168 /**
169 ****************************************************************************************
170 * @brief Initialize the APP COMP DRIVER according to the specified parameters
171 * in the app_comp_params_t and app_comp_evt_handler_t.
172 *
173 * @param[in] p_params: Pointer to app_comp_params_t parameter which contains the
174 * configuration information for the specified COMP module.
175 * @param[in] evt_handler: COMP user callback function.
176 *
177 * @return Result of initialization.
178 ****************************************************************************************
179 */
180 uint16_t app_comp_init(app_comp_params_t *p_params, app_comp_evt_handler_t evt_handler);
181
182 /**
183 ****************************************************************************************
184 * @brief De-initialize the APP COMP DRIVER peripheral.
185 *
186 * @return Result of De-initialization.
187 ****************************************************************************************
188 */
189 uint16_t app_comp_deinit(void);
190
191 /**
192 ****************************************************************************************
193 * @brief Start the comparator.
194 *
195 @return Result of initialization.
196 ****************************************************************************************
197 */
198 uint16_t app_comp_start(void);
199
200 /**
201 ****************************************************************************************
202 * @brief Stop the comparator.
203 *
204 @return Result of initialization.
205 ****************************************************************************************
206 */
207 uint16_t app_comp_stop(void);
208
209 /**
210 ****************************************************************************************
211 * @brief Return the COMP handle.
212 *
213 * @return Pointer to the COMP handle.
214 ****************************************************************************************
215 */
216 comp_handle_t *app_comp_get_handle(void);
217
218 /** @} */
219
220 #endif
221
222 #ifdef __cplusplus
223 }
224 #endif
225
226 #endif
227
228 /** @} */
229
230 /** @} */
231
232 /** @} */
233
APP_COMP_EVT_ERROR
@ APP_COMP_EVT_ERROR
Definition: app_comp.h:80
app_comp_stop
uint16_t app_comp_stop(void)
Stop the comparator.
app_comp_evt_handler_t
void(* app_comp_evt_handler_t)(app_comp_evt_t *p_evt)
COMP event callback definition.
Definition: app_comp.h:90
app_comp_get_handle
comp_handle_t * app_comp_get_handle(void)
Return the COMP handle.
APP_COMP_INVALID
@ APP_COMP_INVALID
Definition: app_comp.h:126
comp_env_t::evt_handler
app_comp_evt_handler_t evt_handler
COMP event callback definition.
Definition: app_comp.h:143
_ll_comp_init
LL COMP init Structure definition.
Definition: gr55xx_ll_comp.h:77
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:147
comp_env_t::comp_state
app_comp_state_t comp_state
COMP state types.
Definition: app_comp.h:146
app_comp_state_t
app_comp_state_t
App COMP state types.
Definition: app_comp.h:125
_comp_handle
COMP handle Structure definition.
Definition: gr55xx_hal_comp.h:109
app_comp_params_t::pin_cfg
app_comp_pin_cfg_t pin_cfg
the pin configuration information for the specified COMP module.
Definition: app_comp.h:154
app_io.h
Header file containing functions prototypes of GPIO app library.
app_comp_pin_t
COMP pins Structures.
Definition: app_comp.h:100
app_comp_pin_t::mux
app_io_mux_t mux
Specifies the Peripheral to be connected to the selected pins.
Definition: app_comp.h:102
app_comp_deinit
uint16_t app_comp_deinit(void)
De-initialize the APP COMP DRIVER peripheral.
app_comp_start
uint16_t app_comp_start(void)
Start the comparator.
app_comp_params_t::comp_env
comp_env_t comp_env
COMP device structure definition.
Definition: app_comp.h:156
grx_hal.h
This file contains all the functions prototypes for the HAL module driver.
APP_COMP_ACTIVITY
@ APP_COMP_ACTIVITY
Definition: app_comp.h:127
app_comp_pin_cfg_t::vref
app_comp_pin_t vref
Set the configuration of reference pin.
Definition: app_comp.h:113
comp_env_t::p_pin_cfg
app_comp_pin_cfg_t * p_pin_cfg
COMP pins config Structures.
Definition: app_comp.h:145
app_comp_params_t::init
comp_init_t init
COMP configuration parameters.
Definition: app_comp.h:155
app_comp_init
uint16_t app_comp_init(app_comp_params_t *p_params, app_comp_evt_handler_t evt_handler)
Initialize the APP COMP DRIVER according to the specified parameters in the app_comp_params_t and app...
app_comp_evt_t
app_comp_evt_t
APP COMP event Enumerations definition.
Definition: app_comp.h:73
app_comp_pin_cfg_t
COMP pins config Structures.
Definition: app_comp.h:111
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:255
app_drv_error.h
Header file of app driver error code.
app_drv_config.h
Header file of app driver config code.
app_comp_params_t
COMP parameters structure definition.
Definition: app_comp.h:153
APP_COMP_EVT_DONE
@ APP_COMP_EVT_DONE
Definition: app_comp.h:78
app_comp_pin_t::type
app_io_type_t type
Specifies the type of COMP IO.
Definition: app_comp.h:101
app_comp_pin_cfg_t::input
app_comp_pin_t input
Set the configuration of input pin.
Definition: app_comp.h:112
app_comp_pin_t::pin
uint32_t pin
Specifies the IO pins to be configured.
Definition: app_comp.h:103
comp_env_t::handle
comp_handle_t handle
COMP handle definition.
Definition: app_comp.h:144
comp_env_t
COMP device structure definition.
Definition: app_comp.h:142