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 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
79 #endif
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. */
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. */
115 
116 /**@brief App comp state types. */
117 typedef enum
118 {
121 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
122  APP_COMP_SLEEP,
123 #endif
125 
126 /**
127  * @brief COMP device structure definition
128  */
129 typedef struct
130 {
131  app_comp_evt_handler_t evt_handler; /**< COMP event callback definition. */
132  comp_handle_t handle; /**< COMP handle definition. */
133  app_comp_pin_cfg_t *p_pin_cfg; /**< COMP pins config Structures. */
134  app_comp_state_t comp_state; /**< COMP state types. */
135 }comp_env_t;
136 
137 /**
138  * @brief COMP parameters structure definition
139  */
140 typedef struct
141 {
142  app_comp_pin_cfg_t pin_cfg; /**< the pin configuration information for the specified COMP module. */
143  comp_init_t init; /**< COMP configuration parameters. */
144  comp_env_t comp_env; /**< COMP device structure definition. */
146 
147 
148 /** @} */
149 
150 
151 
152 /* Exported functions --------------------------------------------------------*/
153 /** @addtogroup APP_COMP_DRIVER_FUNCTIONS Functions
154  * @{
155  */
156 /**
157  ****************************************************************************************
158  * @brief Initialize the APP COMP DRIVER according to the specified parameters
159  * in the app_comp_params_t and app_comp_evt_handler_t.
160  *
161  * @param[in] p_params: Pointer to app_comp_params_t parameter which contains the
162  * configuration information for the specified COMP module.
163  * @param[in] evt_handler: COMP user callback function.
164  *
165  * @return Result of initialization.
166  ****************************************************************************************
167  */
168 uint16_t app_comp_init(app_comp_params_t *p_params, app_comp_evt_handler_t evt_handler);
169 
170 /**
171  ****************************************************************************************
172  * @brief De-initialize the APP COMP DRIVER peripheral.
173  *
174  * @return Result of De-initialization.
175  ****************************************************************************************
176  */
177 uint16_t app_comp_deinit(void);
178 
179 /**
180  ****************************************************************************************
181  * @brief Start the comparator.
182  *
183  @return Result of initialization.
184  ****************************************************************************************
185  */
186 uint16_t app_comp_start(void);
187 
188 /**
189  ****************************************************************************************
190  * @brief Stop the comparator.
191  *
192  @return Result of initialization.
193  ****************************************************************************************
194  */
195 uint16_t app_comp_stop(void);
196 
197 /**
198  ****************************************************************************************
199  * @brief Return the COMP handle.
200  *
201  * @return Pointer to the COMP handle.
202  ****************************************************************************************
203  */
205 
206 /** @} */
207 
208 #endif
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif
215 
216 /** @} */
217 
218 /** @} */
219 
220 /** @} */
221 
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:119
APP_COMP_ACTIVITY
@ APP_COMP_ACTIVITY
Definition: app_comp.h:120
comp_env_t::evt_handler
app_comp_evt_handler_t evt_handler
Definition: app_comp.h:131
_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:145
comp_env_t::comp_state
app_comp_state_t comp_state
Definition: app_comp.h:134
_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
Definition: app_comp.h:142
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
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
Definition: app_comp.h:144
grx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_comp_pin_cfg_t::vref
app_comp_pin_t vref
Definition: app_comp.h:113
comp_env_t::p_pin_cfg
app_comp_pin_cfg_t * p_pin_cfg
Definition: app_comp.h:133
app_comp_params_t::init
comp_init_t init
Definition: app_comp.h:143
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
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:253
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:141
app_comp_state_t
app_comp_state_t
App comp state types.
Definition: app_comp.h:118
APP_COMP_EVT_DONE
@ APP_COMP_EVT_DONE
Definition: app_comp.h:78
app_comp_pin_t::type
app_io_type_t type
Definition: app_comp.h:101
app_comp_pin_cfg_t::input
app_comp_pin_t input
Definition: app_comp.h:112
app_comp_pin_t::pin
uint32_t pin
Definition: app_comp.h:103
comp_env_t::handle
comp_handle_t handle
Definition: app_comp.h:132
comp_env_t
COMP device structure definition.
Definition: app_comp.h:130