WB32L003 Standard Peripherals Firmware Library

wb32l003_lptim.h
Go to the documentation of this file.
1
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __WB32L003_LPTIM_H
12 #define __WB32L003_LPTIM_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 GateEnable;
36 uint32_t GateLevel;
39 uint32_t ClkSel;
42 uint32_t TogEnable;
45 uint32_t CntTimSel;
48 uint32_t AutoReload;
51 uint32_t Period;
56 } LPTIM_BaseInitTypeDef;
57
58 /* Exported constants --------------------------------------------------------*/
59
67 #define LPTIM_GATE_ENABLE (LPTIM_CR_GATE_EN)
68 #define LPTIM_GATE_DISABLE 0x00000000U
70 #define IS_LPTIM_GATE_ENABLE(GATE) (((GATE) == LPTIM_GATE_ENABLE) || \
71 ((GATE) == LPTIM_GATE_DISABLE))
72
79 #define LPTIM_GATELEVEL_LOW (LPTIM_CR_GATE_P)
80 #define LPTIM_GATELEVEL_HIGH 0x00000000U
82 #define IS_LPTIM_GATE_LEVEL(GATE_LEVEL) (((GATE_LEVEL) == LPTIM_GATELEVEL_LOW) || \
83 ((GATE_LEVEL) == LPTIM_GATELEVEL_HIGH))
84
91 #define LPTIM_CLOCK_SOURCE_PCLK 0x00000000U
92 #define LPTIM_CLOCK_SOURCE_LSE (LPTIM_CR_TCK_SEL_1)
93 #define LPTIM_CLOCK_SOURCE_LSI (LPTIM_CR_TCK_SEL_1 | LPTIM_CR_TCK_SEL_0)
95 #define IS_LPTIM_CLOCK_SOURCE(CLOCK_SOURCE) (((CLOCK_SOURCE) == LPTIM_CLOCK_SOURCE_PCLK) || \
96 ((CLOCK_SOURCE) == LPTIM_CLOCK_SOURCE_LSE) || \
97 ((CLOCK_SOURCE) == LPTIM_CLOCK_SOURCE_LSI))
98
105 #define LPTIM_TOG_ENABLE (LPTIM_CR_TOG_EN)
106 #define LPTIM_TOG_DISABLE 0x00000000U
108 #define IS_LPTIM_TOG(TOG) (((TOG) == LPTIM_TOG_ENABLE) || \
109 ((TOG) == LPTIM_TOG_DISABLE))
110
117 #define LPTIM_COUNTER_SELECT (LPTIM_CR_CT_SEL)
118 #define LPTIM_TIMER_SELECT 0x00000000U
120 #define IS_LPTIM_COUNTER(COUNTER) (((COUNTER) == LPTIM_COUNTER_SELECT) || \
121 ((COUNTER) == LPTIM_TIMER_SELECT))
122
129 #define LPTIM_AUTORELOAD_ENABLE (LPTIM_CR_MODE)
130 #define LPTIM_AUTORELOAD_DISABLE 0x00000000U
132 #define IS_LPTIM_AUTORELOAD(AUTORELOAD) (((AUTORELOAD) == LPTIM_AUTORELOAD_ENABLE) || \
133 ((AUTORELOAD) == LPTIM_AUTORELOAD_DISABLE))
134
142 /* Exported functions --------------------------------------------------------*/
143
144 void LPTIM_DeInit(void);
145 void LPTIM_BaseInit(LPTIM_BaseInitTypeDef *Base_InitStruct);
146 void LPTIM_TCKCmd(FunctionalState NewState);
147 void LPTIM_Cmd(FunctionalState NewState);
148 void LPTIM_ITCmd(FunctionalState NewState);
149 FlagStatus LPTIM_GetFlagStatus(void);
150 ITStatus LPTIM_GetITStatus(void);
151 void LPTIM_ClearFlag(void);
152 void LPTIM_ClearITPendingBit(void);
153 void LPTIM_SetCounter(uint32_t Counter);
154 uint32_t LPTIM_GetCounter(void);
155 void LPTIM_GateCmd(FunctionalState NewState);
156 void LPTIM_ToggleCmd(FunctionalState NewState);
157 void LPTIM_SetGateLevel(uint32_t Level);
158 FlagStatus LPTIM_GetSyncFlag(void);
159
168 #ifdef __cplusplus
169 }
170 #endif
171
172 #endif /* __WB32L003_LPTIM_H */
LPTIM_ClearFlag
void LPTIM_ClearFlag(void)
Clears the LPTIM pending interrupt flag.
Definition: wb32l003_lptim.c:197
LPTIM_DeInit
void LPTIM_DeInit(void)
Deinitializes the LPTIM peripheral registers to their default reset values.
Definition: wb32l003_lptim.c:38
LPTIM_BaseInitTypeDef::TogEnable
uint32_t TogEnable
Definition: wb32l003_lptim.h:42
LPTIM_GetITStatus
ITStatus LPTIM_GetITStatus(void)
Checks whether the LPTIM interrupt is set or not.
Definition: wb32l003_lptim.c:174
LPTIM_GetSyncFlag
FlagStatus LPTIM_GetSyncFlag(void)
Waits for LPTIM WT sync finish.
Definition: wb32l003_lptim.c:310
LPTIM_BaseInitTypeDef::GateEnable
uint32_t GateEnable
Definition: wb32l003_lptim.h:33
LPTIM_GateCmd
void LPTIM_GateCmd(FunctionalState NewState)
Enables or disables the LPTIM gate function.
Definition: wb32l003_lptim.c:245
LPTIM_BaseInitTypeDef
LPTIM Time base Configuration Structure definition.
Definition: wb32l003_lptim.h:31
LPTIM_BaseInitTypeDef::Period
uint32_t Period
Definition: wb32l003_lptim.h:51
LPTIM_BaseInitTypeDef::GateLevel
uint32_t GateLevel
Definition: wb32l003_lptim.h:36
LPTIM_ToggleCmd
void LPTIM_ToggleCmd(FunctionalState NewState)
Enables or disables the LPTIM toggle function.
Definition: wb32l003_lptim.c:268
LPTIM_ClearITPendingBit
void LPTIM_ClearITPendingBit(void)
Clears the LPTIM pending interrupt bit.
Definition: wb32l003_lptim.c:208
LPTIM_BaseInitTypeDef::CntTimSel
uint32_t CntTimSel
Definition: wb32l003_lptim.h:45
LPTIM_GetCounter
uint32_t LPTIM_GetCounter(void)
Gets LPTIM counter.
Definition: wb32l003_lptim.c:234
LPTIM_Cmd
void LPTIM_Cmd(FunctionalState NewState)
Enables or disables the LPTIM peripheral.
Definition: wb32l003_lptim.c:106
LPTIM_SetCounter
void LPTIM_SetCounter(uint32_t Counter)
Sets the LPTIM counter register value on runtime.
Definition: wb32l003_lptim.c:219
LPTIM_BaseInit
void LPTIM_BaseInit(LPTIM_BaseInitTypeDef *Base_InitStruct)
Low Power Time base configuration.
Definition: wb32l003_lptim.c:50
LPTIM_ITCmd
void LPTIM_ITCmd(FunctionalState NewState)
Enables or disables the LPTIM interrupt.
Definition: wb32l003_lptim.c:129
LPTIM_BaseInitTypeDef::AutoReload
uint32_t AutoReload
Definition: wb32l003_lptim.h:48
LPTIM_GetFlagStatus
FlagStatus LPTIM_GetFlagStatus(void)
Checks whether the LPTIM interrupt flag is set or not.
Definition: wb32l003_lptim.c:151
LPTIM_BaseInitTypeDef::ClkSel
uint32_t ClkSel
Definition: wb32l003_lptim.h:39
LPTIM_SetGateLevel
void LPTIM_SetGateLevel(uint32_t Level)
Sets gate level high or low.
Definition: wb32l003_lptim.c:291
LPTIM_TCKCmd
void LPTIM_TCKCmd(FunctionalState NewState)
Enables or disables the LPTIM time clock.
Definition: wb32l003_lptim.c:83