Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / STM32F4 / Drivers / STM32F4xx_StdPeriph_Driver / src / stm32f4xx_exti.c
blobd929c80a3bd4034b533931d920b52f35b0a82f1c
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_exti.c
4 * @author MCD Application Team
5 * @version V1.7.1
6 * @date 20-May-2016
7 * @brief This file provides firmware functions to manage the following
8 * functionalities of the EXTI peripheral:
9 * + Initialization and Configuration
10 * + Interrupts and flags management
12 @verbatim
14 ===============================================================================
15 ##### EXTI features #####
16 ===============================================================================
18 [..] External interrupt/event lines are mapped as following:
19 (#) All available GPIO pins are connected to the 16 external
20 interrupt/event lines from EXTI0 to EXTI15.
21 (#) EXTI line 16 is connected to the PVD Output
22 (#) EXTI line 17 is connected to the RTC Alarm event
23 (#) EXTI line 18 is connected to the USB OTG FS Wakeup from suspend event
24 (#) EXTI line 19 is connected to the Ethernet Wakeup event
25 (#) EXTI line 20 is connected to the USB OTG HS (configured in FS) Wakeup event
26 (#) EXTI line 21 is connected to the RTC Tamper and Time Stamp events
27 (#) EXTI line 22 is connected to the RTC Wakeup event
28 (#) EXTI line 23 is connected to the LPTIM Wakeup event
30 ##### How to use this driver #####
31 ===============================================================================
33 [..] In order to use an I/O pin as an external interrupt source, follow steps
34 below:
35 (#) Configure the I/O in input mode using GPIO_Init()
36 (#) Select the input source pin for the EXTI line using SYSCFG_EXTILineConfig()
37 (#) Select the mode(interrupt, event) and configure the trigger
38 selection (Rising, falling or both) using EXTI_Init()
39 (#) Configure NVIC IRQ channel mapped to the EXTI line using NVIC_Init()
41 [..]
42 (@) SYSCFG APB clock must be enabled to get write access to SYSCFG_EXTICRx
43 registers using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
45 @endverbatim
47 ******************************************************************************
48 * @attention
50 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
52 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
53 * You may not use this file except in compliance with the License.
54 * You may obtain a copy of the License at:
56 * http://www.st.com/software_license_agreement_liberty_v2
58 * Unless required by applicable law or agreed to in writing, software
59 * distributed under the License is distributed on an "AS IS" BASIS,
60 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61 * See the License for the specific language governing permissions and
62 * limitations under the License.
64 ******************************************************************************
67 /* Includes ------------------------------------------------------------------*/
68 #include "stm32f4xx_exti.h"
70 /** @addtogroup STM32F4xx_StdPeriph_Driver
71 * @{
74 /** @defgroup EXTI
75 * @brief EXTI driver modules
76 * @{
79 /* Private typedef -----------------------------------------------------------*/
80 /* Private define ------------------------------------------------------------*/
82 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
84 /* Private macro -------------------------------------------------------------*/
85 /* Private variables ---------------------------------------------------------*/
86 /* Private function prototypes -----------------------------------------------*/
87 /* Private functions ---------------------------------------------------------*/
89 /** @defgroup EXTI_Private_Functions
90 * @{
93 /** @defgroup EXTI_Group1 Initialization and Configuration functions
94 * @brief Initialization and Configuration functions
96 @verbatim
97 ===============================================================================
98 ##### Initialization and Configuration functions #####
99 ===============================================================================
101 @endverbatim
102 * @{
106 * @brief Deinitializes the EXTI peripheral registers to their default reset values.
107 * @param None
108 * @retval None
110 void EXTI_DeInit(void)
112 EXTI->IMR = 0x00000000;
113 EXTI->EMR = 0x00000000;
114 EXTI->RTSR = 0x00000000;
115 EXTI->FTSR = 0x00000000;
116 EXTI->PR = 0x007FFFFF;
120 * @brief Initializes the EXTI peripheral according to the specified
121 * parameters in the EXTI_InitStruct.
122 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure
123 * that contains the configuration information for the EXTI peripheral.
124 * @retval None
126 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
128 uint32_t tmp = 0;
130 /* Check the parameters */
131 assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
132 assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
133 assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line));
134 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
136 tmp = (uint32_t)EXTI_BASE;
138 if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
140 /* Clear EXTI line configuration */
141 EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line;
142 EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line;
144 tmp += EXTI_InitStruct->EXTI_Mode;
146 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
148 /* Clear Rising Falling edge configuration */
149 EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line;
150 EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line;
152 /* Select the trigger for the selected external interrupts */
153 if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
155 /* Rising Falling edge */
156 EXTI->RTSR |= EXTI_InitStruct->EXTI_Line;
157 EXTI->FTSR |= EXTI_InitStruct->EXTI_Line;
159 else
161 tmp = (uint32_t)EXTI_BASE;
162 tmp += EXTI_InitStruct->EXTI_Trigger;
164 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
167 else
169 tmp += EXTI_InitStruct->EXTI_Mode;
171 /* Disable the selected external lines */
172 *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line;
177 * @brief Fills each EXTI_InitStruct member with its reset value.
178 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will
179 * be initialized.
180 * @retval None
182 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
184 EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
185 EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
186 EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
187 EXTI_InitStruct->EXTI_LineCmd = DISABLE;
191 * @brief Generates a Software interrupt on selected EXTI line.
192 * @param EXTI_Line: specifies the EXTI line on which the software interrupt
193 * will be generated.
194 * This parameter can be any combination of EXTI_Linex where x can be (0..22)
195 * @retval None
197 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
199 /* Check the parameters */
200 assert_param(IS_EXTI_LINE(EXTI_Line));
202 EXTI->SWIER |= EXTI_Line;
206 * @}
209 /** @defgroup EXTI_Group2 Interrupts and flags management functions
210 * @brief Interrupts and flags management functions
212 @verbatim
213 ===============================================================================
214 ##### Interrupts and flags management functions #####
215 ===============================================================================
217 @endverbatim
218 * @{
222 * @brief Checks whether the specified EXTI line flag is set or not.
223 * @param EXTI_Line: specifies the EXTI line flag to check.
224 * This parameter can be EXTI_Linex where x can be(0..22)
225 * @retval The new state of EXTI_Line (SET or RESET).
227 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
229 FlagStatus bitstatus = RESET;
230 /* Check the parameters */
231 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
233 if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
235 bitstatus = SET;
237 else
239 bitstatus = RESET;
241 return bitstatus;
245 * @brief Clears the EXTI's line pending flags.
246 * @param EXTI_Line: specifies the EXTI lines flags to clear.
247 * This parameter can be any combination of EXTI_Linex where x can be (0..22)
248 * @retval None
250 void EXTI_ClearFlag(uint32_t EXTI_Line)
252 /* Check the parameters */
253 assert_param(IS_EXTI_LINE(EXTI_Line));
255 EXTI->PR = EXTI_Line;
259 * @brief Checks whether the specified EXTI line is asserted or not.
260 * @param EXTI_Line: specifies the EXTI line to check.
261 * This parameter can be EXTI_Linex where x can be(0..22)
262 * @retval The new state of EXTI_Line (SET or RESET).
264 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
266 FlagStatus bitstatus = RESET;
267 /* Check the parameters */
268 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
270 if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
272 bitstatus = SET;
274 else
276 bitstatus = RESET;
278 return bitstatus;
283 * @brief Clears the EXTI's line pending bits.
284 * @param EXTI_Line: specifies the EXTI lines to clear.
285 * This parameter can be any combination of EXTI_Linex where x can be (0..22)
286 * @retval None
288 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
290 /* Check the parameters */
291 assert_param(IS_EXTI_LINE(EXTI_Line));
293 EXTI->PR = EXTI_Line;
297 * @}
301 * @}
305 * @}
309 * @}
312 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/