G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_cortex.h
Go to the documentation of this file.
1
58
59/* Define to prevent recursive inclusion -------------------------------------*/
60#ifndef G32R4xx_DDL_CORTEX_H
61#define G32R4xx_DDL_CORTEX_H
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
67/* Includes ------------------------------------------------------------------*/
68#include "g32r4xx.h"
69
73
77
78/* Private types -------------------------------------------------------------*/
79/* Private variables ---------------------------------------------------------*/
80/* Private constants ---------------------------------------------------------*/
81/* Private macros ------------------------------------------------------------*/
82/* Exported types ------------------------------------------------------------*/
83/* Exported constants --------------------------------------------------------*/
87
91#define DDL_SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U
92#define DDL_SYSTICK_CLKSOURCE_HCLK SysTick_CTRL_CLKSOURCE_Msk
96
100#define DDL_HANDLER_FAULT_USG SCB_SHCSR_USGFAULTENA_Msk
101#define DDL_HANDLER_FAULT_BUS SCB_SHCSR_BUSFAULTENA_Msk
102#define DDL_HANDLER_FAULT_MEM SCB_SHCSR_MEMFAULTENA_Msk
106
110
111/* Exported macro ------------------------------------------------------------*/
112/* Exported functions --------------------------------------------------------*/
116
120
126__STATIC_INLINE uint32_t DDL_SYSTICK_IsActiveCounterFlag(void)
127{
128 return ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk));
129}
130
138__STATIC_INLINE void DDL_SYSTICK_SetClkSource(uint32_t Source)
139{
140 if (Source == DDL_SYSTICK_CLKSOURCE_HCLK)
141 {
142 SET_BIT(SysTick->CTRL, DDL_SYSTICK_CLKSOURCE_HCLK);
143 }
144 else
145 {
146 CLEAR_BIT(SysTick->CTRL, DDL_SYSTICK_CLKSOURCE_HCLK);
147 }
148}
149
156__STATIC_INLINE uint32_t DDL_SYSTICK_GetClkSource(void)
157{
158 return READ_BIT(SysTick->CTRL, DDL_SYSTICK_CLKSOURCE_HCLK);
159}
160
165__STATIC_INLINE void DDL_SYSTICK_EnableIT(void)
166{
167 SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
168}
169
174__STATIC_INLINE void DDL_SYSTICK_DisableIT(void)
175{
176 CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
177}
178
183__STATIC_INLINE uint32_t DDL_SYSTICK_IsEnabledIT(void)
184{
185 return (READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk));
186}
187
191
195
200__STATIC_INLINE void DDL_LPM_EnableSleep(void)
201{
202 /* Clear SLEEPDEEP bit of Cortex System Control Register */
203 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
204}
205
210__STATIC_INLINE void DDL_LPM_EnableDeepSleep(void)
211{
212 /* Set SLEEPDEEP bit of Cortex System Control Register */
213 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
214}
215
222__STATIC_INLINE void DDL_LPM_EnableSleepOnExit(void)
223{
224 /* Set SLEEPONEXIT bit of Cortex System Control Register */
225 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
226}
227
232__STATIC_INLINE void DDL_LPM_DisableSleepOnExit(void)
233{
234 /* Clear SLEEPONEXIT bit of Cortex System Control Register */
235 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
236}
237
243__STATIC_INLINE void DDL_LPM_EnableEventOnPend(void)
244{
245 /* Set SEVEONPEND bit of Cortex System Control Register */
246 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
247}
248
254__STATIC_INLINE void DDL_LPM_DisableEventOnPend(void)
255{
256 /* Clear SEVEONPEND bit of Cortex System Control Register */
257 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
258}
259
263
267
276__STATIC_INLINE void DDL_HANDLER_EnableFault(uint32_t Fault)
277{
278 /* Enable the system handler fault */
279 SET_BIT(SCB->SHCSR, Fault);
280}
281
290__STATIC_INLINE void DDL_HANDLER_DisableFault(uint32_t Fault)
291{
292 /* Disable the system handler fault */
293 CLEAR_BIT(SCB->SHCSR, Fault);
294}
295
299
303
308__STATIC_INLINE uint32_t DDL_CPUID_GetImplementer(void)
309{
310 return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos);
311}
312
317__STATIC_INLINE uint32_t DDL_CPUID_GetVariant(void)
318{
319 return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos);
320}
321
326__STATIC_INLINE uint32_t DDL_CPUID_GetConstant(void)
327{
328 return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos);
329}
330
335__STATIC_INLINE uint32_t DDL_CPUID_GetParNo(void)
336{
337 return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos);
338}
339
344__STATIC_INLINE uint32_t DDL_CPUID_GetRevision(void)
345{
346 return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos);
347}
348
352
356
360
364
365#ifdef __cplusplus
366}
367#endif
368
369#endif /* G32R4xx_DDL_CORTEX_H */
370
#define DDL_SYSTICK_CLKSOURCE_HCLK
__STATIC_INLINE void DDL_HANDLER_EnableFault(uint32_t Fault)
Enable a fault in System handler control register (SHCSR).
__STATIC_INLINE void DDL_HANDLER_DisableFault(uint32_t Fault)
Disable a fault in System handler control register (SHCSR).
__STATIC_INLINE void DDL_LPM_EnableEventOnPend(void)
Enabled events and all interrupts, including disabled interrupts, can wakeup the processor.
__STATIC_INLINE void DDL_LPM_EnableSleepOnExit(void)
Configures sleep-on-exit when returning from Handler mode to Thread mode.
__STATIC_INLINE void DDL_LPM_EnableSleep(void)
Processor uses sleep as its low power mode.
__STATIC_INLINE void DDL_LPM_DisableEventOnPend(void)
Only enabled interrupts or events can wakeup the processor, disabled interrupts are excluded.
__STATIC_INLINE void DDL_LPM_DisableSleepOnExit(void)
Do not sleep when returning to Thread mode.
__STATIC_INLINE void DDL_LPM_EnableDeepSleep(void)
Processor uses deep sleep as its low power mode.
__STATIC_INLINE uint32_t DDL_CPUID_GetConstant(void)
Get Constant number.
__STATIC_INLINE uint32_t DDL_CPUID_GetParNo(void)
Get Part number.
__STATIC_INLINE uint32_t DDL_CPUID_GetVariant(void)
Get Variant number (The r value in the rnpn product revision identifier).
__STATIC_INLINE uint32_t DDL_CPUID_GetImplementer(void)
Get Implementer code.
__STATIC_INLINE uint32_t DDL_CPUID_GetRevision(void)
Get Revision number (The p value in the rnpn product revision identifier, indicates patch release).
__STATIC_INLINE void DDL_SYSTICK_SetClkSource(uint32_t Source)
Configures the SysTick clock source.
__STATIC_INLINE void DDL_SYSTICK_DisableIT(void)
Disable SysTick exception request.
__STATIC_INLINE uint32_t DDL_SYSTICK_IsActiveCounterFlag(void)
This function checks if the Systick counter flag is active or not.
__STATIC_INLINE void DDL_SYSTICK_EnableIT(void)
Enable SysTick exception request.
__STATIC_INLINE uint32_t DDL_SYSTICK_GetClkSource(void)
Get the SysTick clock source.
__STATIC_INLINE uint32_t DDL_SYSTICK_IsEnabledIT(void)
Checks if the SYSTICK interrupt is enabled or disabled.