gr55xx_hal_comp.h
Go to the documentation of this file.
1
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_COMP_H__
53 #define __GR55xx_HAL_COMP_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_comp.h"
61 #include "gr55xx_hal_def.h"
62
63 /* Exported types ------------------------------------------------------------*/
75 typedef enum
76 {
77 HAL_COMP_STATE_RESET = 0x00,
78 HAL_COMP_STATE_READY = 0x01,
79 HAL_COMP_STATE_BUSY = 0x02,
80 HAL_COMP_STATE_ERROR = 0x04
81 } hal_comp_state_t;
82
98 typedef ll_comp_init_t comp_init_t;
108 typedef struct _comp_handle
109 {
110 comp_init_t init;
112 __IO hal_lock_t lock;
114 __IO hal_comp_state_t state;
116 __IO uint32_t error_code;
118 uint32_t retention[1];
120 } comp_handle_t;
136 typedef struct _comp_callback
137 {
138 void (*comp_msp_init)(comp_handle_t *p_comp);
139 void (*comp_msp_deinit)(comp_handle_t *p_comp);
140 void (*comp_trigger_callback)(comp_handle_t *p_comp);
141 } comp_callback_t;
142
153 /* Exported constants --------------------------------------------------------*/
161 #define HAL_COMP_ERROR_NONE ((uint32_t)0x00000000)
162 #define HAL_COMP_ERROR_TIMEOUT ((uint32_t)0x00000001)
163 #define HAL_COMP_ERROR_INVALID_PARAM ((uint32_t)0x00000002)
170 #define COMP_INPUT_SRC_IO0 LL_COMP_INPUT_SRC_IO0
171 #define COMP_INPUT_SRC_IO1 LL_COMP_INPUT_SRC_IO1
172 #define COMP_INPUT_SRC_IO2 LL_COMP_INPUT_SRC_IO2
173 #define COMP_INPUT_SRC_IO3 LL_COMP_INPUT_SRC_IO3
174 #define COMP_INPUT_SRC_IO4 LL_COMP_INPUT_SRC_IO4
180 #define COMP_REF_SRC_IO0 LL_COMP_REF_SRC_IO0
181 #define COMP_REF_SRC_IO1 LL_COMP_REF_SRC_IO1
182 #define COMP_REF_SRC_IO2 LL_COMP_REF_SRC_IO2
183 #define COMP_REF_SRC_IO3 LL_COMP_REF_SRC_IO3
184 #define COMP_REF_SRC_IO4 LL_COMP_REF_SRC_IO4
185 #define COMP_REF_SRC_VBAT LL_COMP_REF_SRC_VBAT
186 #define COMP_REF_SRC_VREF LL_COMP_REF_SRC_VREF
192 #define COMP_DEFAULT_CONFIG LL_COMP_DEFAULT_CONFIG
193
195 /* Private macros ------------------------------------------------------------*/
205 #define IS_COMP_INPUT(__INPUT__) (((__INPUT__) == COMP_INPUT_SRC_IO0) || \
206 ((__INPUT__) == COMP_INPUT_SRC_IO1) || \
207 ((__INPUT__) == COMP_INPUT_SRC_IO2) || \
208 ((__INPUT__) == COMP_INPUT_SRC_IO3) || \
209 ((__INPUT__) == COMP_INPUT_SRC_IO4))
210
216 #define IS_COMP_REF(__INPUT__) (((__INPUT__) == COMP_REF_SRC_IO0) || \
217 ((__INPUT__) == COMP_REF_SRC_IO1) || \
218 ((__INPUT__) == COMP_REF_SRC_IO2) || \
219 ((__INPUT__) == COMP_REF_SRC_IO3) || \
220 ((__INPUT__) == COMP_REF_SRC_IO4) || \
221 ((__INPUT__) == COMP_REF_SRC_VBAT) || \
222 ((__INPUT__) == COMP_REF_SRC_VREF))
223
228 /* Exported functions --------------------------------------------------------*/
252 hal_status_t hal_comp_init(comp_handle_t *p_comp);
253
267 hal_status_t hal_comp_deinit(comp_handle_t *p_comp);
268
280 void hal_comp_msp_init(comp_handle_t *p_comp);
281
293 void hal_comp_msp_deinit(comp_handle_t *p_comp);
294
315 hal_status_t hal_comp_start(comp_handle_t *p_comp);
316
330 hal_status_t hal_comp_stop(comp_handle_t *p_comp);
331
346 void hal_comp_irq_handler(comp_handle_t *p_comp);
347
359 void hal_comp_trigger_callback(comp_handle_t *p_comp);
360
391 hal_comp_state_t hal_comp_get_state(comp_handle_t *p_comp);
392
403 uint32_t hal_comp_get_error(comp_handle_t *p_comp);
404
416 hal_status_t hal_comp_suspend_reg(comp_handle_t *p_comp);
417
430 hal_status_t hal_comp_resume_reg(comp_handle_t *p_comp);
431
438 #ifdef __cplusplus
439 }
440 #endif
441
442 #endif /* __GR55xx_HAL_COMP_H__ */
443
hal_comp_irq_handler
void hal_comp_irq_handler(comp_handle_t *p_comp)
Handle COMP interrupt request.
HAL_COMP_STATE_ERROR
@ HAL_COMP_STATE_ERROR
Definition: gr55xx_hal_comp.h:80
_comp_handle::retention
uint32_t retention[1]
Definition: gr55xx_hal_comp.h:118
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_comp_callback::comp_msp_deinit
void(* comp_msp_deinit)(comp_handle_t *p_comp)
Definition: gr55xx_hal_comp.h:139
_comp_callback
HAL COMP Callback function definition.
Definition: gr55xx_hal_comp.h:137
hal_comp_init
hal_status_t hal_comp_init(comp_handle_t *p_comp)
Initialize the COMP according to the specified parameters in the comp_init_t and initialize the assoc...
hal_comp_get_error
uint32_t hal_comp_get_error(comp_handle_t *p_comp)
Return the COMP error code.
hal_comp_resume_reg
hal_status_t hal_comp_resume_reg(comp_handle_t *p_comp)
Restore some registers related to COMP configuration after sleep. This function must be used in conju...
_comp_callback::comp_trigger_callback
void(* comp_trigger_callback)(comp_handle_t *p_comp)
Definition: gr55xx_hal_comp.h:140
hal_comp_state_t
hal_comp_state_t
HAL COMP State Enumerations definition.
Definition: gr55xx_hal_comp.h:76
_ll_comp_init
LL COMP init Structure definition.
Definition: gr55xx_ll_comp.h:77
_comp_callback::comp_msp_init
void(* comp_msp_init)(comp_handle_t *p_comp)
Definition: gr55xx_hal_comp.h:138
_comp_handle::error_code
__IO uint32_t error_code
Definition: gr55xx_hal_comp.h:116
hal_comp_get_state
hal_comp_state_t hal_comp_get_state(comp_handle_t *p_comp)
Return the COMP handle state.
_comp_handle
COMP handle Structure definition.
Definition: gr55xx_hal_comp.h:109
comp_init_t
ll_comp_init_t comp_init_t
COMP init structure definition.
Definition: gr55xx_hal_comp.h:98
comp_handle_t
struct _comp_handle comp_handle_t
COMP handle Structure definition.
HAL_COMP_STATE_RESET
@ HAL_COMP_STATE_RESET
Definition: gr55xx_hal_comp.h:77
hal_comp_stop
hal_status_t hal_comp_stop(comp_handle_t *p_comp)
Stop the comparator.
HAL_COMP_STATE_READY
@ HAL_COMP_STATE_READY
Definition: gr55xx_hal_comp.h:78
comp_callback_t
struct _comp_callback comp_callback_t
HAL COMP Callback function definition.
_comp_handle::init
comp_init_t init
Definition: gr55xx_hal_comp.h:110
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_comp_msp_init
void hal_comp_msp_init(comp_handle_t *p_comp)
Initialize the COMP MSP.
hal_comp_suspend_reg
hal_status_t hal_comp_suspend_reg(comp_handle_t *p_comp)
Suspend some registers related to COMP configuration before sleep.
hal_comp_trigger_callback
void hal_comp_trigger_callback(comp_handle_t *p_comp)
comparator callback.
hal_comp_msp_deinit
void hal_comp_msp_deinit(comp_handle_t *p_comp)
De-initialize the COMP MSP.
hal_comp_deinit
hal_status_t hal_comp_deinit(comp_handle_t *p_comp)
De-initialize the COMP peripheral.
HAL_COMP_STATE_BUSY
@ HAL_COMP_STATE_BUSY
Definition: gr55xx_hal_comp.h:79
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
gr55xx_ll_comp.h
Header file containing functions prototypes of COMP LL library.
_comp_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_comp.h:112
hal_comp_start
hal_status_t hal_comp_start(comp_handle_t *p_comp)
Start the comparator.
_comp_handle::state
__IO hal_comp_state_t state
Definition: gr55xx_hal_comp.h:114