G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_pmu.h
Go to the documentation of this file.
1
42
43/* Define to prevent recursive inclusion -------------------------------------*/
44#ifndef G32R4xx_DDL_PMU_H
45#define G32R4xx_DDL_PMU_H
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/* Includes ------------------------------------------------------------------*/
52#include "g32r4xx.h"
53
57
58#if defined(PMU)
59
63
64/* Private types -------------------------------------------------------------*/
65/* Private variables ---------------------------------------------------------*/
66/* Private constants ---------------------------------------------------------*/
67/* Private macros ------------------------------------------------------------*/
68/* Exported types ------------------------------------------------------------*/
69/* Exported constants --------------------------------------------------------*/
73
77#define DDL_PMU_WAKEUP_PIN1 PMU_WKPCR_WKUPEN0 /* PC1-WUIO */
78#define DDL_PMU_WAKEUP_PIN2 PMU_WKPCR_WKUPEN1 /* PC2-WUIO */
79#define DDL_PMU_WAKEUP_PIN3 PMU_WKPCR_WKUPEN2 /* PD0-WUIO */
80#define DDL_PMU_WAKEUP_PIN4 PMU_WKPCR_WKUPEN3 /* PD9-WUIO */
81
85
89#define DDL_PMU_WAKEUP_PIN_POLARITY_RISING (0x0U)
90#define DDL_PMU_WAKEUP_PIN_POLARITY_FALLING (0x1U)
91#define DDL_PMU_WAKEUP_PIN_POLARITY_RISING_AND_FALLING (0x2U)
95
99#define DDL_PMU_STANDBY_PINMODE_ANALOG (0x0U)
100#define DDL_PMU_STANDBY_PINMODE_PU (0x1U)
101#define DDL_PMU_STANDBY_PINMODE_PD (0x2U)
105
109#define DDL_PMU_EVS_FILTER_NONE (0x00000000UL)
110#define DDL_PMU_EVS_FILTER_2LSICLK (PMU_EVSCR_VDCPVDFILTER_0)
111#define DDL_PMU_EVS_FILTER_4LSICLK (PMU_EVSCR_VDCPVDFILTER_1)
112#define DDL_PMU_EVS_FILTER_8LSICLK (PMU_EVSCR_VDCPVDFILTER)
116
120
121/* Exported macro ------------------------------------------------------------*/
125
129
136#define DDL_PMU_WriteReg(__REG__, __VALUE__) WRITE_REG(PMU->__REG__, (__VALUE__))
137
143#define DDL_PMU_ReadReg(__REG__) READ_REG(PMU->__REG__)
147
151
152/* Exported functions --------------------------------------------------------*/
156
160
170__STATIC_INLINE void DDL_PMU_EnableWakeUpPin(uint32_t Pin)
171{
172 SET_BIT(PMU->WKPCR, Pin);
173}
174
184__STATIC_INLINE void DDL_PMU_DisableWakeUpPin(uint32_t Pin)
185{
186 CLEAR_BIT(PMU->WKPCR, Pin);
187}
188
202__STATIC_INLINE void DDL_PMU_SetWakeUpPinPolarity(uint32_t Pin, uint32_t Polarity)
203{
204 MODIFY_REG(PMU->WKPCR, (PMU_WKPCR_WKUPPOL0 << ((POSITION_VAL(Pin) * 2))), (Polarity << (4 + POSITION_VAL(Pin) * 2)));
205}
206
219__STATIC_INLINE uint32_t DDL_PMU_GetWakeUpPinPolarity(uint32_t Pin)
220{
221 return (uint32_t)(READ_BIT(PMU->WKPCR, (PMU_WKPCR_WKUPPOL0 << (POSITION_VAL(Pin) * 2))) >> (4 + POSITION_VAL(Pin) * 2));
222}
223
226
230
244__STATIC_INLINE void DDL_PMU_SetPinModeInStandby(uint32_t Pin, uint32_t Mode)
245{
246 MODIFY_REG(PMU->WKPCR, PMU_WKPCR_APC, ((!!Mode) << PMU_WKPCR_APC_Pos));
248 {
249 SET_BIT(PMU->PUCRA, Pin);
250 CLEAR_BIT(PMU->PDCRA, Pin);
251 }
252 else if(Mode == DDL_PMU_STANDBY_PINMODE_PD)
253 {
254 CLEAR_BIT(PMU->PUCRA, Pin);
255 SET_BIT(PMU->PDCRA, Pin);
256 }
257 else
258 {
259 CLEAR_BIT(PMU->PUCRA, Pin);
260 CLEAR_BIT(PMU->PDCRA, Pin);
261 }
262}
263
276__STATIC_INLINE uint32_t DDL_PMU_GetPinModeInStandby(uint32_t Pin)
277{
278 return (uint32_t)((READ_BIT(PMU->WKPCR, PMU_WKPCR_APC) == PMU_WKPCR_APC ? 1UL : 0UL) *
279 ((READ_BIT(PMU->PUCRA, Pin) > 0U ? DDL_PMU_STANDBY_PINMODE_PU : 0UL) |
280 (READ_BIT(PMU->PDCRA, Pin) > 0U ? DDL_PMU_STANDBY_PINMODE_PD : 0UL)));
281}
282
292__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_WakeUp(uint32_t Pin)
293{
294 return (uint32_t)(READ_BIT(PMU->SR, Pin));
295}
296
306__STATIC_INLINE void DDL_PMU_ClearFlag_WakeUp(uint32_t Pin)
307{
308 WRITE_REG(PMU->SR, Pin);
309}
310
316__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_Standby(void)
317{
318 return (uint32_t)(READ_BIT(PMU->SR, PMU_SR_SBF));
319}
320
326__STATIC_INLINE void DDL_PMU_ClearFlag_Standby(void)
327{
328 WRITE_REG(PMU->SR, PMU_SR_SBF);
329}
330
334
338
344__STATIC_INLINE void DDL_PMU_EnableEVSWakeUp(void)
345{
346 SET_BIT(PMU->EVSCR, PMU_EVSCR_VDCPVDWKPEN);
347}
348
354__STATIC_INLINE void DDL_PMU_DisableEVSWakeUp(void)
355{
356 CLEAR_BIT(PMU->EVSCR, PMU_EVSCR_VDCPVDWKPEN);
357}
358
364__STATIC_INLINE void DDL_PMU_EnableEVS(void)
365{
366 SET_BIT(PMU->EVSCR, PMU_EVSCR_VDCPVDEN);
367}
368
374__STATIC_INLINE void DDL_PMU_DisableEVS(void)
375{
376 CLEAR_BIT(PMU->EVSCR, PMU_EVSCR_VDCPVDEN);
377}
378
388__STATIC_INLINE void DDL_PMU_SetEVSFilter(uint32_t Filter)
389{
390 MODIFY_REG(PMU->EVSCR, PMU_EVSCR_VDCPVDFILTER, Filter);
391}
392
402__STATIC_INLINE uint32_t DDL_PMU_GetEVSFilter(void)
403{
404 return (uint32_t)(READ_BIT(PMU->EVSCR, PMU_EVSCR_VDCPVDFILTER));
405}
406
412__STATIC_INLINE void DDL_PMU_SetEVSThreshold(uint32_t threshold)
413{
414 MODIFY_REG(PMU->EVSCR, PMU_EVSCR_VDCPVDSEL, threshold << PMU_EVSCR_VDCPVDSEL_Pos);
415}
416
422__STATIC_INLINE uint32_t DDL_PMU_GetEVSThreshold(void)
423{
424 return (uint32_t)(READ_BIT(PMU->EVSCR, PMU_EVSCR_VDCPVDSEL) >> PMU_EVSCR_VDCPVDSEL_Pos);
425}
426
432__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_EVS(void)
433{
434 return (uint32_t)(READ_BIT(PMU->SR, PMU_SR_EVSWKF) == PMU_SR_EVSWKF ? 1UL : 0UL);
435}
436
442__STATIC_INLINE void DDL_PMU_ClearFlag_EVS(void)
443{
444 WRITE_REG(PMU->SR, PMU_SR_EVSWKF);
445}
446
450
454
460__STATIC_INLINE void DDL_PMU_EnablePVD(void)
461{
462 SET_BIT(PMU->PVDCR, PMU_PVDCR_PVDEN);
463}
464
470__STATIC_INLINE void DDL_PMU_DisablePVD(void)
471{
472 CLEAR_BIT(PMU->PVDCR, PMU_PVDCR_PVDEN);
473}
474
480__STATIC_INLINE void DDL_PMU_SetPVDThreshold(uint32_t Threshold)
481{
482 MODIFY_REG(PMU->PVDCR, PMU_PVDCR_PVDTHSEL, (Threshold << PMU_PVDCR_PVDTHSEL_Pos));
483}
484
490__STATIC_INLINE uint32_t DDL_PMU_GetPVDThreshold(void)
491{
492 return (uint32_t)(READ_BIT(PMU->PVDCR, PMU_PVDCR_PVDTHSEL) >> PMU_PVDCR_PVDTHSEL_Pos);
493}
494
500__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_PVDOutput(void)
501{
502 return (uint32_t)(READ_BIT(PMU->SR, PMU_SR_PVDO) == PMU_SR_PVDO ? 1UL : 0UL);
503}
504
508
509#if defined(USE_FULL_DDL_DRIVER)
514void DDL_PMU_EnterStopModeWFI(void);
516void DDL_PMU_EnterStopModeWFE(void);
520#endif /* USE_FULL_DDL_DRIVER */
521
525
529
530#endif /* PMU */
531
535
536#ifdef __cplusplus
537}
538#endif
539
540#endif /* G32R4xx_DDL_PMU_H */
541
#define DDL_PMU_STANDBY_PINMODE_PD
#define DDL_PMU_STANDBY_PINMODE_PU
__STATIC_INLINE void DDL_PMU_EnableEVS(void)
Enable EVS pin.
__STATIC_INLINE void DDL_PMU_SetEVSThreshold(uint32_t threshold)
Get EVS thresholds value.
__STATIC_INLINE void DDL_PMU_ClearFlag_EVS(void)
Clear EVS wakeup event flag.
__STATIC_INLINE uint32_t DDL_PMU_GetEVSFilter(void)
Get EVS pin filter.
__STATIC_INLINE void DDL_PMU_EnableEVSWakeUp(void)
Enable EVS pin to wake up in standby mode.
__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_EVS(void)
Check if EVS wakeup event occurred or not.
__STATIC_INLINE void DDL_PMU_SetEVSFilter(uint32_t Filter)
Set EVS pin filter.
__STATIC_INLINE void DDL_PMU_DisableEVS(void)
Disable EVS pin.
__STATIC_INLINE uint32_t DDL_PMU_GetEVSThreshold(void)
Get EVS thresholds value.
__STATIC_INLINE void DDL_PMU_DisableEVSWakeUp(void)
Disable EVS pin to wake up in standby mode.
void DDL_PMU_EnterStopModeWFI(void)
Enter Stop Mode by WFI.
void DDL_PMU_EnterStopModeWFE(void)
Enter Stop Mode by WFE.
void DDL_PMU_EnterStandbyModeWFE(void)
Enter Standby Mode by WFE.
void DDL_PMU_EnterStandbyModeWFI(void)
Enter Standby Mode by WFI.
__STATIC_INLINE void DDL_PMU_DisablePVD(void)
Disable PVD.
__STATIC_INLINE uint32_t DDL_PMU_GetPVDThreshold(void)
Get PVD threshold.
__STATIC_INLINE void DDL_PMU_EnablePVD(void)
Enable PVD.
__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_PVDOutput(void)
Check if PVD output event occurred or not.
__STATIC_INLINE void DDL_PMU_SetPVDThreshold(uint32_t Threshold)
Set PVD threshold.
__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_Standby(void)
Check if standby event occurred or not.
__STATIC_INLINE uint32_t DDL_PMU_IsActiveFlag_WakeUp(uint32_t Pin)
Check if pin wake up event occurred or not.
__STATIC_INLINE uint32_t DDL_PMU_GetPinModeInStandby(uint32_t Pin)
Get pin mode in standby mode.
__STATIC_INLINE void DDL_PMU_SetPinModeInStandby(uint32_t Pin, uint32_t Mode)
Set pin mode in standby mode.
__STATIC_INLINE void DDL_PMU_ClearFlag_Standby(void)
Clear standby flag.
__STATIC_INLINE void DDL_PMU_ClearFlag_WakeUp(uint32_t Pin)
Clear pin wake up flag.
__STATIC_INLINE void DDL_PMU_EnableWakeUpPin(uint32_t Pin)
Enable pin wake up.
__STATIC_INLINE void DDL_PMU_DisableWakeUpPin(uint32_t Pin)
Disable pin wake up.
__STATIC_INLINE void DDL_PMU_SetWakeUpPinPolarity(uint32_t Pin, uint32_t Polarity)
Set wake up pin polarity.
__STATIC_INLINE uint32_t DDL_PMU_GetWakeUpPinPolarity(uint32_t Pin)
Get wake up pin polarity.