mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/stm32f10x_exti.c@52:a51c77007319, 2013-12-02 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Dec 02 11:30:05 2013 +0000
- Revision:
- 52:a51c77007319
- Child:
- 70:c1fbde68b492
Synchronized with git revision 49df530ae72ce97ccc773d1f2c13b38e868e6abd
Full URL: https://github.com/mbedmicro/mbed/commit/49df530ae72ce97ccc773d1f2c13b38e868e6abd/
Add STMicroelectronics NUCLEO_F103RB target
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 52:a51c77007319 | 1 | /** |
mbed_official | 52:a51c77007319 | 2 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 3 | * @file stm32f10x_exti.c |
mbed_official | 52:a51c77007319 | 4 | * @author MCD Application Team |
mbed_official | 52:a51c77007319 | 5 | * @version V3.5.0 |
mbed_official | 52:a51c77007319 | 6 | * @date 11-March-2011 |
mbed_official | 52:a51c77007319 | 7 | * @brief This file provides all the EXTI firmware functions. |
mbed_official | 52:a51c77007319 | 8 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 9 | * @attention |
mbed_official | 52:a51c77007319 | 10 | * |
mbed_official | 52:a51c77007319 | 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
mbed_official | 52:a51c77007319 | 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
mbed_official | 52:a51c77007319 | 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
mbed_official | 52:a51c77007319 | 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
mbed_official | 52:a51c77007319 | 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
mbed_official | 52:a51c77007319 | 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
mbed_official | 52:a51c77007319 | 17 | * |
mbed_official | 52:a51c77007319 | 18 | * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> |
mbed_official | 52:a51c77007319 | 19 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 20 | */ |
mbed_official | 52:a51c77007319 | 21 | |
mbed_official | 52:a51c77007319 | 22 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 52:a51c77007319 | 23 | #include "stm32f10x_exti.h" |
mbed_official | 52:a51c77007319 | 24 | |
mbed_official | 52:a51c77007319 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver |
mbed_official | 52:a51c77007319 | 26 | * @{ |
mbed_official | 52:a51c77007319 | 27 | */ |
mbed_official | 52:a51c77007319 | 28 | |
mbed_official | 52:a51c77007319 | 29 | /** @defgroup EXTI |
mbed_official | 52:a51c77007319 | 30 | * @brief EXTI driver modules |
mbed_official | 52:a51c77007319 | 31 | * @{ |
mbed_official | 52:a51c77007319 | 32 | */ |
mbed_official | 52:a51c77007319 | 33 | |
mbed_official | 52:a51c77007319 | 34 | /** @defgroup EXTI_Private_TypesDefinitions |
mbed_official | 52:a51c77007319 | 35 | * @{ |
mbed_official | 52:a51c77007319 | 36 | */ |
mbed_official | 52:a51c77007319 | 37 | |
mbed_official | 52:a51c77007319 | 38 | /** |
mbed_official | 52:a51c77007319 | 39 | * @} |
mbed_official | 52:a51c77007319 | 40 | */ |
mbed_official | 52:a51c77007319 | 41 | |
mbed_official | 52:a51c77007319 | 42 | /** @defgroup EXTI_Private_Defines |
mbed_official | 52:a51c77007319 | 43 | * @{ |
mbed_official | 52:a51c77007319 | 44 | */ |
mbed_official | 52:a51c77007319 | 45 | |
mbed_official | 52:a51c77007319 | 46 | #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */ |
mbed_official | 52:a51c77007319 | 47 | |
mbed_official | 52:a51c77007319 | 48 | /** |
mbed_official | 52:a51c77007319 | 49 | * @} |
mbed_official | 52:a51c77007319 | 50 | */ |
mbed_official | 52:a51c77007319 | 51 | |
mbed_official | 52:a51c77007319 | 52 | /** @defgroup EXTI_Private_Macros |
mbed_official | 52:a51c77007319 | 53 | * @{ |
mbed_official | 52:a51c77007319 | 54 | */ |
mbed_official | 52:a51c77007319 | 55 | |
mbed_official | 52:a51c77007319 | 56 | /** |
mbed_official | 52:a51c77007319 | 57 | * @} |
mbed_official | 52:a51c77007319 | 58 | */ |
mbed_official | 52:a51c77007319 | 59 | |
mbed_official | 52:a51c77007319 | 60 | /** @defgroup EXTI_Private_Variables |
mbed_official | 52:a51c77007319 | 61 | * @{ |
mbed_official | 52:a51c77007319 | 62 | */ |
mbed_official | 52:a51c77007319 | 63 | |
mbed_official | 52:a51c77007319 | 64 | /** |
mbed_official | 52:a51c77007319 | 65 | * @} |
mbed_official | 52:a51c77007319 | 66 | */ |
mbed_official | 52:a51c77007319 | 67 | |
mbed_official | 52:a51c77007319 | 68 | /** @defgroup EXTI_Private_FunctionPrototypes |
mbed_official | 52:a51c77007319 | 69 | * @{ |
mbed_official | 52:a51c77007319 | 70 | */ |
mbed_official | 52:a51c77007319 | 71 | |
mbed_official | 52:a51c77007319 | 72 | /** |
mbed_official | 52:a51c77007319 | 73 | * @} |
mbed_official | 52:a51c77007319 | 74 | */ |
mbed_official | 52:a51c77007319 | 75 | |
mbed_official | 52:a51c77007319 | 76 | /** @defgroup EXTI_Private_Functions |
mbed_official | 52:a51c77007319 | 77 | * @{ |
mbed_official | 52:a51c77007319 | 78 | */ |
mbed_official | 52:a51c77007319 | 79 | |
mbed_official | 52:a51c77007319 | 80 | /** |
mbed_official | 52:a51c77007319 | 81 | * @brief Deinitializes the EXTI peripheral registers to their default reset values. |
mbed_official | 52:a51c77007319 | 82 | * @param None |
mbed_official | 52:a51c77007319 | 83 | * @retval None |
mbed_official | 52:a51c77007319 | 84 | */ |
mbed_official | 52:a51c77007319 | 85 | void EXTI_DeInit(void) |
mbed_official | 52:a51c77007319 | 86 | { |
mbed_official | 52:a51c77007319 | 87 | EXTI->IMR = 0x00000000; |
mbed_official | 52:a51c77007319 | 88 | EXTI->EMR = 0x00000000; |
mbed_official | 52:a51c77007319 | 89 | EXTI->RTSR = 0x00000000; |
mbed_official | 52:a51c77007319 | 90 | EXTI->FTSR = 0x00000000; |
mbed_official | 52:a51c77007319 | 91 | EXTI->PR = 0x000FFFFF; |
mbed_official | 52:a51c77007319 | 92 | } |
mbed_official | 52:a51c77007319 | 93 | |
mbed_official | 52:a51c77007319 | 94 | /** |
mbed_official | 52:a51c77007319 | 95 | * @brief Initializes the EXTI peripheral according to the specified |
mbed_official | 52:a51c77007319 | 96 | * parameters in the EXTI_InitStruct. |
mbed_official | 52:a51c77007319 | 97 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure |
mbed_official | 52:a51c77007319 | 98 | * that contains the configuration information for the EXTI peripheral. |
mbed_official | 52:a51c77007319 | 99 | * @retval None |
mbed_official | 52:a51c77007319 | 100 | */ |
mbed_official | 52:a51c77007319 | 101 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) |
mbed_official | 52:a51c77007319 | 102 | { |
mbed_official | 52:a51c77007319 | 103 | uint32_t tmp = 0; |
mbed_official | 52:a51c77007319 | 104 | |
mbed_official | 52:a51c77007319 | 105 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 106 | assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode)); |
mbed_official | 52:a51c77007319 | 107 | assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger)); |
mbed_official | 52:a51c77007319 | 108 | assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line)); |
mbed_official | 52:a51c77007319 | 109 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd)); |
mbed_official | 52:a51c77007319 | 110 | |
mbed_official | 52:a51c77007319 | 111 | tmp = (uint32_t)EXTI_BASE; |
mbed_official | 52:a51c77007319 | 112 | |
mbed_official | 52:a51c77007319 | 113 | if (EXTI_InitStruct->EXTI_LineCmd != DISABLE) |
mbed_official | 52:a51c77007319 | 114 | { |
mbed_official | 52:a51c77007319 | 115 | /* Clear EXTI line configuration */ |
mbed_official | 52:a51c77007319 | 116 | EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 117 | EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 118 | |
mbed_official | 52:a51c77007319 | 119 | tmp += EXTI_InitStruct->EXTI_Mode; |
mbed_official | 52:a51c77007319 | 120 | |
mbed_official | 52:a51c77007319 | 121 | *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 122 | |
mbed_official | 52:a51c77007319 | 123 | /* Clear Rising Falling edge configuration */ |
mbed_official | 52:a51c77007319 | 124 | EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 125 | EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 126 | |
mbed_official | 52:a51c77007319 | 127 | /* Select the trigger for the selected external interrupts */ |
mbed_official | 52:a51c77007319 | 128 | if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling) |
mbed_official | 52:a51c77007319 | 129 | { |
mbed_official | 52:a51c77007319 | 130 | /* Rising Falling edge */ |
mbed_official | 52:a51c77007319 | 131 | EXTI->RTSR |= EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 132 | EXTI->FTSR |= EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 133 | } |
mbed_official | 52:a51c77007319 | 134 | else |
mbed_official | 52:a51c77007319 | 135 | { |
mbed_official | 52:a51c77007319 | 136 | tmp = (uint32_t)EXTI_BASE; |
mbed_official | 52:a51c77007319 | 137 | tmp += EXTI_InitStruct->EXTI_Trigger; |
mbed_official | 52:a51c77007319 | 138 | |
mbed_official | 52:a51c77007319 | 139 | *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 140 | } |
mbed_official | 52:a51c77007319 | 141 | } |
mbed_official | 52:a51c77007319 | 142 | else |
mbed_official | 52:a51c77007319 | 143 | { |
mbed_official | 52:a51c77007319 | 144 | tmp += EXTI_InitStruct->EXTI_Mode; |
mbed_official | 52:a51c77007319 | 145 | |
mbed_official | 52:a51c77007319 | 146 | /* Disable the selected external lines */ |
mbed_official | 52:a51c77007319 | 147 | *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line; |
mbed_official | 52:a51c77007319 | 148 | } |
mbed_official | 52:a51c77007319 | 149 | } |
mbed_official | 52:a51c77007319 | 150 | |
mbed_official | 52:a51c77007319 | 151 | /** |
mbed_official | 52:a51c77007319 | 152 | * @brief Fills each EXTI_InitStruct member with its reset value. |
mbed_official | 52:a51c77007319 | 153 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will |
mbed_official | 52:a51c77007319 | 154 | * be initialized. |
mbed_official | 52:a51c77007319 | 155 | * @retval None |
mbed_official | 52:a51c77007319 | 156 | */ |
mbed_official | 52:a51c77007319 | 157 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) |
mbed_official | 52:a51c77007319 | 158 | { |
mbed_official | 52:a51c77007319 | 159 | EXTI_InitStruct->EXTI_Line = EXTI_LINENONE; |
mbed_official | 52:a51c77007319 | 160 | EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; |
mbed_official | 52:a51c77007319 | 161 | EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; |
mbed_official | 52:a51c77007319 | 162 | EXTI_InitStruct->EXTI_LineCmd = DISABLE; |
mbed_official | 52:a51c77007319 | 163 | } |
mbed_official | 52:a51c77007319 | 164 | |
mbed_official | 52:a51c77007319 | 165 | /** |
mbed_official | 52:a51c77007319 | 166 | * @brief Generates a Software interrupt. |
mbed_official | 52:a51c77007319 | 167 | * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled. |
mbed_official | 52:a51c77007319 | 168 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). |
mbed_official | 52:a51c77007319 | 169 | * @retval None |
mbed_official | 52:a51c77007319 | 170 | */ |
mbed_official | 52:a51c77007319 | 171 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line) |
mbed_official | 52:a51c77007319 | 172 | { |
mbed_official | 52:a51c77007319 | 173 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 174 | assert_param(IS_EXTI_LINE(EXTI_Line)); |
mbed_official | 52:a51c77007319 | 175 | |
mbed_official | 52:a51c77007319 | 176 | EXTI->SWIER |= EXTI_Line; |
mbed_official | 52:a51c77007319 | 177 | } |
mbed_official | 52:a51c77007319 | 178 | |
mbed_official | 52:a51c77007319 | 179 | /** |
mbed_official | 52:a51c77007319 | 180 | * @brief Checks whether the specified EXTI line flag is set or not. |
mbed_official | 52:a51c77007319 | 181 | * @param EXTI_Line: specifies the EXTI line flag to check. |
mbed_official | 52:a51c77007319 | 182 | * This parameter can be: |
mbed_official | 52:a51c77007319 | 183 | * @arg EXTI_Linex: External interrupt line x where x(0..19) |
mbed_official | 52:a51c77007319 | 184 | * @retval The new state of EXTI_Line (SET or RESET). |
mbed_official | 52:a51c77007319 | 185 | */ |
mbed_official | 52:a51c77007319 | 186 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) |
mbed_official | 52:a51c77007319 | 187 | { |
mbed_official | 52:a51c77007319 | 188 | FlagStatus bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 189 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 190 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); |
mbed_official | 52:a51c77007319 | 191 | |
mbed_official | 52:a51c77007319 | 192 | if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET) |
mbed_official | 52:a51c77007319 | 193 | { |
mbed_official | 52:a51c77007319 | 194 | bitstatus = SET; |
mbed_official | 52:a51c77007319 | 195 | } |
mbed_official | 52:a51c77007319 | 196 | else |
mbed_official | 52:a51c77007319 | 197 | { |
mbed_official | 52:a51c77007319 | 198 | bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 199 | } |
mbed_official | 52:a51c77007319 | 200 | return bitstatus; |
mbed_official | 52:a51c77007319 | 201 | } |
mbed_official | 52:a51c77007319 | 202 | |
mbed_official | 52:a51c77007319 | 203 | /** |
mbed_official | 52:a51c77007319 | 204 | * @brief Clears the EXTI's line pending flags. |
mbed_official | 52:a51c77007319 | 205 | * @param EXTI_Line: specifies the EXTI lines flags to clear. |
mbed_official | 52:a51c77007319 | 206 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). |
mbed_official | 52:a51c77007319 | 207 | * @retval None |
mbed_official | 52:a51c77007319 | 208 | */ |
mbed_official | 52:a51c77007319 | 209 | void EXTI_ClearFlag(uint32_t EXTI_Line) |
mbed_official | 52:a51c77007319 | 210 | { |
mbed_official | 52:a51c77007319 | 211 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 212 | assert_param(IS_EXTI_LINE(EXTI_Line)); |
mbed_official | 52:a51c77007319 | 213 | |
mbed_official | 52:a51c77007319 | 214 | EXTI->PR = EXTI_Line; |
mbed_official | 52:a51c77007319 | 215 | } |
mbed_official | 52:a51c77007319 | 216 | |
mbed_official | 52:a51c77007319 | 217 | /** |
mbed_official | 52:a51c77007319 | 218 | * @brief Checks whether the specified EXTI line is asserted or not. |
mbed_official | 52:a51c77007319 | 219 | * @param EXTI_Line: specifies the EXTI line to check. |
mbed_official | 52:a51c77007319 | 220 | * This parameter can be: |
mbed_official | 52:a51c77007319 | 221 | * @arg EXTI_Linex: External interrupt line x where x(0..19) |
mbed_official | 52:a51c77007319 | 222 | * @retval The new state of EXTI_Line (SET or RESET). |
mbed_official | 52:a51c77007319 | 223 | */ |
mbed_official | 52:a51c77007319 | 224 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) |
mbed_official | 52:a51c77007319 | 225 | { |
mbed_official | 52:a51c77007319 | 226 | ITStatus bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 227 | uint32_t enablestatus = 0; |
mbed_official | 52:a51c77007319 | 228 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 229 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); |
mbed_official | 52:a51c77007319 | 230 | |
mbed_official | 52:a51c77007319 | 231 | enablestatus = EXTI->IMR & EXTI_Line; |
mbed_official | 52:a51c77007319 | 232 | if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET)) |
mbed_official | 52:a51c77007319 | 233 | { |
mbed_official | 52:a51c77007319 | 234 | bitstatus = SET; |
mbed_official | 52:a51c77007319 | 235 | } |
mbed_official | 52:a51c77007319 | 236 | else |
mbed_official | 52:a51c77007319 | 237 | { |
mbed_official | 52:a51c77007319 | 238 | bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 239 | } |
mbed_official | 52:a51c77007319 | 240 | return bitstatus; |
mbed_official | 52:a51c77007319 | 241 | } |
mbed_official | 52:a51c77007319 | 242 | |
mbed_official | 52:a51c77007319 | 243 | /** |
mbed_official | 52:a51c77007319 | 244 | * @brief Clears the EXTI's line pending bits. |
mbed_official | 52:a51c77007319 | 245 | * @param EXTI_Line: specifies the EXTI lines to clear. |
mbed_official | 52:a51c77007319 | 246 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). |
mbed_official | 52:a51c77007319 | 247 | * @retval None |
mbed_official | 52:a51c77007319 | 248 | */ |
mbed_official | 52:a51c77007319 | 249 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line) |
mbed_official | 52:a51c77007319 | 250 | { |
mbed_official | 52:a51c77007319 | 251 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 252 | assert_param(IS_EXTI_LINE(EXTI_Line)); |
mbed_official | 52:a51c77007319 | 253 | |
mbed_official | 52:a51c77007319 | 254 | EXTI->PR = EXTI_Line; |
mbed_official | 52:a51c77007319 | 255 | } |
mbed_official | 52:a51c77007319 | 256 | |
mbed_official | 52:a51c77007319 | 257 | /** |
mbed_official | 52:a51c77007319 | 258 | * @} |
mbed_official | 52:a51c77007319 | 259 | */ |
mbed_official | 52:a51c77007319 | 260 | |
mbed_official | 52:a51c77007319 | 261 | /** |
mbed_official | 52:a51c77007319 | 262 | * @} |
mbed_official | 52:a51c77007319 | 263 | */ |
mbed_official | 52:a51c77007319 | 264 | |
mbed_official | 52:a51c77007319 | 265 | /** |
mbed_official | 52:a51c77007319 | 266 | * @} |
mbed_official | 52:a51c77007319 | 267 | */ |
mbed_official | 52:a51c77007319 | 268 | |
mbed_official | 52:a51c77007319 | 269 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ |