gr55xx_ll_comp.h
Go to the documentation of this file.
1 
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)
63 
68 /* Exported types ------------------------------------------------------------*/
76 typedef struct _ll_comp_init
77 {
78  uint32_t input_source;
83  uint32_t ref_source;
87  uint32_t ref_value;
94 
104 /* Exported constants --------------------------------------------------------*/
112 #define LL_COMP_INPUT_SRC_IO0 (0UL << AON_RF_REG_10_CHANNEL_SEL_P_Pos)
113 #define LL_COMP_INPUT_SRC_IO1 (1UL << AON_RF_REG_10_CHANNEL_SEL_P_Pos)
114 #define LL_COMP_INPUT_SRC_IO2 (2UL << AON_RF_REG_10_CHANNEL_SEL_P_Pos)
115 #define LL_COMP_INPUT_SRC_IO3 (3UL << AON_RF_REG_10_CHANNEL_SEL_P_Pos)
116 #define LL_COMP_INPUT_SRC_IO4 (4UL << AON_RF_REG_10_CHANNEL_SEL_P_Pos)
122 #define LL_COMP_REF_SRC_IO0 (0UL << AON_RF_REG_10_CHANNEL_SEL_N_Pos)
123 #define LL_COMP_REF_SRC_IO1 (1UL << AON_RF_REG_10_CHANNEL_SEL_N_Pos)
124 #define LL_COMP_REF_SRC_IO2 (2UL << AON_RF_REG_10_CHANNEL_SEL_N_Pos)
125 #define LL_COMP_REF_SRC_IO3 (3UL << AON_RF_REG_10_CHANNEL_SEL_N_Pos)
126 #define LL_COMP_REF_SRC_IO4 (4UL << AON_RF_REG_10_CHANNEL_SEL_N_Pos)
127 #define LL_COMP_REF_SRC_VBAT (6UL << AON_RF_REG_10_CHANNEL_SEL_N_Pos)
128 #define LL_COMP_REF_SRC_VREF (7UL << AON_RF_REG_10_CHANNEL_SEL_N_Pos)
133 /* Exported macro ------------------------------------------------------------*/
134 
149 #define LL_COMP_WriteReg(__instance__, __REG__, __VALUE__) WRITE_REG((__instance__)->__REG__, (__VALUE__))
150 
157 #define LL_COMP_ReadReg(__instance__, __REG__) READ_REG((__instance__)->__REG__)
158 
163 /* Private types -------------------------------------------------------------*/
164 /* Private variables ---------------------------------------------------------*/
165 /* Private constants ---------------------------------------------------------*/
166 /* Private macros ------------------------------------------------------------*/
178 #define LL_COMP_DEFAULT_CONFIG \
179 { \
180  .channel_p = LL_COMP_CHANNEL_IO0, \
181  .channel_n = LL_COMP_CHANNEL_IO1, \
182 }
183 
189 /* Exported functions --------------------------------------------------------*/
207 __STATIC_INLINE void ll_comp_enable(void)
208 {
209  SET_BITS(AON->PWR_RET01, AON_PWR_REG01_WAKE_UP_SEL_MSIO_COMP);
210  SET_BITS(AON->RF_REG_10, AON_RF_REG_10_WAKE_COMP_EN_Msk);
211 }
212 
222 __STATIC_INLINE void ll_comp_disable(void)
223 {
224  CLEAR_BITS(AON->RF_REG_10, AON_RF_REG_10_WAKE_COMP_EN_Msk);
225  CLEAR_BITS(AON->PWR_RET01, AON_PWR_REG01_WAKE_UP_SEL_MSIO_COMP);
226 }
227 
243 __STATIC_INLINE void ll_comp_set_input_src(uint32_t source)
244 {
245  MODIFY_REG(AON->RF_REG_10, AON_RF_REG_10_CHANNEL_SEL_P_Msk, source);
246 }
247 
265 __STATIC_INLINE void ll_comp_set_ref_src(uint32_t source)
266 {
267  MODIFY_REG(AON->RF_REG_10, AON_RF_REG_10_CHANNEL_SEL_N_Msk, source);
268 }
269 
281 __STATIC_INLINE void ll_comp_set_vbatt_lvl(uint32_t level)
282 {
283  MODIFY_REG(AON->RF_REG_10, AON_RF_REG_10_COMP_BATT_LVL_CTRL_LV_Msk, level << AON_RF_REG_10_COMP_BATT_LVL_CTRL_LV_Pos);
284 }
285 
297 __STATIC_INLINE void ll_comp_set_vref_lvl(uint32_t level)
298 {
299  MODIFY_REG(AON->RF_REG_10, AON_RF_REG_10_COMP_REF_CTRL_LV_Msk, level << AON_RF_REG_10_COMP_REF_CTRL_LV_Pos);
300 }
301 
311 SECTION_RAM_CODE __STATIC_INLINE uint32_t ll_comp_is_active_flag_it(void)
312 {
313  return (READ_BITS(AON->SLP_EVENT, AON_SLP_EVENT_PMU_MSIO_COMP) == AON_SLP_EVENT_PMU_MSIO_COMP);
314 }
315 
325 SECTION_RAM_CODE __STATIC_INLINE void ll_comp_clear_flag_it(void)
326 {
327  GLOBAL_EXCEPTION_DISABLE();
328  CLEAR_BITS(AON->SLP_EVENT, AON_SLP_EVENT_PMU_MSIO_COMP);
329  GLOBAL_EXCEPTION_ENABLE();
330 }
331 
344 error_status_t ll_comp_deinit(void);
345 
355 error_status_t ll_comp_init(ll_comp_init_t *p_comp_init);
356 
364 
369 #endif /* AON */
370 
371 #ifdef __cplusplus
372 }
373 #endif
374 
375 #endif /* __GR55XX_LL_COMP_H__ */
376 
_ll_comp_init::ref_source
uint32_t ref_source
Definition: gr55xx_ll_comp.h:83
ll_comp_is_active_flag_it
SECTION_RAM_CODE __STATIC_INLINE uint32_t ll_comp_is_active_flag_it(void)
Indicate if the COMP Interrupt Flag is set or not.
Definition: gr55xx_ll_comp.h:311
ll_comp_init_t
struct _ll_comp_init ll_comp_init_t
LL COMP init Structure definition.
_ll_comp_init::input_source
uint32_t input_source
Definition: gr55xx_ll_comp.h:78
_ll_comp_init
LL COMP init Structure definition.
Definition: gr55xx_ll_comp.h:77
ll_comp_set_vref_lvl
__STATIC_INLINE void ll_comp_set_vref_lvl(uint32_t level)
Set VREF control level.
Definition: gr55xx_ll_comp.h:297
ll_comp_disable
__STATIC_INLINE void ll_comp_disable(void)
Disable COMP module.
Definition: gr55xx_ll_comp.h:222
ll_comp_deinit
error_status_t ll_comp_deinit(void)
De-initialize COMP registers (Registers restored to their default values).
ll_comp_init
error_status_t ll_comp_init(ll_comp_init_t *p_comp_init)
Initialize COMP registers according to the specified. parameters in p_comp_init.
ll_comp_enable
__STATIC_INLINE void ll_comp_enable(void)
Enable COMP module.
Definition: gr55xx_ll_comp.h:207
ll_comp_struct_init
void ll_comp_struct_init(ll_comp_init_t *p_comp_init)
Set each field of a ll_comp_init_t type structure to default value.
ll_comp_set_vbatt_lvl
__STATIC_INLINE void ll_comp_set_vbatt_lvl(uint32_t level)
Set VBATT control level.
Definition: gr55xx_ll_comp.h:281
ll_comp_set_ref_src
__STATIC_INLINE void ll_comp_set_ref_src(uint32_t source)
Set channel of COMP reference source.
Definition: gr55xx_ll_comp.h:265
ll_comp_clear_flag_it
SECTION_RAM_CODE __STATIC_INLINE void ll_comp_clear_flag_it(void)
Clear Interrupt Status flag for COMP.
Definition: gr55xx_ll_comp.h:325
_ll_comp_init::ref_value
uint32_t ref_value
Definition: gr55xx_ll_comp.h:87
ll_comp_set_input_src
__STATIC_INLINE void ll_comp_set_input_src(uint32_t source)
Set channel of COMP input source.
Definition: gr55xx_ll_comp.h:243