Set blackbox file handler to NULL after closing file
[inav.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Src / stm32h7xx_ll_exti.c
blobd30bc514b90884fda5be98d643dda3b6923854e2
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_ll_exti.c
4 * @author MCD Application Team
5 * @brief EXTI LL module driver.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
19 #if defined(USE_FULL_LL_DRIVER)
21 /* Includes ------------------------------------------------------------------*/
22 #include "stm32h7xx_ll_exti.h"
24 /** @addtogroup STM32H7xx_LL_Driver
25 * @{
28 #if defined (EXTI)
30 /** @defgroup EXTI_LL EXTI
31 * @{
34 /* Private types -------------------------------------------------------------*/
35 /* Private variables ---------------------------------------------------------*/
36 /* Private constants ---------------------------------------------------------*/
37 /* Private macros ------------------------------------------------------------*/
38 /** @addtogroup EXTI_LL_Private_Macros
39 * @{
42 #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
43 #define IS_LL_EXTI_LINE_32_63(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_32_63) == 0x00000000U)
44 #define IS_LL_EXTI_LINE_64_95(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_64_95) == 0x00000000U)
46 #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \
47 || ((__VALUE__) == LL_EXTI_MODE_EVENT) \
48 || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
51 #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \
52 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \
53 || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \
54 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
56 /**
57 * @}
60 /* Private function prototypes -----------------------------------------------*/
62 /* Exported functions --------------------------------------------------------*/
63 /** @addtogroup EXTI_LL_Exported_Functions
64 * @{
67 /** @addtogroup EXTI_LL_EF_Init
68 * @{
71 /**
72 * @brief De-initialize the EXTI registers to their default reset values.
73 * @retval An ErrorStatus enumeration value:
74 * - SUCCESS: EXTI registers are de-initialized
75 * - ERROR: not applicable
77 ErrorStatus LL_EXTI_DeInit(void)
79 /* Rising Trigger selection register set to default reset values */
80 LL_EXTI_WriteReg(RTSR1, 0x00000000U);
81 LL_EXTI_WriteReg(RTSR2, 0x00000000U);
82 LL_EXTI_WriteReg(RTSR3, 0x00000000U);
84 /* Falling Trigger selection register set to default reset values */
85 LL_EXTI_WriteReg(FTSR1, 0x00000000U);
86 LL_EXTI_WriteReg(FTSR2, 0x00000000U);
87 LL_EXTI_WriteReg(FTSR3, 0x00000000U);
89 /* Software interrupt event register set to default reset values */
90 LL_EXTI_WriteReg(SWIER1, 0x00000000U);
91 LL_EXTI_WriteReg(SWIER2, 0x00000000U);
92 LL_EXTI_WriteReg(SWIER3, 0x00000000U);
94 /* D3 Pending register set to default reset values */
95 LL_EXTI_WriteReg(D3PMR1, 0x00000000U);
96 LL_EXTI_WriteReg(D3PMR2, 0x00000000U);
97 LL_EXTI_WriteReg(D3PMR3, 0x00000000U);
99 /* D3 Pending clear selection register low to default reset values */
100 LL_EXTI_WriteReg(D3PCR1L, 0x00000000U);
101 LL_EXTI_WriteReg(D3PCR2L, 0x00000000U);
102 LL_EXTI_WriteReg(D3PCR3L, 0x00000000U);
104 /* D3 Pending clear selection register high to default reset values */
105 LL_EXTI_WriteReg(D3PCR1H, 0x00000000U);
106 LL_EXTI_WriteReg(D3PCR2H, 0x00000000U);
107 LL_EXTI_WriteReg(D3PCR3H, 0x00000000U);
109 /* Interrupt mask register set to default reset values */
110 LL_EXTI_WriteReg(IMR1, 0x00000000U);
111 LL_EXTI_WriteReg(IMR2, 0x00000000U);
112 LL_EXTI_WriteReg(IMR3, 0x00000000U);
114 /* Event mask register set to default reset values */
115 LL_EXTI_WriteReg(EMR1, 0x00000000U);
116 LL_EXTI_WriteReg(EMR2, 0x00000000U);
117 LL_EXTI_WriteReg(EMR3, 0x00000000U);
119 /* Clear Pending requests */
120 LL_EXTI_WriteReg(PR1, EXTI_PR1_PR_Msk);
121 LL_EXTI_WriteReg(PR2, EXTI_PR2_PR_Msk);
122 LL_EXTI_WriteReg(PR3, EXTI_PR3_PR_Msk);
124 #if defined(DUAL_CORE)
125 /* Interrupt mask register set to default reset values for Core 2 (Coretx-M4)*/
126 LL_EXTI_WriteReg(C2IMR1, 0x00000000U);
127 LL_EXTI_WriteReg(C2IMR2, 0x00000000U);
128 LL_EXTI_WriteReg(C2IMR3, 0x00000000U);
130 /* Event mask register set to default reset values */
131 LL_EXTI_WriteReg(C2EMR1, 0x00000000U);
132 LL_EXTI_WriteReg(C2EMR2, 0x00000000U);
133 LL_EXTI_WriteReg(C2EMR3, 0x00000000U);
135 /* Clear Pending requests */
136 LL_EXTI_WriteReg(C2PR1, EXTI_PR1_PR_Msk);
137 LL_EXTI_WriteReg(C2PR2, EXTI_PR2_PR_Msk);
138 LL_EXTI_WriteReg(C2PR3, EXTI_PR3_PR_Msk);
140 #endif /* DUAL_CORE*/
141 return SUCCESS;
145 * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
146 * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
147 * @retval An ErrorStatus enumeration value:
148 * - SUCCESS: EXTI registers are initialized
149 * - ERROR: not applicable
151 ErrorStatus LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
153 ErrorStatus status = SUCCESS;
154 /* Check the parameters */
155 assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
156 assert_param(IS_LL_EXTI_LINE_32_63(EXTI_InitStruct->Line_32_63));
157 assert_param(IS_LL_EXTI_LINE_64_95(EXTI_InitStruct->Line_64_95));
158 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
159 assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
161 /* ENABLE LineCommand */
162 if (EXTI_InitStruct->LineCommand != DISABLE)
164 assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
166 /* Configure EXTI Lines in range from 0 to 31 */
167 if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
169 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_IT) == LL_EXTI_MODE_IT)
171 /* Enable IT on provided Lines for Cortex-M7*/
172 LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
174 else
176 /* Disable IT on provided Lines for Cortex-M7*/
177 LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
180 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_EVENT) == LL_EXTI_MODE_EVENT)
182 /* Enable event on provided Lines for Cortex-M7 */
183 LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
185 else
187 /* Disable event on provided Lines for Cortex-M7 */
188 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
190 #if defined(DUAL_CORE)
191 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_C2_IT) == LL_EXTI_MODE_C2_IT)
193 /* Enable IT on provided Lines for Cortex-M4 */
194 LL_C2_EXTI_EnableIT_0_31 (EXTI_InitStruct->Line_0_31);
196 else
198 /* Disable IT on provided Lines for Cortex-M4*/
199 LL_C2_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
202 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_C2_EVENT) == LL_EXTI_MODE_C2_EVENT)
204 /* Enable event on provided Lines for Cortex-M4 */
205 LL_C2_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
207 else
209 /* Disable event on provided Lines for Cortex-M4*/
210 LL_C2_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
212 #endif /* DUAL_CORE */
214 if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
216 switch (EXTI_InitStruct->Trigger)
218 case LL_EXTI_TRIGGER_RISING:
219 /* First Disable Falling Trigger on provided Lines */
220 LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
221 /* Then Enable Rising Trigger on provided Lines */
222 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
223 break;
224 case LL_EXTI_TRIGGER_FALLING:
225 /* First Disable Rising Trigger on provided Lines */
226 LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
227 /* Then Enable Falling Trigger on provided Lines */
228 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
229 break;
230 case LL_EXTI_TRIGGER_RISING_FALLING:
231 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
232 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
233 break;
234 default:
235 status = ERROR;
236 break;
240 /* Configure EXTI Lines in range from 32 to 63 */
241 if (EXTI_InitStruct->Line_32_63 != LL_EXTI_LINE_NONE)
243 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_IT) == LL_EXTI_MODE_IT)
245 /* Enable IT on provided Lines for Cortex-M7*/
246 LL_EXTI_EnableIT_32_63(EXTI_InitStruct->Line_32_63);
248 else
250 /* Disable IT on provided Lines for Cortex-M7*/
251 LL_EXTI_DisableIT_32_63(EXTI_InitStruct->Line_32_63);
254 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_EVENT) == LL_EXTI_MODE_EVENT)
256 /* Enable event on provided Lines for Cortex-M7 */
257 LL_EXTI_EnableEvent_32_63(EXTI_InitStruct->Line_32_63);
259 else
261 /* Disable event on provided Lines for Cortex-M7 */
262 LL_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63);
264 #if defined(DUAL_CORE)
265 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_C2_IT) == LL_EXTI_MODE_C2_IT)
267 /* Enable IT on provided Lines for Cortex-M4 */
268 LL_C2_EXTI_EnableIT_32_63 (EXTI_InitStruct->Line_32_63);
270 else
272 /* Disable IT on provided Lines for Cortex-M4 */
273 LL_C2_EXTI_DisableIT_32_63 (EXTI_InitStruct->Line_32_63);
276 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_C2_EVENT) == LL_EXTI_MODE_C2_EVENT)
278 /* Enable event on provided Lines for Cortex-M4 */
279 LL_C2_EXTI_EnableEvent_32_63(EXTI_InitStruct->Line_32_63);
281 else
283 /* Disable event on provided Lines for Cortex-M4 */
284 LL_C2_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63);
286 #endif /* DUAL_CORE */
288 if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
290 switch (EXTI_InitStruct->Trigger)
292 case LL_EXTI_TRIGGER_RISING:
293 /* First Disable Falling Trigger on provided Lines */
294 LL_EXTI_DisableFallingTrig_32_63(EXTI_InitStruct->Line_32_63);
295 /* Then Enable IT on provided Lines */
296 LL_EXTI_EnableRisingTrig_32_63(EXTI_InitStruct->Line_32_63);
297 break;
298 case LL_EXTI_TRIGGER_FALLING:
299 /* First Disable Rising Trigger on provided Lines */
300 LL_EXTI_DisableRisingTrig_32_63(EXTI_InitStruct->Line_32_63);
301 /* Then Enable Falling Trigger on provided Lines */
302 LL_EXTI_EnableFallingTrig_32_63(EXTI_InitStruct->Line_32_63);
303 break;
304 case LL_EXTI_TRIGGER_RISING_FALLING:
305 LL_EXTI_EnableRisingTrig_32_63(EXTI_InitStruct->Line_32_63);
306 LL_EXTI_EnableFallingTrig_32_63(EXTI_InitStruct->Line_32_63);
307 break;
308 default:
309 status = ERROR;
310 break;
314 /* Configure EXTI Lines in range from 64 to 95 */
315 if (EXTI_InitStruct->Line_64_95 != LL_EXTI_LINE_NONE)
317 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_IT) == LL_EXTI_MODE_IT)
319 /* Enable IT on provided Lines for Cortex-M7*/
320 LL_EXTI_EnableIT_64_95(EXTI_InitStruct->Line_64_95);
322 else
324 /* Disable IT on provided Lines for Cortex-M7*/
325 LL_EXTI_DisableIT_64_95(EXTI_InitStruct->Line_64_95);
328 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_EVENT) == LL_EXTI_MODE_EVENT)
330 /* Enable event on provided Lines for Cortex-M7 */
331 LL_EXTI_EnableEvent_64_95(EXTI_InitStruct->Line_64_95);
333 else
335 /* Disable event on provided Lines for Cortex-M7 */
336 LL_EXTI_DisableEvent_64_95(EXTI_InitStruct->Line_64_95);
339 #if defined(DUAL_CORE)
340 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_C2_IT) == LL_EXTI_MODE_C2_IT)
342 /* Enable IT on provided Lines for Cortex-M4 */
343 LL_C2_EXTI_EnableIT_64_95 (EXTI_InitStruct->Line_64_95);
345 else
347 /* Disable IT on provided Lines for Cortex-M4 */
348 LL_C2_EXTI_DisableIT_64_95 (EXTI_InitStruct->Line_64_95);
351 if((EXTI_InitStruct->Mode & LL_EXTI_MODE_C2_EVENT) == LL_EXTI_MODE_C2_EVENT)
353 /* Enable event on provided Lines for Cortex-M4 */
354 LL_C2_EXTI_EnableEvent_64_95(EXTI_InitStruct->Line_64_95);
356 else
358 /* Disable event on provided Lines for Cortex-M4 */
359 LL_C2_EXTI_DisableEvent_64_95(EXTI_InitStruct->Line_64_95);
361 #endif /* DUAL_CORE */
363 if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
365 switch (EXTI_InitStruct->Trigger)
367 case LL_EXTI_TRIGGER_RISING:
368 /* First Disable Falling Trigger on provided Lines */
369 LL_EXTI_DisableFallingTrig_64_95(EXTI_InitStruct->Line_64_95);
370 /* Then Enable IT on provided Lines */
371 LL_EXTI_EnableRisingTrig_64_95(EXTI_InitStruct->Line_64_95);
372 break;
373 case LL_EXTI_TRIGGER_FALLING:
374 /* First Disable Rising Trigger on provided Lines */
375 LL_EXTI_DisableRisingTrig_64_95(EXTI_InitStruct->Line_64_95);
376 /* Then Enable Falling Trigger on provided Lines */
377 LL_EXTI_EnableFallingTrig_64_95(EXTI_InitStruct->Line_64_95);
378 break;
379 case LL_EXTI_TRIGGER_RISING_FALLING:
380 LL_EXTI_EnableRisingTrig_64_95(EXTI_InitStruct->Line_64_95);
381 LL_EXTI_EnableFallingTrig_64_95(EXTI_InitStruct->Line_64_95);
382 break;
383 default:
384 status = ERROR;
385 break;
390 else /* DISABLE LineCommand */
392 /* Disable IT on provided Lines for Cortex-M7*/
393 LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
394 LL_EXTI_DisableIT_32_63(EXTI_InitStruct->Line_32_63);
395 LL_EXTI_DisableIT_64_95(EXTI_InitStruct->Line_64_95);
397 /* Disable event on provided Lines for Cortex-M7 */
398 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
399 LL_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63);
400 LL_EXTI_DisableEvent_64_95(EXTI_InitStruct->Line_64_95);
402 #if defined(DUAL_CORE)
403 /* Disable IT on provided Lines for Cortex-M4*/
404 LL_C2_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
405 LL_C2_EXTI_DisableIT_32_63(EXTI_InitStruct->Line_32_63);
406 LL_C2_EXTI_DisableIT_64_95(EXTI_InitStruct->Line_64_95);
408 /* Disable event on provided Lines for Cortex-M4 */
409 LL_C2_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
410 LL_C2_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63);
411 LL_C2_EXTI_DisableEvent_64_95(EXTI_InitStruct->Line_64_95);
412 #endif /* DUAL_CORE */
415 return status;
419 * @brief Set each @ref LL_EXTI_InitTypeDef field to default value.
420 * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
421 * @retval None
423 void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
425 EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE;
426 EXTI_InitStruct->Line_32_63 = LL_EXTI_LINE_NONE;
427 EXTI_InitStruct->Line_64_95 = LL_EXTI_LINE_NONE;
428 EXTI_InitStruct->LineCommand = DISABLE;
429 EXTI_InitStruct->Mode = LL_EXTI_MODE_IT;
430 EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING;
434 * @}
438 * @}
442 * @}
445 #endif /* defined (EXTI) */
448 * @}
451 #endif /* USE_FULL_LL_DRIVER */
453 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/