Create configuration-nopid-system.md
[u360gts.git] / lib / main / STM32F10x_StdPeriph_Driver / src / stm32f10x_exti.c
blobb6290d5826249264eca1c66185bbcdb8be8bcc48
1 /**
2 ******************************************************************************
3 * @file stm32f10x_exti.c
4 * @author MCD Application Team
5 * @version V3.5.0
6 * @date 11-March-2011
7 * @brief This file provides all the EXTI firmware functions.
8 ******************************************************************************
9 * @attention
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Includes ------------------------------------------------------------------*/
23 #include "stm32f10x_exti.h"
25 /** @addtogroup STM32F10x_StdPeriph_Driver
26 * @{
29 /** @defgroup EXTI
30 * @brief EXTI driver modules
31 * @{
34 /** @defgroup EXTI_Private_TypesDefinitions
35 * @{
38 /**
39 * @}
42 /** @defgroup EXTI_Private_Defines
43 * @{
46 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
48 /**
49 * @}
52 /** @defgroup EXTI_Private_Macros
53 * @{
56 /**
57 * @}
60 /** @defgroup EXTI_Private_Variables
61 * @{
64 /**
65 * @}
68 /** @defgroup EXTI_Private_FunctionPrototypes
69 * @{
72 /**
73 * @}
76 /** @defgroup EXTI_Private_Functions
77 * @{
80 /**
81 * @brief Deinitializes the EXTI peripheral registers to their default reset values.
82 * @param None
83 * @retval None
85 void EXTI_DeInit(void)
87 EXTI->IMR = 0x00000000;
88 EXTI->EMR = 0x00000000;
89 EXTI->RTSR = 0x00000000;
90 EXTI->FTSR = 0x00000000;
91 EXTI->PR = 0x000FFFFF;
94 /**
95 * @brief Initializes the EXTI peripheral according to the specified
96 * parameters in the EXTI_InitStruct.
97 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure
98 * that contains the configuration information for the EXTI peripheral.
99 * @retval None
101 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
103 uint32_t tmp = 0;
105 /* Check the parameters */
106 assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
107 assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
108 assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line));
109 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
111 tmp = (uint32_t)EXTI_BASE;
113 if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
115 /* Clear EXTI line configuration */
116 EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line;
117 EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line;
119 tmp += EXTI_InitStruct->EXTI_Mode;
121 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
123 /* Clear Rising Falling edge configuration */
124 EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line;
125 EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line;
127 /* Select the trigger for the selected external interrupts */
128 if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
130 /* Rising Falling edge */
131 EXTI->RTSR |= EXTI_InitStruct->EXTI_Line;
132 EXTI->FTSR |= EXTI_InitStruct->EXTI_Line;
134 else
136 tmp = (uint32_t)EXTI_BASE;
137 tmp += EXTI_InitStruct->EXTI_Trigger;
139 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
142 else
144 tmp += EXTI_InitStruct->EXTI_Mode;
146 /* Disable the selected external lines */
147 *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line;
152 * @brief Fills each EXTI_InitStruct member with its reset value.
153 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will
154 * be initialized.
155 * @retval None
157 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
159 EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
160 EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
161 EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
162 EXTI_InitStruct->EXTI_LineCmd = DISABLE;
166 * @brief Generates a Software interrupt.
167 * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled.
168 * This parameter can be any combination of EXTI_Linex where x can be (0..19).
169 * @retval None
171 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
173 /* Check the parameters */
174 assert_param(IS_EXTI_LINE(EXTI_Line));
176 EXTI->SWIER |= EXTI_Line;
180 * @brief Checks whether the specified EXTI line flag is set or not.
181 * @param EXTI_Line: specifies the EXTI line flag to check.
182 * This parameter can be:
183 * @arg EXTI_Linex: External interrupt line x where x(0..19)
184 * @retval The new state of EXTI_Line (SET or RESET).
186 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
188 FlagStatus bitstatus = RESET;
189 /* Check the parameters */
190 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
192 if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
194 bitstatus = SET;
196 else
198 bitstatus = RESET;
200 return bitstatus;
204 * @brief Clears the EXTI's line pending flags.
205 * @param EXTI_Line: specifies the EXTI lines flags to clear.
206 * This parameter can be any combination of EXTI_Linex where x can be (0..19).
207 * @retval None
209 void EXTI_ClearFlag(uint32_t EXTI_Line)
211 /* Check the parameters */
212 assert_param(IS_EXTI_LINE(EXTI_Line));
214 EXTI->PR = EXTI_Line;
218 * @brief Checks whether the specified EXTI line is asserted or not.
219 * @param EXTI_Line: specifies the EXTI line to check.
220 * This parameter can be:
221 * @arg EXTI_Linex: External interrupt line x where x(0..19)
222 * @retval The new state of EXTI_Line (SET or RESET).
224 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
226 ITStatus bitstatus = RESET;
227 uint32_t enablestatus = 0;
228 /* Check the parameters */
229 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
231 enablestatus = EXTI->IMR & EXTI_Line;
232 if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
234 bitstatus = SET;
236 else
238 bitstatus = RESET;
240 return bitstatus;
244 * @brief Clears the EXTI's line pending bits.
245 * @param EXTI_Line: specifies the EXTI lines to clear.
246 * This parameter can be any combination of EXTI_Linex where x can be (0..19).
247 * @retval None
249 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
251 /* Check the parameters */
252 assert_param(IS_EXTI_LINE(EXTI_Line));
254 EXTI->PR = EXTI_Line;
258 * @}
262 * @}
266 * @}
269 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/