STM32F4xx HAL Driver master
STM32CubeF4 HAL / LL Drivers API Reference
Loading...
Searching...
No Matches
stm32f4xx_ll_exti.c
Go to the documentation of this file.
1
18#if defined(USE_FULL_LL_DRIVER)
19
20/* Includes ------------------------------------------------------------------*/
21#include "stm32f4xx_ll_exti.h"
22#ifdef USE_FULL_ASSERT
23#include "stm32_assert.h"
24#else
25#define assert_param(expr) ((void)0U)
26#endif
27
31
32#if defined (EXTI)
33
37
38/* Private types -------------------------------------------------------------*/
39/* Private variables ---------------------------------------------------------*/
40/* Private constants ---------------------------------------------------------*/
41/* Private macros ------------------------------------------------------------*/
45
46#define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
47
48#define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \
49 || ((__VALUE__) == LL_EXTI_MODE_EVENT) \
50 || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
51
52
53#define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \
54 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \
55 || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \
56 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
57
61
62/* Private function prototypes -----------------------------------------------*/
63
64/* Exported functions --------------------------------------------------------*/
68
72
79uint32_t LL_EXTI_DeInit(void)
80{
81 /* Interrupt mask register set to default reset values */
82 LL_EXTI_WriteReg(IMR, 0x00000000U);
83 /* Event mask register set to default reset values */
84 LL_EXTI_WriteReg(EMR, 0x00000000U);
85 /* Rising Trigger selection register set to default reset values */
86 LL_EXTI_WriteReg(RTSR, 0x00000000U);
87 /* Falling Trigger selection register set to default reset values */
88 LL_EXTI_WriteReg(FTSR, 0x00000000U);
89 /* Software interrupt event register set to default reset values */
90 LL_EXTI_WriteReg(SWIER, 0x00000000U);
91 /* Pending register set to default reset values */
92 LL_EXTI_WriteReg(PR, 0x00FFFFFFU);
93
94 return SUCCESS;
95}
96
104uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
105{
106 ErrorStatus status = SUCCESS;
107 /* Check the parameters */
108 assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
109 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
110 assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
111
112 /* ENABLE LineCommand */
113 if (EXTI_InitStruct->LineCommand != DISABLE)
114 {
115 assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
116
117 /* Configure EXTI Lines in range from 0 to 31 */
118 if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
119 {
120 switch (EXTI_InitStruct->Mode)
121 {
122 case LL_EXTI_MODE_IT:
123 /* First Disable Event on provided Lines */
124 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
125 /* Then Enable IT on provided Lines */
126 LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
127 break;
128 case LL_EXTI_MODE_EVENT:
129 /* First Disable IT on provided Lines */
130 LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
131 /* Then Enable Event on provided Lines */
132 LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
133 break;
134 case LL_EXTI_MODE_IT_EVENT:
135 /* Directly Enable IT & Event on provided Lines */
136 LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
137 LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
138 break;
139 default:
140 status = ERROR;
141 break;
142 }
143 if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
144 {
145 switch (EXTI_InitStruct->Trigger)
146 {
147 case LL_EXTI_TRIGGER_RISING:
148 /* First Disable Falling Trigger on provided Lines */
149 LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
150 /* Then Enable Rising Trigger on provided Lines */
151 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
152 break;
153 case LL_EXTI_TRIGGER_FALLING:
154 /* First Disable Rising Trigger on provided Lines */
155 LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
156 /* Then Enable Falling Trigger on provided Lines */
157 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
158 break;
159 case LL_EXTI_TRIGGER_RISING_FALLING:
160 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
161 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
162 break;
163 default:
164 status = ERROR;
165 break;
166 }
167 }
168 }
169 }
170 /* DISABLE LineCommand */
171 else
172 {
173 /* De-configure EXTI Lines in range from 0 to 31 */
174 LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
175 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
176 }
177 return status;
178}
179
185void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
186{
187 EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE;
188 EXTI_InitStruct->LineCommand = DISABLE;
189 EXTI_InitStruct->Mode = LL_EXTI_MODE_IT;
190 EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING;
191}
192
196
200
204
205#endif /* defined (EXTI) */
206
210
211#endif /* USE_FULL_LL_DRIVER */
212
#define assert_param(expr)
Header file of EXTI LL module.