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_H_
53 #define _APP_COMP_H_
54
55 #include "gr55xx_hal.h"
56 #include "app_drv_error.h"
57 #include "app_io.h"
58 #ifdef ENV_USE_FREERTOS
59 #include "app_rtos_cfg.h"
60 #endif
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 #ifdef HAL_COMP_MODULE_ENABLED
67
68 /** @addtogroup APP_COMP_ENUM Enumerations
69 * @{
70 */
71 /**
72 * @brief COMP event Enumerations definition
73 */
74 typedef enum
75 {
76 APP_COMP_EVT_DONE,
77 APP_COMP_EVT_ERROR
78 } app_comp_evt_t;
79 /** @} */
80
81
82 /** @addtogroup APP_COMP_STRUCTURES Structures
83 * @{
84 */
85 /**
86 * @brief COMP pins Structures
87 */
88 typedef struct
89 {
90 app_io_type_t type; /**< Specifies the type of COMP IO. */
91 app_io_mux_t mux; /**< Specifies the Peripheral to be connected to the selected pins. */
92 uint32_t pin; /**< Specifies the IO pins to be configured.
93 This parameter can be any value of @ref GR551x_pins. */
94 } app_comp_pin_t;
95
96 /**
97 * @brief COMP pins config Structures
98 */
99 typedef struct
100 {
101 app_comp_pin_t input; /**< Set the configuration of input pin. */
102 app_comp_pin_t vref; /**< Set the configuration of reference pin. */
103 } app_comp_pin_cfg_t;
104
105 /**
106 * @brief COMP parameters structure definition
107 */
108 typedef struct
109 {
110 app_comp_pin_cfg_t pin_cfg; /**< the pin configuration information for the specified COMP module. */
111 comp_init_t init; /**< COMP configuration parameters. */
112 } app_comp_params_t;
113
114 /**
115 * @brief COMP event callback definition
116 */
117 typedef void (*app_comp_evt_handler_t)(app_comp_evt_t *p_evt);
118 /** @} */
119
120
121
122 /* Exported functions --------------------------------------------------------*/
123 /** @addtogroup APP_COMP_DRIVER_FUNCTIONS Functions
124 * @{
125 */
126 /**
127 ****************************************************************************************
128 * @brief Initialize the APP COMP DRIVER according to the specified parameters
129 * in the app_comp_params_t and app_comp_evt_handler_t.
130 *
131 * @param[in] p_params: Pointer to app_comp_params_t parameter which contains the
132 * configuration information for the specified COMP module.
133 * @param[in] evt_handler: COMP user callback function.
134 *
135 * @return Result of initialization.
136 ****************************************************************************************
137 */
138 uint16_t app_comp_init(app_comp_params_t *p_params, app_comp_evt_handler_t evt_handler);
139
140 /**
141 ****************************************************************************************
142 * @brief De-initialize the APP COMP DRIVER peripheral.
143 *
144 * @return Result of De-initialization.
145 ****************************************************************************************
146 */
147 uint16_t app_comp_deinit(void);
148
149 /**
150 ****************************************************************************************
151 * @brief Start the comparator.
152 *
153 @return Result of initialization.
154 ****************************************************************************************
155 */
156 uint16_t app_comp_start(void);
157
158 /**
159 ****************************************************************************************
160 * @brief Stop the comparator.
161 *
162 @return Result of initialization.
163 ****************************************************************************************
164 */
165 uint16_t app_comp_stop(void);
166
167 /**
168 ****************************************************************************************
169 * @brief Return the COMP handle.
170 *
171 * @return Pointer to the COMP handle.
172 ****************************************************************************************
173 */
174 comp_handle_t *app_comp_get_handle(void);
175
176 #ifdef ENV_RTOS_USE_SEMP
177
178 /**
179 ****************************************************************************************
180 * @brief [RTOS] Start the comparator.
181 *
182 @return Result of initialization.
183 ****************************************************************************************
184 */
185 uint16_t app_comp_sem_start(void);
186
187 #endif
188
189 /** @} */
190
191 #endif
192
193 #ifdef __cplusplus
194 }
195 #endif
196
197 #endif
198
199 /** @} */
200 /** @} */
201 /** @} */
APP_COMP_EVT_ERROR
@ APP_COMP_EVT_ERROR
Definition: app_comp.h:77
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:117
app_comp_stop
uint16_t app_comp_stop(void)
Stop the comparator.
app_comp_get_handle
comp_handle_t * app_comp_get_handle(void)
Return the COMP handle.
_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:141
_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:110
app_io.h
Header file containing functions prototypes of GPIO app library.
app_comp_pin_t
COMP pins Structures.
Definition: app_comp.h:89
app_comp_pin_t::mux
app_io_mux_t mux
Specifies the Peripheral to be connected to the selected pins.
Definition: app_comp.h:91
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_pin_cfg_t::vref
app_comp_pin_t vref
Set the configuration of reference pin.
Definition: app_comp.h:102
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_comp_params_t::init
comp_init_t init
COMP configuration parameters.
Definition: app_comp.h:111
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:75
app_comp_pin_cfg_t
COMP pins config Structures.
Definition: app_comp.h:100
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
app_rtos_cfg.h
Header file of app rtos config code.
app_drv_error.h
Header file of app driver error code.
app_comp_params_t
COMP parameters structure definition.
Definition: app_comp.h:109
APP_COMP_EVT_DONE
@ APP_COMP_EVT_DONE
Definition: app_comp.h:76
app_comp_pin_t::type
app_io_type_t type
Specifies the type of COMP IO.
Definition: app_comp.h:90
app_comp_pin_cfg_t::input
app_comp_pin_t input
Set the configuration of input pin.
Definition: app_comp.h:101
app_comp_pin_t::pin
uint32_t pin
Specifies the IO pins to be configured.
Definition: app_comp.h:92