gr55xx_ll_comp.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_ll_comp.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of COMP LL 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 LL_DRIVER LL Driver
43  * @{
44  */
45 
46 /** @defgroup LL_COMP COMP
47  * @brief COMP LL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55XX_LL_COMP_H__
53 #define __GR55XX_LL_COMP_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx.h"
61 
62 #if defined(AON_CTL)
63 
64 /** @defgroup COMP_LL_STRUCTURES Structures
65  * @{
66  */
67 
68 /* Exported types ------------------------------------------------------------*/
69 /** @defgroup COMP_LL_ES_INIT COMP Exported init structures
70  * @{
71  */
72 
73 /**
74  * @brief LL COMP init Structure definition
75  */
76 typedef struct _ll_comp_init
77 {
78  uint32_t input_source; /**< Specifies the input source for the comparator.
79  This parameter can be any value of @ref COMP_LL_EC_INPUT_SRC.
80 
81  This parameter can be modified afterwards using unitary function @ref ll_comp_set_input_src(). */
82 
83  uint32_t ref_source; /**< Specifies the reference source for the comparator.
84  This parameter can be any value of @ref COMP_LL_EC_INPUT_SRC.
85 
86  This parameter can be modified afterwards using unitary function @ref ll_comp_set_ref_src(). */
87  uint32_t ref_value; /*!< Specifies the value of the COMP buffered reference.
88  If ref_source select to LL_COMP_REF_SRC_VBAT, this parameter can be a value between: 0 ~ 7.
89  This parameter can be modified afterwards using unitary function @ref ll_comp_set_vbatt_lvl().
90 
91  If ref_source select to LL_COMP_REF_SRC_VREF, this parameter can be a value between: 0 ~ 255.
92  This parameter can be modified afterwards using unitary function @ref ll_comp_set_vref_lvl(). */
93  uint32_t hyst; /**< Specifies the hysteresis for the comparator.
94  This parameter can be modified afterwards using unitary function ll_comp_positive_hysteresis() and ll_comp_negative_hysteresis(). */
95 
96  uint32_t edge; /**< Specifies the wakeup edge of the comparator.
97  This parameter can be any value of @ref COMP_LL_EC_WAKEUP_EDGE. */
98 
99  uint32_t res_deg; /**< Specifies the calibration for the comparator.
100 
101  This parameter can be modified afterwards using unitary function ll_comp_positive_degeneration() and ll_comp_negative_degeneration(). */
102 } ll_comp_init_t;
103 
104 /** @} */
105 
106 /** @} */
107 
108 /**
109  * @defgroup COMP_LL_MACRO Defines
110  * @{
111  */
112 
113 /* Exported constants --------------------------------------------------------*/
114 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
115  * @{
116  */
117 
118 /** @defgroup COMP_LL_EC_INPUT_SRC COMP INPUT SOURCE
119  * @{
120  */
121 #define LL_COMP_INPUT_SRC_IO0 (0UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_0 as inputs for the comparator */
122 #define LL_COMP_INPUT_SRC_IO1 (1UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_1 as inputs for the comparator */
123 #define LL_COMP_INPUT_SRC_IO2 (2UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_2 as inputs for the comparator */
124 #define LL_COMP_INPUT_SRC_IO3 (3UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_3 as inputs for the comparator */
125 #define LL_COMP_INPUT_SRC_IO4 (4UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_4 as inputs for the comparator */
126 #define LL_COMP_INPUT_SRC_IO5 (5UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_5 as inputs for the comparator */
127 #define LL_COMP_INPUT_SRC_IO6 (6UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_6 as inputs for the comparator */
128 #define LL_COMP_INPUT_SRC_IO7 (7UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set MSIO_7 as inputs for the comparator */
129 
130 #define LL_COMP_INPUT_SRC_VBAT (9UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set VBATT as inputs for the comparator */
131 #define LL_COMP_INPUT_SRC_VREF (10UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Pos) /**< Set VREF as inputs for the comparator */
132 
133 /** @} */
134 
135 /** @defgroup COMP_LL_EC_REF_SRC COMP REF SOURCE
136  * @{
137  */
138 #define LL_COMP_REF_SRC_IO0 (0UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_0 as references for the comparator */
139 #define LL_COMP_REF_SRC_IO1 (1UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_1 as references for the comparator */
140 #define LL_COMP_REF_SRC_IO2 (2UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_2 as references for the comparator */
141 #define LL_COMP_REF_SRC_IO3 (3UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_3 as references for the comparator */
142 #define LL_COMP_REF_SRC_IO4 (4UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_4 as references for the comparator */
143 #define LL_COMP_REF_SRC_IO5 (5UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_5 as references for the comparator */
144 #define LL_COMP_REF_SRC_IO6 (6UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_6 as references for the comparator */
145 #define LL_COMP_REF_SRC_IO7 (7UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set MSIO_7 as references for the comparator */
146 
147 #define LL_COMP_REF_SRC_VBAT (9UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set VBATT as references for the comparator */
148 #define LL_COMP_REF_SRC_VREF (10UL << AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Pos) /**< Set VREF as references for the comparator */
149 /** @} */
150 
151 /** @defgroup COMP_LL_EC_HYST_SRC COMP HYST
152  * @{
153  */
154 #define LL_COMP_HYST_POSITIVE (1UL << AON_PMU_COMP_REG_1_CHANNEL_POSITIVE_HYST_Pos ) /**< Set positive side of hysteresis for the comparator */
155 #define LL_COMP_HYST_NEGATIVE (1UL << AON_PMU_COMP_REG_1_CHANNEL_NEGATIVE_HYST_Pos ) /**< Set negative side of hysteresis for the comparator */
156 
157 /** @} */
158 
159 /** @defgroup COMP_LL_COMP_RES_DEGENERATION COMP RES DEGENERATION
160  * @{
161  */
162 #define LL_COMP_RES_DEGENERATION_POSITIVE (1UL << AON_PMU_COMP_REG_1_CHANNEL_POSITIVE_RES_DEGENERATION_Pos ) /**< Set positive side of calibration for the comparator */
163 #define LL_COMP_RES_DEGENERATION_NEGATIVE (1UL << AON_PMU_COMP_REG_1_CHANNEL_NEGATIVE_RES_DEGENERATION_Pos ) /**< Set negative side of calibration for the comparator */
164 /** @} */
165 
166 /** @defgroup COMP_LL_EC_WAKEUP_EDGE COMP WAKEUP EDGE
167  * @{
168  */
169 #define LL_COMP_WAKEUP_EDGE_BOTH ( 0UL )
170 #define LL_COMP_WAKEUP_EDGE_FALLING ( 1UL )
171 #define LL_COMP_WAKEUP_EDGE_RISING ( 2UL )
172 
173 /** @} */
174 
175 /** @} */
176 
177 /* Exported macro ------------------------------------------------------------*/
178 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
179  * @{
180  */
181 
182 /** @defgroup COMP_LL_EM_WRITE_READ Common Write and read registers Macros
183  * @{
184  */
185 
186 /**
187  * @brief Write a value in COMP register
188  * @param __instance__ COMP instance
189  * @param __REG__ Register to be written
190  * @param __VALUE__ Value to be written in the register
191  * @retval None
192  */
193 #define LL_COMP_WriteReg(__instance__, __REG__, __VALUE__) WRITE_REG((__instance__)->__REG__, (__VALUE__))
194 
195 /**
196  * @brief Read a value in COMP register
197  * @param __instance__ COMP instance
198  * @param __REG__ Register to be read
199  * @retval Register value
200  */
201 #define LL_COMP_ReadReg(__instance__, __REG__) READ_REG((__instance__)->__REG__)
202 
203 /** @} */
204 
205 /** @} */
206 
207 /* Private types -------------------------------------------------------------*/
208 /* Private variables ---------------------------------------------------------*/
209 /* Private constants ---------------------------------------------------------*/
210 /* Private macros ------------------------------------------------------------*/
211 /** @defgroup COMP_LL_Private_Macros COMP Private Macros
212  * @{
213  */
214 
215 /** @defgroup COMP_LL_EC_DEFAULT_CONFIG InitStruct default configuartion
216  * @{
217  */
218 
219 /**
220  * @brief Default configuartion for initializing structure
221  */
222 #define LL_COMP_DEFAULT_CONFIG \
223 { \
224  .channel_p = LL_COMP_CHANNEL_IO0, \
225  .channel_n = LL_COMP_CHANNEL_IO1, \
226 }
227 /** @} */
228 
229 /** @} */
230 
231 /** @} */
232 
233 /* Exported functions --------------------------------------------------------*/
234 /** @defgroup COMP_LL_DRIVER_FUNCTIONS Functions
235  * @{
236  */
237 
238 /** @defgroup COMP_LL_EF_Configuration Basic Configuration
239  * @{
240  */
241 
242 /**
243  * @brief Enable COMP module.
244  *
245  * Register|BitsName
246  * --------|--------
247  * COMP_REG_0 | COMP_EN
248  *
249  * @retval None
250  */
251 __STATIC_INLINE void ll_comp_enable(void)
252 {
253  SET_BITS(AON_PMU->COMP_REG_0, AON_PMU_COMP_REG_0_WAKE_COMP_EN_Msk);
254 }
255 
256 /**
257  * @brief Disable COMP module.
258  *
259  * Register|BitsName
260  * --------|--------
261  * COMP_REG_0 | COMP_EN
262  *
263  * @retval None
264  */
265 __STATIC_INLINE void ll_comp_disable(void)
266 {
267  CLEAR_BITS(AON_PMU->COMP_REG_0, AON_PMU_COMP_REG_0_WAKE_COMP_EN_Msk);
268 }
269 
270 /**
271  * @brief Set channel of COMP input source.
272  *
273  * Register|BitsName
274  * --------|--------
275  * COMP_REG_0 | AON_COMP_REG_0_CHANNEL_SEL_P
276  *
277  * @param source This parameter can be one of the following values:
278  * @arg @ref LL_COMP_INPUT_SRC_IO0
279  * @arg @ref LL_COMP_INPUT_SRC_IO1
280  * @arg @ref LL_COMP_INPUT_SRC_IO2
281  * @arg @ref LL_COMP_INPUT_SRC_IO3
282  * @arg @ref LL_COMP_INPUT_SRC_IO4
283  * @arg @ref LL_COMP_INPUT_SRC_IO5
284  * @arg @ref LL_COMP_INPUT_SRC_IO6
285  * @arg @ref LL_COMP_INPUT_SRC_IO7
286  * @arg @ref LL_COMP_INPUT_SRC_VBAT
287  * @arg @ref LL_COMP_INPUT_SRC_VREF
288  * @retval None
289  */
290 __STATIC_INLINE void ll_comp_set_input_src(uint32_t source)
291 {
292  MODIFY_REG(AON_PMU->COMP_REG_0, AON_PMU_COMP_REG_0_CHANNEL_SEL_P_Msk, source);
293 }
294 
295 /**
296  * @brief Set channel of COMP reference source.
297  *
298  * Register|BitsName
299  * --------|--------
300  * COMP_REG_0 | AON_COMP_REG_0_CHANNEL_SEL_N
301  *
302  * @param source This parameter can be one of the following values:
303  * @arg @ref LL_COMP_REF_SRC_IO0
304  * @arg @ref LL_COMP_REF_SRC_IO1
305  * @arg @ref LL_COMP_REF_SRC_IO2
306  * @arg @ref LL_COMP_REF_SRC_IO3
307  * @arg @ref LL_COMP_REF_SRC_IO4
308  * @arg @ref LL_COMP_REF_SRC_IO5
309  * @arg @ref LL_COMP_REF_SRC_IO6
310  * @arg @ref LL_COMP_REF_SRC_IO7
311  * @arg @ref LL_COMP_REF_SRC_VBAT
312  * @arg @ref LL_COMP_REF_SRC_VREF
313  * @retval None
314  */
315 __STATIC_INLINE void ll_comp_set_ref_src(uint32_t source)
316 {
317  MODIFY_REG(AON_PMU->COMP_REG_0, AON_PMU_COMP_REG_0_CHANNEL_SEL_N_Msk, source);
318 }
319 
320 /**
321  * @brief Set VBATT control level.
322  *
323  * Register|BitsName
324  * --------|--------
325  * COMP_REG_0 | BATT_LVL_CTRL_LV
326  *
327  * @param level This parameter can be a value between: 0 ~ 7
328  * Vbatt_ref = ((level+1)/10) * VBATT
329  * @retval None
330  */
331 __STATIC_INLINE void ll_comp_set_vbatt_lvl(uint32_t level)
332 {
333  SET_BITS(AON_PMU->COMP_REG_1, AON_PMU_COMP_REG_1_COMP_VBAT_EN_Msk);
334  MODIFY_REG(AON_PMU->COMP_REG_0, AON_PMU_COMP_REG_0_COMP_BATT_LVL_CTRL_LV_Msk, level << AON_PMU_COMP_REG_0_COMP_BATT_LVL_CTRL_LV_Pos);
335 }
336 
337 /**
338  * @brief Set VREF control level.
339  *
340  * Register|BitsName
341  * --------|--------
342  * COMP_REG_0 | COMP_REF_CTRL
343  *
344  * @param level This parameter can be a value between: 0 ~ 63
345  * Vref = 30mv * level
346  * @retval None
347  */
348 __STATIC_INLINE void ll_comp_set_vref_lvl(uint32_t level)
349 {
350  SET_BITS(AON_PMU->COMP_REG_1, AON_PMU_COMP_REG_1_COMP_VREF_EN_Msk);
351  MODIFY_REG(AON_PMU->COMP_REG_0, AON_PMU_COMP_REG_0_COMP_REF_CTRL_LV_Msk, level << AON_PMU_COMP_REG_0_COMP_REF_CTRL_LV_Pos);
352 }
353 /**
354  * @brief set current of comparator.
355  *
356  * Register|BitsName
357  * --------|--------
358  * COMP_REG_0 | icomp_ctrl
359  *
360  * @param level The current of comparator
361  *
362  * @retval None
363  */
364 __STATIC_INLINE void ll_comp_set_current(uint32_t level)
365 {
366  MODIFY_REG(AON_PMU->COMP_REG_0, AON_PMU_COMP_REG_0_ICOMP_CTRL_LV_Msk, level << AON_PMU_COMP_REG_0_ICOMP_CTRL_LV_Pos);
367 }
368 
369 /**
370  * @brief set power of comparator.
371  *
372  * Register|BitsName
373  * --------|--------
374  * COMP_REG_0 | cascres_half
375  *
376  * @param level The power of comparator
377  *
378  * @retval None
379  */
380 __STATIC_INLINE void ll_comp_cascres_half_high(uint32_t level)
381 {
382  MODIFY_REG(AON_PMU->COMP_REG_1, AON_PMU_COMP_REG_1_COMP_CASCRES_HALF_CTRL_Msk, level <<AON_PMU_COMP_REG_1_COMP_CASCRES_HALF_CTRL_Pos);
383 }
384 
385 /**
386  * @brief Set hysteresis comparator
387  *
388  * Register|BitsName
389  * --------|--------
390  * COMP_REG_1 | P_HYS_EN
391  *
392  * @param hyst This parameter can be the following value:
393  * @arg @ref LL_COMP_HYST_POSITIVE
394  *
395  * @retval None
396  */
397 __STATIC_INLINE void ll_comp_positive_hysteresis(uint32_t hyst)
398 {
399  MODIFY_REG(AON_PMU->COMP_REG_1, AON_PMU_COMP_REG_1_CHANNEL_POSITIVE_HYST , hyst);
400 }
401 
402 /**
403  * @brief Set hysteresis comparator
404  *
405  * Register|BitsName
406  * --------|--------
407  * COMP_REG_1 | N_HYS_EN
408  *
409  * @param hyst This parameter can be the following value:
410  * @arg @ref LL_COMP_HYST_NEGATIVE
411  *
412  * @retval None
413  */
414 __STATIC_INLINE void ll_comp_negative_hysteresis(uint32_t hyst)
415 {
416  MODIFY_REG(AON_PMU->COMP_REG_1, AON_PMU_COMP_REG_1_CHANNEL_NEGATIVE_HYST , hyst);
417 }
418 
419 /**
420  * @brief Set calibration of comparator
421  *
422  * Register|BitsName
423  * --------|--------
424  * COMP_REG_1 | RDEG_P
425  *
426  * @param res_deg This parameter can be the following value:
427  * @arg @ref LL_COMP_RES_DEGENERATION_POSITIVE
428  *
429  * @retval None
430  */
431 __STATIC_INLINE void ll_comp_positive_degeneration(uint32_t res_deg)
432 {
433  MODIFY_REG(AON_PMU->COMP_REG_1, AON_PMU_COMP_REG_1_CHANNEL_POSITIVE_RES_DEGENERATION , res_deg);
434 }
435 
436 /**
437  * @brief Set calibration of comparator
438  *
439  * Register|BitsName
440  * --------|--------
441  * COMP_REG_1 | RDEG_N
442  *
443  * @param res_deg This parameter can be the following value:
444  * @arg @ref LL_COMP_RES_DEGENERATION_NEGATIVE
445  *
446  * @retval None
447  */
448 __STATIC_INLINE void ll_comp_negative_degeneration(uint32_t res_deg)
449 {
450  MODIFY_REG(AON_PMU->COMP_REG_1, AON_PMU_COMP_REG_1_CHANNEL_NEGATIVE_RES_DEGENERATION , res_deg);
451 }
452 
453 /**
454  * @brief Set compator glitch remove cycles
455  *
456  * Register|BitsName
457  * --------|--------
458  * AON_CTL_PMU_COMP_GLITCH_REMOVE | AON_CTL_PMU_COMP_GLITCH_REMOVE_CYCLE
459  *
460  * @param cycle The compator glitch remove cycles
461  *
462  * @retval None.
463  */
464 __STATIC_INLINE void ll_comp_set_remove_cycle(uint32_t cycle)
465 {
466  MODIFY_REG(AON_CTL->PMU_COMP_GLITCH_REMOVE, AON_CTL_PMU_COMP_GLITCH_REMOVE_CYCLE, cycle << AON_CTL_PMU_COMP_GLITCH_REMOVE_CYCLE_Pos);
467 }
468 
469 /**
470  * @brief get the glitch remove_cycle
471  *
472  * Register|BitsName
473  * --------|--------
474  * AON_CTL_PMU_COMP_GLITCH_REMOVE | AON_CTL_PMU_COMP_GLITCH_REMOVE_CYCLE
475  *
476  * @retval remove_cycles.
477  */
478 __STATIC_INLINE uint32_t ll_comp_get_remove_cycle(void)
479 {
480  return (uint32_t)(READ_BITS(AON_CTL->PMU_COMP_GLITCH_REMOVE, AON_CTL_PMU_COMP_GLITCH_REMOVE_CYCLE_Msk) >> AON_CTL_PMU_COMP_GLITCH_REMOVE_CYCLE_Pos);
481 }
482 
483 /**
484  * @brief Enable Wakeup Interrupt for COMP Rising.
485  *
486  * Register|BitsName
487  * --------|--------
488  * AON_SLEEP_EVENT | MSIO_COMP
489  *
490  * @retval None.
491  */
492 __STATIC_INLINE void ll_comp_enable_rising_wakeup(void)
493 {
494  BIT_ADDR((uint32_t)&AON_CTL->MCU_WAKEUP_CTRL, AON_CTL_MCU_WAKEUP_CTRL_COMP_RISE_Pos) = 1;
495 }
496 
497 /**
498  * @brief Disable Wakeup Interrupt for COMP Rising.
499  *
500  * Register|BitsName
501  * --------|--------
502  * AON_SLEEP_EVENT | MSIO_COMP
503  *
504  * @retval None.
505  */
506 __STATIC_INLINE void ll_comp_disable_rising_wakeup(void)
507 {
508  BIT_ADDR((uint32_t)&AON_CTL->MCU_WAKEUP_CTRL, AON_CTL_MCU_WAKEUP_CTRL_COMP_RISE_Pos) = 0;
509 }
510 
511 /**
512  * @brief Get Wakeup Interrupt for COMP Rising.
513  *
514  * Register|BitsName
515  * --------|--------
516  * AON_SLEEP_EVENT | MSIO_COMP
517  *
518  * @retval State of bit (1 or o).
519  */
520 __STATIC_INLINE uint32_t ll_comp_is_enable_rising_wakeup(void)
521 {
522  return (READ_BITS(AON_CTL->MCU_WAKEUP_CTRL, AON_CTL_MCU_WAKEUP_CTRL_COMP_RISE) == AON_CTL_MCU_WAKEUP_CTRL_COMP_RISE);
523 }
524 
525 /**
526  * @brief Enable Wakeup Interrupt for COMP Falling.
527  *
528  * Register|BitsName
529  * --------|--------
530  * AON_SLEEP_EVENT | MSIO_COMP
531  *
532  * @retval None.
533  */
534 __STATIC_INLINE void ll_comp_enable_falling_wakeup(void)
535 {
536  BIT_ADDR((uint32_t)&AON_CTL->MCU_WAKEUP_CTRL, AON_CTL_MCU_WAKEUP_CTRL_COMP_FALL_Pos) = 1;
537 }
538 
539 /**
540  * @brief Disable Wakeup Interrupt for COMP Falling.
541  *
542  * Register|BitsName
543  * --------|--------
544  * AON_SLEEP_EVENT | MSIO_COMP
545  *
546  * @retval None.
547  */
548 __STATIC_INLINE void ll_comp_disable_falling_wakeup(void)
549 {
550  BIT_ADDR((uint32_t)&AON_CTL->MCU_WAKEUP_CTRL, AON_CTL_MCU_WAKEUP_CTRL_COMP_FALL_Pos) = 0;
551 }
552 
553 /**
554  * @brief Get Wakeup Interrupt for COMP Falling.
555  *
556  * Register|BitsName
557  * --------|--------
558  * AON_SLEEP_EVENT | MSIO_COMP
559  *
560  * @retval State of bit (1 or o).
561  */
562 __STATIC_INLINE uint32_t ll_comp_is_enable_falling_wakeup(void)
563 {
564  return (READ_BITS(AON_CTL->MCU_WAKEUP_CTRL, AON_CTL_MCU_WAKEUP_CTRL_COMP_FALL) == AON_CTL_MCU_WAKEUP_CTRL_COMP_FALL);
565 }
566 
567 /**
568  * @brief Indicate if the COMP rising_triger Flag is set or not.
569  *
570  * Register|BitsName
571  * --------|--------
572  * AON_SLEEP_EVENT | MSIO_COMP
573  *
574  * @retval State of bit (1 or o).
575  */
576 SECTION_RAM_CODE __STATIC_INLINE uint32_t ll_comp_is_rising_triger_flag_it(void)
577 {
578  return (READ_BITS(AON_CTL->AON_SLP_EVENT, AON_CTL_SLP_EVENT_CMP_RISE) == AON_CTL_SLP_EVENT_CMP_RISE);
579 }
580 
581 /**
582  * @brief Clear rising_triger flag for COMP.
583  *
584  * Register|BitsName
585  * --------|--------
586  * AON_SLEEP_EVENT | MSIO_COMP
587  *
588  * @retval None.
589  */
590 SECTION_RAM_CODE __STATIC_INLINE void ll_comp_clear_rising_triger_flag_it(void)
591 {
592  WRITE_REG(AON_CTL->AON_SLP_EVENT, ~AON_CTL_SLP_EVENT_CMP_RISE);
593 }
594 
595 /**
596  * @brief Indicate if the COMP falling_triger Flag is set or not.
597  *
598  * Register|BitsName
599  * --------|--------
600  * AON_SLEEP_EVENT | MSIO_COMP
601  *
602  * @retval State of bit (1 or o).
603  */
604 SECTION_RAM_CODE __STATIC_INLINE uint32_t ll_comp_is_falling_triger_flag_it(void)
605 {
606  return (READ_BITS(AON_CTL->AON_SLP_EVENT, AON_CTL_SLP_EVENT_CMP_FALL) == AON_CTL_SLP_EVENT_CMP_FALL);
607 }
608 
609 /**
610  * @brief Clear falling_triger flag for COMP.
611  *
612  * Register|BitsName
613  * --------|--------
614  * AON_SLEEP_EVENT | MSIO_COMP
615  *
616  * @retval None.
617  */
618 SECTION_RAM_CODE __STATIC_INLINE void ll_comp_clear_falling_triger_flag_it(void)
619 {
620  WRITE_REG(AON_CTL->AON_SLP_EVENT, ~AON_CTL_SLP_EVENT_CMP_FALL);
621 }
622 
623 
624 /** @} */
625 
626 /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
627  * @{
628  */
629 
630 /**
631  * @brief De-initialize COMP registers (Registers restored to their default values).
632  * @retval An error_status_t enumeration value:
633  * - SUCCESS: COMP registers are de-initialized
634  * - ERROR: COMP registers are not de-initialized
635  */
636 error_status_t ll_comp_deinit(void);
637 
638 /**
639  * @brief Initialize COMP registers according to the specified.
640  * parameters in p_comp_init.
641  * @param p_comp_init Pointer to a ll_comp_init_t structure that contains the configuration
642  * information for the specified COMP peripheral.
643  * @retval An error_status_t enumeration value:
644  * - SUCCESS: COMP registers are initialized according to p_comp_init content
645  * - ERROR: Problem occurred during COMP Registers initialization
646  */
647 error_status_t ll_comp_init(ll_comp_init_t *p_comp_init);
648 
649 /**
650  * @brief Set each field of a @ref ll_comp_init_t type structure to default value.
651  * @param p_comp_init Pointer to a @ref ll_comp_init_t structure
652  * whose fields will be set to default values.
653  * @retval None
654  */
655 void ll_comp_struct_init(ll_comp_init_t *p_comp_init);
656 
657 /** @} */
658 
659 /** @} */
660 
661 #endif /* AON */
662 
663 #ifdef __cplusplus
664 }
665 #endif
666 
667 #endif /* __GR55XX_LL_COMP_H__ */
668 
669 /** @} */
670 
671 /** @} */
672 
673 /** @} */