MG32L003 Standard Peripherals Firmware Library
mg32l003_lptim.h
Go to the documentation of this file.
1 
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __MG32L003_LPTIM_H
12 #define __MG32L003_LPTIM_H
13 
14 #ifdef __cplusplus
15  extern "C" {
16 #endif
17 
18 /* Includes ------------------------------------------------------------------*/
19 #include "mg32l003.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;
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 /* __MG32L003_LPTIM_H */
void LPTIM_ClearFlag(void)
Clears the LPTIM pending interrupt flag.
Definition: mg32l003_lptim.c:197
void LPTIM_DeInit(void)
Deinitializes the LPTIM peripheral registers to their default reset values.
Definition: mg32l003_lptim.c:38
uint32_t TogEnable
Definition: mg32l003_lptim.h:42
ITStatus LPTIM_GetITStatus(void)
Checks whether the LPTIM interrupt is set or not.
Definition: mg32l003_lptim.c:174
FlagStatus LPTIM_GetSyncFlag(void)
Waits for LPTIM WT sync finish.
Definition: mg32l003_lptim.c:310
uint32_t GateEnable
Definition: mg32l003_lptim.h:33
void LPTIM_GateCmd(FunctionalState NewState)
Enables or disables the LPTIM gate function.
Definition: mg32l003_lptim.c:245
LPTIM Time base Configuration Structure definition.
Definition: mg32l003_lptim.h:31
uint32_t Period
Definition: mg32l003_lptim.h:51
uint32_t GateLevel
Definition: mg32l003_lptim.h:36
void LPTIM_ToggleCmd(FunctionalState NewState)
Enables or disables the LPTIM toggle function.
Definition: mg32l003_lptim.c:268
void LPTIM_ClearITPendingBit(void)
Clears the LPTIM pending interrupt bit.
Definition: mg32l003_lptim.c:208
uint32_t CntTimSel
Definition: mg32l003_lptim.h:45
uint32_t LPTIM_GetCounter(void)
Gets LPTIM counter.
Definition: mg32l003_lptim.c:234
void LPTIM_Cmd(FunctionalState NewState)
Enables or disables the LPTIM peripheral.
Definition: mg32l003_lptim.c:106
void LPTIM_SetCounter(uint32_t Counter)
Sets the LPTIM counter register value on runtime.
Definition: mg32l003_lptim.c:219
void LPTIM_BaseInit(LPTIM_BaseInitTypeDef *Base_InitStruct)
Low Power Time base configuration.
Definition: mg32l003_lptim.c:50
void LPTIM_ITCmd(FunctionalState NewState)
Enables or disables the LPTIM interrupt.
Definition: mg32l003_lptim.c:129
uint32_t AutoReload
Definition: mg32l003_lptim.h:48
FlagStatus LPTIM_GetFlagStatus(void)
Checks whether the LPTIM interrupt flag is set or not.
Definition: mg32l003_lptim.c:151
uint32_t ClkSel
Definition: mg32l003_lptim.h:39
void LPTIM_SetGateLevel(uint32_t Level)
Sets gate level high or low.
Definition: mg32l003_lptim.c:291
void LPTIM_TCKCmd(FunctionalState NewState)
Enables or disables the LPTIM time clock.
Definition: mg32l003_lptim.c:83