2 ******************************************************************************
3 * @file stm32f7xx_ll_exti.c
4 * @author MCD Application Team
5 * @brief EXTI LL module driver.
6 ******************************************************************************
9 * <h2><center>© 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 "stm32f7xx_ll_exti.h"
23 #ifdef USE_FULL_ASSERT
24 #include "stm32_assert.h"
26 #define assert_param(expr) ((void)0U)
29 /** @addtogroup STM32F7xx_LL_Driver
35 /** @defgroup EXTI_LL EXTI
39 /* Private types -------------------------------------------------------------*/
40 /* Private variables ---------------------------------------------------------*/
41 /* Private constants ---------------------------------------------------------*/
42 /* Private macros ------------------------------------------------------------*/
43 /** @addtogroup EXTI_LL_Private_Macros
47 #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
49 #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \
50 || ((__VALUE__) == LL_EXTI_MODE_EVENT) \
51 || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
54 #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \
55 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \
56 || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \
57 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
63 /* Private function prototypes -----------------------------------------------*/
65 /* Exported functions --------------------------------------------------------*/
66 /** @addtogroup EXTI_LL_Exported_Functions
70 /** @addtogroup EXTI_LL_EF_Init
75 * @brief De-initialize the EXTI registers to their default reset values.
76 * @retval An ErrorStatus enumeration value:
77 * - SUCCESS: EXTI registers are de-initialized
78 * - ERROR: not applicable
80 uint32_t LL_EXTI_DeInit(void)
82 /* Interrupt mask register set to default reset values */
83 LL_EXTI_WriteReg(IMR
, 0x00000000U
);
84 /* Event mask register set to default reset values */
85 LL_EXTI_WriteReg(EMR
, 0x00000000U
);
86 /* Rising Trigger selection register set to default reset values */
87 LL_EXTI_WriteReg(RTSR
, 0x00000000U
);
88 /* Falling Trigger selection register set to default reset values */
89 LL_EXTI_WriteReg(FTSR
, 0x00000000U
);
90 /* Software interrupt event register set to default reset values */
91 LL_EXTI_WriteReg(SWIER
, 0x00000000U
);
92 /* Pending register set to default reset values */
93 LL_EXTI_WriteReg(PR
, 0x01FFFFFFU
);
99 * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
100 * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
101 * @retval An ErrorStatus enumeration value:
102 * - SUCCESS: EXTI registers are initialized
103 * - ERROR: not applicable
105 uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef
*EXTI_InitStruct
)
107 ErrorStatus status
= SUCCESS
;
108 /* Check the parameters */
109 assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct
->Line_0_31
));
110 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct
->LineCommand
));
111 assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct
->Mode
));
113 /* ENABLE LineCommand */
114 if (EXTI_InitStruct
->LineCommand
!= DISABLE
)
116 assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct
->Trigger
));
118 /* Configure EXTI Lines in range from 0 to 31 */
119 if (EXTI_InitStruct
->Line_0_31
!= LL_EXTI_LINE_NONE
)
121 switch (EXTI_InitStruct
->Mode
)
123 case LL_EXTI_MODE_IT
:
124 /* First Disable Event on provided Lines */
125 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct
->Line_0_31
);
126 /* Then Enable IT on provided Lines */
127 LL_EXTI_EnableIT_0_31(EXTI_InitStruct
->Line_0_31
);
129 case LL_EXTI_MODE_EVENT
:
130 /* First Disable IT on provided Lines */
131 LL_EXTI_DisableIT_0_31(EXTI_InitStruct
->Line_0_31
);
132 /* Then Enable Event on provided Lines */
133 LL_EXTI_EnableEvent_0_31(EXTI_InitStruct
->Line_0_31
);
135 case LL_EXTI_MODE_IT_EVENT
:
136 /* Directly Enable IT & Event on provided Lines */
137 LL_EXTI_EnableIT_0_31(EXTI_InitStruct
->Line_0_31
);
138 LL_EXTI_EnableEvent_0_31(EXTI_InitStruct
->Line_0_31
);
144 if (EXTI_InitStruct
->Trigger
!= LL_EXTI_TRIGGER_NONE
)
146 switch (EXTI_InitStruct
->Trigger
)
148 case LL_EXTI_TRIGGER_RISING
:
149 /* First Disable Falling Trigger on provided Lines */
150 LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct
->Line_0_31
);
151 /* Then Enable Rising Trigger on provided Lines */
152 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct
->Line_0_31
);
154 case LL_EXTI_TRIGGER_FALLING
:
155 /* First Disable Rising Trigger on provided Lines */
156 LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct
->Line_0_31
);
157 /* Then Enable Falling Trigger on provided Lines */
158 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct
->Line_0_31
);
160 case LL_EXTI_TRIGGER_RISING_FALLING
:
161 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct
->Line_0_31
);
162 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct
->Line_0_31
);
171 /* DISABLE LineCommand */
174 /* De-configure EXTI Lines in range from 0 to 31 */
175 LL_EXTI_DisableIT_0_31(EXTI_InitStruct
->Line_0_31
);
176 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct
->Line_0_31
);
182 * @brief Set each @ref LL_EXTI_InitTypeDef field to default value.
183 * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
186 void LL_EXTI_StructInit(LL_EXTI_InitTypeDef
*EXTI_InitStruct
)
188 EXTI_InitStruct
->Line_0_31
= LL_EXTI_LINE_NONE
;
189 EXTI_InitStruct
->LineCommand
= DISABLE
;
190 EXTI_InitStruct
->Mode
= LL_EXTI_MODE_IT
;
191 EXTI_InitStruct
->Trigger
= LL_EXTI_TRIGGER_FALLING
;
206 #endif /* defined (EXTI) */
212 #endif /* USE_FULL_LL_DRIVER */
214 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/