Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
stm32f10x_exti.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f10x_exti.c 00004 * @author MCD Application Team 00005 * @version V3.5.0 00006 * @date 11-March-2011 00007 * @brief This file provides all the EXTI firmware functions. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00012 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 00013 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 00014 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 00015 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 00016 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00017 * 00018 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> 00019 ****************************************************************************** 00020 */ 00021 00022 /* Includes ------------------------------------------------------------------*/ 00023 #include "stm32f10x_exti.h" 00024 00025 /** @addtogroup STM32F10x_StdPeriph_Driver 00026 * @{ 00027 */ 00028 00029 /** @defgroup EXTI 00030 * @brief EXTI driver modules 00031 * @{ 00032 */ 00033 00034 /** @defgroup EXTI_Private_TypesDefinitions 00035 * @{ 00036 */ 00037 00038 /** 00039 * @} 00040 */ 00041 00042 /** @defgroup EXTI_Private_Defines 00043 * @{ 00044 */ 00045 00046 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */ 00047 00048 /** 00049 * @} 00050 */ 00051 00052 /** @defgroup EXTI_Private_Macros 00053 * @{ 00054 */ 00055 00056 /** 00057 * @} 00058 */ 00059 00060 /** @defgroup EXTI_Private_Variables 00061 * @{ 00062 */ 00063 00064 /** 00065 * @} 00066 */ 00067 00068 /** @defgroup EXTI_Private_FunctionPrototypes 00069 * @{ 00070 */ 00071 00072 /** 00073 * @} 00074 */ 00075 00076 /** @defgroup EXTI_Private_Functions 00077 * @{ 00078 */ 00079 00080 /** 00081 * @brief Deinitializes the EXTI peripheral registers to their default reset values. 00082 * @param None 00083 * @retval None 00084 */ 00085 void EXTI_DeInit(void) 00086 { 00087 EXTI->IMR = 0x00000000; 00088 EXTI->EMR = 0x00000000; 00089 EXTI->RTSR = 0x00000000; 00090 EXTI->FTSR = 0x00000000; 00091 EXTI->PR = 0x000FFFFF; 00092 } 00093 00094 /** 00095 * @brief Initializes the EXTI peripheral according to the specified 00096 * parameters in the EXTI_InitStruct. 00097 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure 00098 * that contains the configuration information for the EXTI peripheral. 00099 * @retval None 00100 */ 00101 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) 00102 { 00103 uint32_t tmp = 0; 00104 00105 /* Check the parameters */ 00106 assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode)); 00107 assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger)); 00108 assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line)); 00109 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd)); 00110 00111 tmp = (uint32_t)EXTI_BASE; 00112 00113 if (EXTI_InitStruct->EXTI_LineCmd != DISABLE) 00114 { 00115 /* Clear EXTI line configuration */ 00116 EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line; 00117 EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line; 00118 00119 tmp += EXTI_InitStruct->EXTI_Mode; 00120 00121 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; 00122 00123 /* Clear Rising Falling edge configuration */ 00124 EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line; 00125 EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line; 00126 00127 /* Select the trigger for the selected external interrupts */ 00128 if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling) 00129 { 00130 /* Rising Falling edge */ 00131 EXTI->RTSR |= EXTI_InitStruct->EXTI_Line; 00132 EXTI->FTSR |= EXTI_InitStruct->EXTI_Line; 00133 } 00134 else 00135 { 00136 tmp = (uint32_t)EXTI_BASE; 00137 tmp += EXTI_InitStruct->EXTI_Trigger; 00138 00139 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; 00140 } 00141 } 00142 else 00143 { 00144 tmp += EXTI_InitStruct->EXTI_Mode; 00145 00146 /* Disable the selected external lines */ 00147 *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line; 00148 } 00149 } 00150 00151 /** 00152 * @brief Fills each EXTI_InitStruct member with its reset value. 00153 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will 00154 * be initialized. 00155 * @retval None 00156 */ 00157 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) 00158 { 00159 EXTI_InitStruct->EXTI_Line = EXTI_LINENONE; 00160 EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; 00161 EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; 00162 EXTI_InitStruct->EXTI_LineCmd = DISABLE; 00163 } 00164 00165 /** 00166 * @brief Generates a Software interrupt. 00167 * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled. 00168 * This parameter can be any combination of EXTI_Linex where x can be (0..19). 00169 * @retval None 00170 */ 00171 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line) 00172 { 00173 /* Check the parameters */ 00174 assert_param(IS_EXTI_LINE(EXTI_Line)); 00175 00176 EXTI->SWIER |= EXTI_Line; 00177 } 00178 00179 /** 00180 * @brief Checks whether the specified EXTI line flag is set or not. 00181 * @param EXTI_Line: specifies the EXTI line flag to check. 00182 * This parameter can be: 00183 * @arg EXTI_Linex: External interrupt line x where x(0..19) 00184 * @retval The new state of EXTI_Line (SET or RESET). 00185 */ 00186 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) 00187 { 00188 FlagStatus bitstatus = RESET; 00189 /* Check the parameters */ 00190 assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 00191 00192 if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET) 00193 { 00194 bitstatus = SET; 00195 } 00196 else 00197 { 00198 bitstatus = RESET; 00199 } 00200 return bitstatus; 00201 } 00202 00203 /** 00204 * @brief Clears the EXTI's line pending flags. 00205 * @param EXTI_Line: specifies the EXTI lines flags to clear. 00206 * This parameter can be any combination of EXTI_Linex where x can be (0..19). 00207 * @retval None 00208 */ 00209 void EXTI_ClearFlag(uint32_t EXTI_Line) 00210 { 00211 /* Check the parameters */ 00212 assert_param(IS_EXTI_LINE(EXTI_Line)); 00213 00214 EXTI->PR = EXTI_Line; 00215 } 00216 00217 /** 00218 * @brief Checks whether the specified EXTI line is asserted or not. 00219 * @param EXTI_Line: specifies the EXTI line to check. 00220 * This parameter can be: 00221 * @arg EXTI_Linex: External interrupt line x where x(0..19) 00222 * @retval The new state of EXTI_Line (SET or RESET). 00223 */ 00224 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) 00225 { 00226 ITStatus bitstatus = RESET; 00227 uint32_t enablestatus = 0; 00228 /* Check the parameters */ 00229 assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 00230 00231 enablestatus = EXTI->IMR & EXTI_Line; 00232 if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET)) 00233 { 00234 bitstatus = SET; 00235 } 00236 else 00237 { 00238 bitstatus = RESET; 00239 } 00240 return bitstatus; 00241 } 00242 00243 /** 00244 * @brief Clears the EXTI's line pending bits. 00245 * @param EXTI_Line: specifies the EXTI lines to clear. 00246 * This parameter can be any combination of EXTI_Linex where x can be (0..19). 00247 * @retval None 00248 */ 00249 void EXTI_ClearITPendingBit(uint32_t EXTI_Line) 00250 { 00251 /* Check the parameters */ 00252 assert_param(IS_EXTI_LINE(EXTI_Line)); 00253 00254 EXTI->PR = EXTI_Line; 00255 } 00256 00257 /** 00258 * @} 00259 */ 00260 00261 /** 00262 * @} 00263 */ 00264 00265 /** 00266 * @} 00267 */ 00268 00269 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 20:45:31 by
1.7.2