WB32L003 Standard Peripherals Firmware Library

wb32l003_lvd.h
Go to the documentation of this file.
1
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __WB32L003_LVD_H
12 #define __WB32L003_LVD_H
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /* Includes ------------------------------------------------------------------*/
19 #include "wb32l003.h"
20
25 /* Exported types ------------------------------------------------------------*/
26
31 typedef struct
32 {
33 uint32_t FltClkSel;
36 uint32_t VoltageLevel;
39 uint32_t TriggerSel;
42 uint32_t Action;
45 uint32_t FltNum;
48 } LVD_InitTypeDef;
49
50 /* Exported constants --------------------------------------------------------*/
51
59 #define LVD_FLTCLK_DISABLE (0x00000000U)
60 #define LVD_FLTCLK_PCLK (LVD_CR_FLTCLK_SEL_0)
61 #define LVD_FLTCLK_LSI (LVD_CR_FLTCLK_SEL_1)
63 #define IS_LVD_FLTCLK(FLTCLK) (((FLTCLK) == LVD_FLTCLK_DISABLE) || \
64 ((FLTCLK) == LVD_FLTCLK_PCLK) || \
65 ((FLTCLK) == LVD_FLTCLK_LSI))
66 #define IS_LVD_FLTNUM(FLTNUM) (((FLTNUM) >= 0U) && ((FLTNUM) <= 0xFFFFU))
67
74 #define LVD_TRIGGER_HIGHLEVEL (VCMP_CR1_HIGHINTEN)
75 #define LVD_TRIGGER_RISING (VCMP_CR1_RISEINTEN)
76 #define LVD_TRIGGER_FALLING (VCMP_CR1_FALLINTEN)
77 #define LVD_TRIGGER_BOTHEDGE (VCMP_CR1_RISEINTEN | VCMP_CR1_FALLINTEN)
78 #define LVD_TRIGGER_ALL (VCMP_CR1_HIGHINTEN | VCMP_CR1_RISEINTEN | VCMP_CR1_FALLINTEN)
80 #define IS_LVD_TRIGGER(LVD_TRIGGER) (((LVD_TRIGGER) == LVD_TRIGGER_HIGHLEVEL) || \
81 ((LVD_TRIGGER) == LVD_TRIGGER_RISING) || \
82 ((LVD_TRIGGER) == LVD_TRIGGER_FALLING) || \
83 ((LVD_TRIGGER) == LVD_TRIGGER_BOTHEDGE) || \
84 ((LVD_TRIGGER) == LVD_TRIGGER_ALL))
85
92 #define LVD_VOLLEVEL_0 (0x00000000U)
93 #define LVD_VOLLEVEL_1 (LVD_CR_DIV_SEL_0)
94 #define LVD_VOLLEVEL_2 (LVD_CR_DIV_SEL_1)
95 #define LVD_VOLLEVEL_3 (LVD_CR_DIV_SEL_0 | LVD_CR_DIV_SEL_1)
96 #define LVD_VOLLEVEL_4 (LVD_CR_DIV_SEL_2)
97 #define LVD_VOLLEVEL_5 (LVD_CR_DIV_SEL_0 | LVD_CR_DIV_SEL_2)
98 #define LVD_VOLLEVEL_6 (LVD_CR_DIV_SEL_2 | LVD_CR_DIV_SEL_1)
99 #define LVD_VOLLEVEL_7 (LVD_CR_DIV_SEL_2 | LVD_CR_DIV_SEL_1 | LVD_CR_DIV_SEL_0)
100
101 #define LVD_VOLLEVEL_8 (LVD_CR_DIV_SEL_3)
102 #define LVD_VOLLEVEL_9 (LVD_CR_DIV_SEL_3 | LVD_CR_DIV_SEL_0)
103 #define LVD_VOLLEVEL_A (LVD_CR_DIV_SEL_3 | LVD_CR_DIV_SEL_1)
104
105 #define IS_LVD_VOLLEVEL(VOLLEVE) (((VOLLEVE) == LVD_VOLLEVEL_0) || ((VOLLEVE) == LVD_VOLLEVEL_1) || \
106 ((VOLLEVE) == LVD_VOLLEVEL_2) || ((VOLLEVE) == LVD_VOLLEVEL_3) || \
107 ((VOLLEVE) == LVD_VOLLEVEL_4) || ((VOLLEVE) == LVD_VOLLEVEL_5) || \
108 ((VOLLEVE) == LVD_VOLLEVEL_6) || ((VOLLEVE) == LVD_VOLLEVEL_7) || \
109 ((VOLLEVE) == LVD_VOLLEVEL_8) || ((VOLLEVE) == LVD_VOLLEVEL_9) || \
110 ((VOLLEVE) == LVD_VOLLEVEL_A))
111
118 #define LVD_ACTION_INTERRUPT (0x00000000U)
119 #define LVD_ACTION_RESET (LVD_CR_ACT)
121 #define IS_LVD_ACTION(ACTION) (((ACTION) == LVD_ACTION_INTERRUPT) || \
122 ((ACTION) == LVD_ACTION_RESET))
123
131 /* Exported macros -----------------------------------------------------------*/
132 /* Exported functions --------------------------------------------------------*/
133
134 void LVD_DIGFLT_Cmd(FunctionalState NewState);
135 void LVD_Init(LVD_InitTypeDef *InitStruct);
136 void LVD_Cmd(FunctionalState NewState);
137 void LVD_DeInit(void);
138 void LVD_ITCmd(FunctionalState NewState);
139 FlagStatus LVD_GetFlagStatus(void);
140 ITStatus LVD_GetITStatus(void);
141 void LVD_ClearITPendingBit(void);
142 void LVD_ClearFlag(void);
143
152 #ifdef __cplusplus
153 }
154 #endif
155
156 #endif /* __WB32L003_LVD_H */
LVD_InitTypeDef
LVD Configuration Structure definition.
Definition: wb32l003_lvd.h:31
LVD_ITCmd
void LVD_ITCmd(FunctionalState NewState)
Enables or disables LVD interrupt.
Definition: wb32l003_lvd.c:121
LVD_GetFlagStatus
FlagStatus LVD_GetFlagStatus(void)
Checks whether LVD interrupt flag is set or not.
Definition: wb32l003_lvd.c:141
LVD_Cmd
void LVD_Cmd(FunctionalState NewState)
Enables or disables the LVD peripheral.
Definition: wb32l003_lvd.c:100
LVD_InitTypeDef::FltNum
uint32_t FltNum
Definition: wb32l003_lvd.h:45
LVD_InitTypeDef::FltClkSel
uint32_t FltClkSel
Definition: wb32l003_lvd.h:33
LVD_DeInit
void LVD_DeInit(void)
Deinitializes the LVD peripheral registers to their default reset values.
Definition: wb32l003_lvd.c:38
LVD_InitTypeDef::TriggerSel
uint32_t TriggerSel
Definition: wb32l003_lvd.h:39
LVD_InitTypeDef::Action
uint32_t Action
Definition: wb32l003_lvd.h:42
LVD_GetITStatus
ITStatus LVD_GetITStatus(void)
Checks whether LVD interrupt is set or not.
Definition: wb32l003_lvd.c:165
LVD_Init
void LVD_Init(LVD_InitTypeDef *InitStruct)
Initializes the LVD Unit according to the specified parameters in the LVD_InitTypeDef.
Definition: wb32l003_lvd.c:72
LVD_InitTypeDef::VoltageLevel
uint32_t VoltageLevel
Definition: wb32l003_lvd.h:36
LVD_ClearFlag
void LVD_ClearFlag(void)
Clears the LVD flag.
Definition: wb32l003_lvd.c:199
LVD_DIGFLT_Cmd
void LVD_DIGFLT_Cmd(FunctionalState NewState)
Enables or disables the LVD digital filter.
Definition: wb32l003_lvd.c:50
LVD_ClearITPendingBit
void LVD_ClearITPendingBit(void)
Clears the LVD interrupt bit.
Definition: wb32l003_lvd.c:189