G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_lptmr.h
Go to the documentation of this file.
1
42
43/* Define to prevent recursive inclusion -------------------------------------*/
44#ifndef G32R4xx_DDL_LPTMR_H
45#define G32R4xx_DDL_LPTMR_H
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/* Includes ------------------------------------------------------------------*/
52#include "g32r4xx.h"
53
57
58#if defined (LPTMR)
59
63
64/* Private types -------------------------------------------------------------*/
65/* Private variables ---------------------------------------------------------*/
66/* Private constants ---------------------------------------------------------*/
67/* Private macros ------------------------------------------------------------*/
68/* Exported types ------------------------------------------------------------*/
69#if defined(USE_FULL_DDL_DRIVER)
73
77typedef struct
78{
79 uint16_t Prescaler;
84
85 uint32_t WakeUpValue;
91
95#endif /* USE_FULL_DDL_DRIVER */
96
97/* Exported constants --------------------------------------------------------*/
101
106#define DDL_LPTMR_STS_RUF LPTMR_SR_RU
107#define DDL_LPTMR_STS_PUF LPTMR_SR_PU
108#define DDL_LPTMR_STS_WKF LPTMR_SR_WK_STS
112
117#define DDL_LPTMR_INT_WKEN LPTMR_CR_IREN
121
122/* Exported macro ------------------------------------------------------------*/
126
137#define DDL_LPTMR_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
138
145#define DDL_LPTMR_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
149
150/* Exported functions --------------------------------------------------------*/
154
158
164__STATIC_INLINE void DDL_LPTMR_Enable(LPTMR_TypeDef *LPTMRx)
165{
166 SET_BIT(LPTMRx->CR, LPTMR_CR_EN);
167}
168
174__STATIC_INLINE void DDL_LPTMR_Disable(LPTMR_TypeDef *LPTMRx)
175{
176 CLEAR_BIT(LPTMRx->CR, LPTMR_CR_EN);
177}
178
184__STATIC_INLINE void DDL_LPTMR_EnableClk(void)
185{
186 SET_BIT(PMU->CR, PMU_CR_LPTMRCEN);
187}
188
194__STATIC_INLINE void DDL_LPTMR_DisableClk(void)
195{
196 CLEAR_BIT(PMU->CR, PMU_CR_LPTMRCEN);
197}
198
206__STATIC_INLINE void DDL_LPTMR_SetPrescaler(LPTMR_TypeDef *LPTMRx, uint32_t Prescaler)
207{
208 WRITE_REG(LPTMRx->PSC, Prescaler);
209}
210
216__STATIC_INLINE uint32_t DDL_LPTMR_GetPrescaler(LPTMR_TypeDef *LPTMRx)
217{
218 return (uint32_t)(READ_REG(LPTMRx->PSC));
219}
220
227__STATIC_INLINE void DDL_LPTMR_SetWakeUpValue(LPTMR_TypeDef *LPTMRx, uint32_t Value)
228{
229 WRITE_REG(LPTMRx->WVR, Value);
230}
231
239__STATIC_INLINE uint32_t DDL_LPTMR_GetWakeUpValue(LPTMR_TypeDef *LPTMRx)
240{
241 return (uint32_t)(READ_REG(LPTMRx->WVR));
242}
243
247
256__STATIC_INLINE void DDL_LPTMR_ClearFlag_WakeUp(LPTMR_TypeDef *LPTMRx)
257{
258 /* Read the current status register value */
259 uint32_t regVal = READ_REG(LPTMRx->SR);
260
261 /* Clear the DDL_LPTMR_STS_WKF bit by writing 0 */
262 regVal &= ~DDL_LPTMR_STS_WKF;
263
264 /* Write the updated value back to SR */
265 WRITE_REG(LPTMRx->SR, regVal);
266}
267
273__STATIC_INLINE uint32_t DDL_LPTMR_IsActiveFlag_ReloadUpdate(LPTMR_TypeDef *LPTMRx)
274{
275 return ((READ_BIT(LPTMRx->SR, DDL_LPTMR_STS_RUF) == (DDL_LPTMR_STS_RUF)) ? 1UL : 0UL);
276}
277
283__STATIC_INLINE uint32_t DDL_LPTMR_IsActiveFlag_PrescalerUpdate(LPTMR_TypeDef *LPTMRx)
284{
285 return ((READ_BIT(LPTMRx->SR, DDL_LPTMR_STS_PUF) == (DDL_LPTMR_STS_PUF)) ? 1UL : 0UL);
286}
287
293__STATIC_INLINE uint32_t DDL_LPTMR_IsActiveFlag_WakeUp(LPTMR_TypeDef *LPTMRx)
294{
295 return ((READ_BIT(LPTMRx->SR, DDL_LPTMR_STS_WKF) == (DDL_LPTMR_STS_WKF)) ? 1UL : 0UL);
296}
297
301
305
311__STATIC_INLINE void DDL_LPTMR_EnableIT_WakeUp(LPTMR_TypeDef *LPTMRx)
312{
313 SET_BIT(LPTMRx->CR, DDL_LPTMR_INT_WKEN);
314}
315
321__STATIC_INLINE void DDL_LPTMR_DisableIT_WakeUp(LPTMR_TypeDef *LPTMRx)
322{
323 CLEAR_BIT(LPTMRx->CR, DDL_LPTMR_INT_WKEN);
324}
325
329
330#if defined(USE_FULL_DDL_DRIVER)
334/* Initialisation and deinitialisation functions */
335void DDL_LPTMR_StructInit(DDL_LPTMR_InitTypeDef *LPTMR_InitStruct);
336ErrorStatus DDL_LPTMR_DeInit(LPTMR_TypeDef *LPTMRx);
337ErrorStatus DDL_LPTMR_Init(LPTMR_TypeDef *LPTMRx, DDL_LPTMR_InitTypeDef *LPTMR_InitStruct);
341#endif /* USE_FULL_DDL_DRIVER */
342
346
350
354
358
359#endif /* LPTMR */
360
364
365#ifdef __cplusplus
366}
367#endif
368
369#endif /* G32R4xx_DDL_LPTMR_H */
370
#define DDL_LPTMR_STS_RUF
#define DDL_LPTMR_STS_PUF
#define DDL_LPTMR_STS_WKF
#define DDL_LPTMR_INT_WKEN
__STATIC_INLINE uint32_t DDL_LPTMR_IsActiveFlag_WakeUp(LPTMR_TypeDef *LPTMRx)
Indicate whether wake up interrupt flag (WKF) is set (wake up interrupt is pending).
__STATIC_INLINE uint32_t DDL_LPTMR_IsActiveFlag_PrescalerUpdate(LPTMR_TypeDef *LPTMRx)
Indicate whether prescaler update flag (PUF) is set.
__STATIC_INLINE uint32_t DDL_LPTMR_IsActiveFlag_ReloadUpdate(LPTMR_TypeDef *LPTMRx)
Indicate whether reload update flag (RUF) is set.
__STATIC_INLINE void DDL_LPTMR_ClearFlag_WakeUp(LPTMR_TypeDef *LPTMRx)
Clear wake-up flag (WKF) by writing 0.
__STATIC_INLINE void DDL_LPTMR_DisableIT_WakeUp(LPTMR_TypeDef *LPTMRx)
Disable wake up interrupt (WK).
__STATIC_INLINE void DDL_LPTMR_EnableIT_WakeUp(LPTMR_TypeDef *LPTMRx)
Enable wake up interrupt (WK).
void DDL_LPTMR_StructInit(DDL_LPTMR_InitTypeDef *LPTMR_InitStruct)
Set the fields of the time base unit configuration data structure to their default values.
ErrorStatus DDL_LPTMR_DeInit(LPTMR_TypeDef *LPTMRx)
Set LPTMRx registers to their reset values.
ErrorStatus DDL_LPTMR_Init(LPTMR_TypeDef *LPTMRx, DDL_LPTMR_InitTypeDef *LPTMR_InitStruct)
Configure the LPTMRx time base unit.
__STATIC_INLINE void DDL_LPTMR_SetPrescaler(LPTMR_TypeDef *LPTMRx, uint32_t Prescaler)
Set the prescaler value.
__STATIC_INLINE void DDL_LPTMR_Enable(LPTMR_TypeDef *LPTMRx)
Enable low power timer.
__STATIC_INLINE uint32_t DDL_LPTMR_GetWakeUpValue(LPTMR_TypeDef *LPTMRx)
Get the wake up value.
__STATIC_INLINE void DDL_LPTMR_Disable(LPTMR_TypeDef *LPTMRx)
Disable low power timer.
__STATIC_INLINE uint32_t DDL_LPTMR_GetPrescaler(LPTMR_TypeDef *LPTMRx)
Get the prescaler value.
__STATIC_INLINE void DDL_LPTMR_DisableClk(void)
Disable low power timer clock.
__STATIC_INLINE void DDL_LPTMR_SetWakeUpValue(LPTMR_TypeDef *LPTMRx, uint32_t Value)
Set the wake up value.
__STATIC_INLINE void DDL_LPTMR_EnableClk(void)
Enable low power timer clock.
LPTMR Time Base configuration structure definition.