G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_eint.c
Go to the documentation of this file.
1
44#if defined(USE_FULL_DDL_DRIVER)
45
46/* Includes ------------------------------------------------------------------*/
47#include "g32r4xx_ddl_eint.h"
48#ifdef USE_FULL_ASSERT
49#include "g32_assert.h"
50#else
51#define ASSERT_PARAM(_PARAM_) ((void)0U)
52#endif
53
57
58#if defined (EINT)
59
63
64/* Private types -------------------------------------------------------------*/
65/* Private variables ---------------------------------------------------------*/
66/* Private constants ---------------------------------------------------------*/
67/* Private macros ------------------------------------------------------------*/
71
72#define IS_DDL_EINT_LINE(__VALUE__) (((__VALUE__) & ~DDL_EINT_LINE_ALL) == 0x00000000U)
73
74#define IS_DDL_EINT_MODE(__VALUE__) (((__VALUE__) == DDL_EINT_MODE_IT) \
75 || ((__VALUE__) == DDL_EINT_MODE_EVENT) \
76 || ((__VALUE__) == DDL_EINT_MODE_IT_EVENT))
77
78
79#define IS_DDL_EINT_TRIGGER(__VALUE__) (((__VALUE__) == DDL_EINT_TRIGGER_NONE) \
80 || ((__VALUE__) == DDL_EINT_TRIGGER_RISING) \
81 || ((__VALUE__) == DDL_EINT_TRIGGER_FALLING) \
82 || ((__VALUE__) == DDL_EINT_TRIGGER_RISING_FALLING))
83
87
88/* Private function prototypes -----------------------------------------------*/
89
90/* Exported functions --------------------------------------------------------*/
94
98
105uint32_t DDL_EINT_DeInit(void)
106{
107 /* Interrupt mask register set to default reset values */
108 DDL_EINT_WriteReg(IMASK, 0x00000000U);
109 /* Event mask register set to default reset values */
110 DDL_EINT_WriteReg(EMASK, 0x00000000U);
111 /* Rising Trigger selection register set to default reset values */
112 DDL_EINT_WriteReg(RTEN, 0x00000000U);
113 /* Falling Trigger selection register set to default reset values */
114 DDL_EINT_WriteReg(FTEN, 0x00000000U);
115 /* Software interrupt event register set to default reset values */
116 DDL_EINT_WriteReg(SWINTE, 0x00000000U);
117 /* Pending register set to default reset values */
118 DDL_EINT_WriteReg(IPEND, 0x00FFFFFFU);
119
120 return SUCCESS;
121}
122
130uint32_t DDL_EINT_Init(DDL_EINT_InitTypeDef *EINT_InitStruct)
131{
132 ErrorStatus status = SUCCESS;
133 /* Check the parameters */
134 ASSERT_PARAM(IS_DDL_EINT_LINE(EINT_InitStruct->Line));
135 ASSERT_PARAM(IS_FUNCTIONAL_STATE(EINT_InitStruct->LineCommand));
136 ASSERT_PARAM(IS_DDL_EINT_MODE(EINT_InitStruct->Mode));
137
138 /* ENABLE LineCommand */
139 if (EINT_InitStruct->LineCommand != DISABLE)
140 {
141 ASSERT_PARAM(IS_DDL_EINT_TRIGGER(EINT_InitStruct->Trigger));
142
143 /* Configure EINT Lines in range from 0 to 31 */
144 if (EINT_InitStruct->Line != DDL_EINT_LINE_NONE)
145 {
146 switch (EINT_InitStruct->Mode)
147 {
148 case DDL_EINT_MODE_IT:
149 /* First Disable Event on provided Lines */
150 DDL_EINT_DisableEvent(EINT_InitStruct->Line);
151 /* Then Enable IT on provided Lines */
152 DDL_EINT_EnableIT(EINT_InitStruct->Line);
153 break;
155 /* First Disable IT on provided Lines */
156 DDL_EINT_DisableIT(EINT_InitStruct->Line);
157 /* Then Enable Event on provided Lines */
158 DDL_EINT_EnableEvent(EINT_InitStruct->Line);
159 break;
161 /* Directly Enable IT & Event on provided Lines */
162 DDL_EINT_EnableIT(EINT_InitStruct->Line);
163 DDL_EINT_EnableEvent(EINT_InitStruct->Line);
164 break;
165 default:
166 status = ERROR;
167 break;
168 }
169 if (EINT_InitStruct->Trigger != DDL_EINT_TRIGGER_NONE)
170 {
171 switch (EINT_InitStruct->Trigger)
172 {
174 /* First Disable Falling Trigger on provided Lines */
175 DDL_EINT_DisableFallingTrig(EINT_InitStruct->Line);
176 /* Then Enable Rising Trigger on provided Lines */
177 DDL_EINT_EnableRisingTrig(EINT_InitStruct->Line);
178 break;
180 /* First Disable Rising Trigger on provided Lines */
181 DDL_EINT_DisableRisingTrig(EINT_InitStruct->Line);
182 /* Then Enable Falling Trigger on provided Lines */
183 DDL_EINT_EnableFallingTrig(EINT_InitStruct->Line);
184 break;
186 DDL_EINT_EnableRisingTrig(EINT_InitStruct->Line);
187 DDL_EINT_EnableFallingTrig(EINT_InitStruct->Line);
188 break;
189 default:
190 status = ERROR;
191 break;
192 }
193 }
194 }
195 }
196 /* DISABLE LineCommand */
197 else
198 {
199 /* De-configure EINT Lines in range from 0 to 31 */
200 DDL_EINT_DisableIT(EINT_InitStruct->Line);
201 DDL_EINT_DisableEvent(EINT_InitStruct->Line);
202 }
203 return status;
204}
205
212{
213 EINT_InitStruct->Line = DDL_EINT_LINE_NONE;
214 EINT_InitStruct->LineCommand = DISABLE;
215 EINT_InitStruct->Mode = DDL_EINT_MODE_IT;
216 EINT_InitStruct->Trigger = DDL_EINT_TRIGGER_FALLING;
217}
218
222
226
230
231#endif /* defined (EINT) */
232
236
237#endif /* USE_FULL_DDL_DRIVER */
238
G32 assert template file. This file should be copied to the application folder and renamed to g32_ass...
#define ASSERT_PARAM(_PARAM_)
Definition g32_assert.h:58
Header file of EINT DDL module.
#define DDL_EINT_LINE_NONE
#define DDL_EINT_MODE_IT
#define DDL_EINT_MODE_IT_EVENT
#define DDL_EINT_MODE_EVENT
#define DDL_EINT_TRIGGER_FALLING
#define DDL_EINT_TRIGGER_RISING
#define DDL_EINT_TRIGGER_NONE
#define DDL_EINT_TRIGGER_RISING_FALLING
__STATIC_INLINE void DDL_EINT_EnableEvent(uint32_t EintLine)
Enable EintLine Event request for Lines within the range.
__STATIC_INLINE void DDL_EINT_DisableEvent(uint32_t EintLine)
Disable EintLine Event request for Lines within the range.
__STATIC_INLINE void DDL_EINT_EnableFallingTrig(uint32_t EintLine)
Enable EintLine Falling Edge Trigger for Lines within the range.
__STATIC_INLINE void DDL_EINT_DisableFallingTrig(uint32_t EintLine)
Disable EintLine Falling Edge Trigger for Lines within the range.
__STATIC_INLINE void DDL_EINT_EnableIT(uint32_t EintLine)
Enable EintLine Interrupt request for Lines within the range.
__STATIC_INLINE void DDL_EINT_DisableIT(uint32_t EintLine)
Disable EintLine Interrupt request for Lines within the range.
void DDL_EINT_StructInit(DDL_EINT_InitTypeDef *EINT_InitStruct)
Set each DDL_EINT_InitTypeDef field to default value.
uint32_t DDL_EINT_DeInit(void)
De-initialize the EINT registers to their default reset values.
uint32_t DDL_EINT_Init(DDL_EINT_InitTypeDef *EINT_InitStruct)
Initialize the EINT registers according to the specified parameters in EINT_InitStruct.
__STATIC_INLINE void DDL_EINT_EnableRisingTrig(uint32_t EintLine)
Enable EintLine Rising Edge Trigger for Lines within the range.
__STATIC_INLINE void DDL_EINT_DisableRisingTrig(uint32_t EintLine)
Disable EintLine Rising Edge Trigger for Lines within the range.
#define DDL_EINT_WriteReg(__REG__, __VALUE__)
Write a value in EINT register.
#define IS_DDL_EINT_LINE(__VALUE__)
#define IS_DDL_EINT_TRIGGER(__VALUE__)
#define IS_DDL_EINT_MODE(__VALUE__)
FunctionalState LineCommand