mbed SDK library sources

Fork of mbed-src by mbed official

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Tue Jan 07 11:00:05 2014 +0000
Revision:
70:c1fbde68b492
Parent:
52:a51c77007319
Child:
84:f54042cbc282
Synchronized with git revision 3f438a307904431f2782db3c8fa49946b9fc1d85

Full URL: https://github.com/mbedmicro/mbed/commit/3f438a307904431f2782db3c8fa49946b9fc1d85/

[NUCLEO_F103RB] license text changed + sleep hal updated

Who changed what in which revision?

UserRevisionLine numberNew 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 70:c1fbde68b492 8 *******************************************************************************
mbed_official 70:c1fbde68b492 9 * Copyright (c) 2014, STMicroelectronics
mbed_official 70:c1fbde68b492 10 * All rights reserved.
mbed_official 70:c1fbde68b492 11 *
mbed_official 70:c1fbde68b492 12 * Redistribution and use in source and binary forms, with or without
mbed_official 70:c1fbde68b492 13 * modification, are permitted provided that the following conditions are met:
mbed_official 70:c1fbde68b492 14 *
mbed_official 70:c1fbde68b492 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 70:c1fbde68b492 16 * this list of conditions and the following disclaimer.
mbed_official 70:c1fbde68b492 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 70:c1fbde68b492 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 70:c1fbde68b492 19 * and/or other materials provided with the distribution.
mbed_official 70:c1fbde68b492 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 70:c1fbde68b492 21 * may be used to endorse or promote products derived from this software
mbed_official 70:c1fbde68b492 22 * without specific prior written permission.
mbed_official 70:c1fbde68b492 23 *
mbed_official 70:c1fbde68b492 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 70:c1fbde68b492 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 70:c1fbde68b492 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 70:c1fbde68b492 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 70:c1fbde68b492 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 70:c1fbde68b492 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 70:c1fbde68b492 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 70:c1fbde68b492 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 70:c1fbde68b492 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 70:c1fbde68b492 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 70:c1fbde68b492 34 *******************************************************************************
mbed_official 70:c1fbde68b492 35 */
mbed_official 52:a51c77007319 36
mbed_official 52:a51c77007319 37 /* Includes ------------------------------------------------------------------*/
mbed_official 52:a51c77007319 38 #include "stm32f10x_exti.h"
mbed_official 52:a51c77007319 39
mbed_official 52:a51c77007319 40 /** @addtogroup STM32F10x_StdPeriph_Driver
mbed_official 52:a51c77007319 41 * @{
mbed_official 52:a51c77007319 42 */
mbed_official 52:a51c77007319 43
mbed_official 52:a51c77007319 44 /** @defgroup EXTI
mbed_official 52:a51c77007319 45 * @brief EXTI driver modules
mbed_official 52:a51c77007319 46 * @{
mbed_official 52:a51c77007319 47 */
mbed_official 52:a51c77007319 48
mbed_official 52:a51c77007319 49 /** @defgroup EXTI_Private_TypesDefinitions
mbed_official 52:a51c77007319 50 * @{
mbed_official 52:a51c77007319 51 */
mbed_official 52:a51c77007319 52
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 /** @defgroup EXTI_Private_Defines
mbed_official 52:a51c77007319 58 * @{
mbed_official 52:a51c77007319 59 */
mbed_official 52:a51c77007319 60
mbed_official 52:a51c77007319 61 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
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 /** @defgroup EXTI_Private_Macros
mbed_official 52:a51c77007319 68 * @{
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 /** @defgroup EXTI_Private_Variables
mbed_official 52:a51c77007319 76 * @{
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 */
mbed_official 52:a51c77007319 82
mbed_official 52:a51c77007319 83 /** @defgroup EXTI_Private_FunctionPrototypes
mbed_official 52:a51c77007319 84 * @{
mbed_official 52:a51c77007319 85 */
mbed_official 52:a51c77007319 86
mbed_official 52:a51c77007319 87 /**
mbed_official 52:a51c77007319 88 * @}
mbed_official 52:a51c77007319 89 */
mbed_official 52:a51c77007319 90
mbed_official 52:a51c77007319 91 /** @defgroup EXTI_Private_Functions
mbed_official 52:a51c77007319 92 * @{
mbed_official 52:a51c77007319 93 */
mbed_official 52:a51c77007319 94
mbed_official 52:a51c77007319 95 /**
mbed_official 52:a51c77007319 96 * @brief Deinitializes the EXTI peripheral registers to their default reset values.
mbed_official 52:a51c77007319 97 * @param None
mbed_official 52:a51c77007319 98 * @retval None
mbed_official 52:a51c77007319 99 */
mbed_official 52:a51c77007319 100 void EXTI_DeInit(void)
mbed_official 52:a51c77007319 101 {
mbed_official 52:a51c77007319 102 EXTI->IMR = 0x00000000;
mbed_official 52:a51c77007319 103 EXTI->EMR = 0x00000000;
mbed_official 52:a51c77007319 104 EXTI->RTSR = 0x00000000;
mbed_official 52:a51c77007319 105 EXTI->FTSR = 0x00000000;
mbed_official 52:a51c77007319 106 EXTI->PR = 0x000FFFFF;
mbed_official 52:a51c77007319 107 }
mbed_official 52:a51c77007319 108
mbed_official 52:a51c77007319 109 /**
mbed_official 52:a51c77007319 110 * @brief Initializes the EXTI peripheral according to the specified
mbed_official 52:a51c77007319 111 * parameters in the EXTI_InitStruct.
mbed_official 52:a51c77007319 112 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure
mbed_official 52:a51c77007319 113 * that contains the configuration information for the EXTI peripheral.
mbed_official 52:a51c77007319 114 * @retval None
mbed_official 52:a51c77007319 115 */
mbed_official 52:a51c77007319 116 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
mbed_official 52:a51c77007319 117 {
mbed_official 52:a51c77007319 118 uint32_t tmp = 0;
mbed_official 52:a51c77007319 119
mbed_official 52:a51c77007319 120 /* Check the parameters */
mbed_official 52:a51c77007319 121 assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
mbed_official 52:a51c77007319 122 assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
mbed_official 52:a51c77007319 123 assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line));
mbed_official 52:a51c77007319 124 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
mbed_official 52:a51c77007319 125
mbed_official 52:a51c77007319 126 tmp = (uint32_t)EXTI_BASE;
mbed_official 52:a51c77007319 127
mbed_official 52:a51c77007319 128 if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
mbed_official 52:a51c77007319 129 {
mbed_official 52:a51c77007319 130 /* Clear EXTI line configuration */
mbed_official 52:a51c77007319 131 EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 132 EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 133
mbed_official 52:a51c77007319 134 tmp += EXTI_InitStruct->EXTI_Mode;
mbed_official 52:a51c77007319 135
mbed_official 52:a51c77007319 136 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 137
mbed_official 52:a51c77007319 138 /* Clear Rising Falling edge configuration */
mbed_official 52:a51c77007319 139 EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 140 EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 141
mbed_official 52:a51c77007319 142 /* Select the trigger for the selected external interrupts */
mbed_official 52:a51c77007319 143 if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
mbed_official 52:a51c77007319 144 {
mbed_official 52:a51c77007319 145 /* Rising Falling edge */
mbed_official 52:a51c77007319 146 EXTI->RTSR |= EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 147 EXTI->FTSR |= EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 148 }
mbed_official 52:a51c77007319 149 else
mbed_official 52:a51c77007319 150 {
mbed_official 52:a51c77007319 151 tmp = (uint32_t)EXTI_BASE;
mbed_official 52:a51c77007319 152 tmp += EXTI_InitStruct->EXTI_Trigger;
mbed_official 52:a51c77007319 153
mbed_official 52:a51c77007319 154 *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 155 }
mbed_official 52:a51c77007319 156 }
mbed_official 52:a51c77007319 157 else
mbed_official 52:a51c77007319 158 {
mbed_official 52:a51c77007319 159 tmp += EXTI_InitStruct->EXTI_Mode;
mbed_official 52:a51c77007319 160
mbed_official 52:a51c77007319 161 /* Disable the selected external lines */
mbed_official 52:a51c77007319 162 *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line;
mbed_official 52:a51c77007319 163 }
mbed_official 52:a51c77007319 164 }
mbed_official 52:a51c77007319 165
mbed_official 52:a51c77007319 166 /**
mbed_official 52:a51c77007319 167 * @brief Fills each EXTI_InitStruct member with its reset value.
mbed_official 52:a51c77007319 168 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will
mbed_official 52:a51c77007319 169 * be initialized.
mbed_official 52:a51c77007319 170 * @retval None
mbed_official 52:a51c77007319 171 */
mbed_official 52:a51c77007319 172 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
mbed_official 52:a51c77007319 173 {
mbed_official 52:a51c77007319 174 EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
mbed_official 52:a51c77007319 175 EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
mbed_official 52:a51c77007319 176 EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
mbed_official 52:a51c77007319 177 EXTI_InitStruct->EXTI_LineCmd = DISABLE;
mbed_official 52:a51c77007319 178 }
mbed_official 52:a51c77007319 179
mbed_official 52:a51c77007319 180 /**
mbed_official 52:a51c77007319 181 * @brief Generates a Software interrupt.
mbed_official 52:a51c77007319 182 * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled.
mbed_official 52:a51c77007319 183 * This parameter can be any combination of EXTI_Linex where x can be (0..19).
mbed_official 52:a51c77007319 184 * @retval None
mbed_official 52:a51c77007319 185 */
mbed_official 52:a51c77007319 186 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
mbed_official 52:a51c77007319 187 {
mbed_official 52:a51c77007319 188 /* Check the parameters */
mbed_official 52:a51c77007319 189 assert_param(IS_EXTI_LINE(EXTI_Line));
mbed_official 52:a51c77007319 190
mbed_official 52:a51c77007319 191 EXTI->SWIER |= EXTI_Line;
mbed_official 52:a51c77007319 192 }
mbed_official 52:a51c77007319 193
mbed_official 52:a51c77007319 194 /**
mbed_official 52:a51c77007319 195 * @brief Checks whether the specified EXTI line flag is set or not.
mbed_official 52:a51c77007319 196 * @param EXTI_Line: specifies the EXTI line flag to check.
mbed_official 52:a51c77007319 197 * This parameter can be:
mbed_official 52:a51c77007319 198 * @arg EXTI_Linex: External interrupt line x where x(0..19)
mbed_official 52:a51c77007319 199 * @retval The new state of EXTI_Line (SET or RESET).
mbed_official 52:a51c77007319 200 */
mbed_official 52:a51c77007319 201 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
mbed_official 52:a51c77007319 202 {
mbed_official 52:a51c77007319 203 FlagStatus bitstatus = RESET;
mbed_official 52:a51c77007319 204 /* Check the parameters */
mbed_official 52:a51c77007319 205 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
mbed_official 52:a51c77007319 206
mbed_official 52:a51c77007319 207 if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
mbed_official 52:a51c77007319 208 {
mbed_official 52:a51c77007319 209 bitstatus = SET;
mbed_official 52:a51c77007319 210 }
mbed_official 52:a51c77007319 211 else
mbed_official 52:a51c77007319 212 {
mbed_official 52:a51c77007319 213 bitstatus = RESET;
mbed_official 52:a51c77007319 214 }
mbed_official 52:a51c77007319 215 return bitstatus;
mbed_official 52:a51c77007319 216 }
mbed_official 52:a51c77007319 217
mbed_official 52:a51c77007319 218 /**
mbed_official 52:a51c77007319 219 * @brief Clears the EXTI's line pending flags.
mbed_official 52:a51c77007319 220 * @param EXTI_Line: specifies the EXTI lines flags to clear.
mbed_official 52:a51c77007319 221 * This parameter can be any combination of EXTI_Linex where x can be (0..19).
mbed_official 52:a51c77007319 222 * @retval None
mbed_official 52:a51c77007319 223 */
mbed_official 52:a51c77007319 224 void EXTI_ClearFlag(uint32_t EXTI_Line)
mbed_official 52:a51c77007319 225 {
mbed_official 52:a51c77007319 226 /* Check the parameters */
mbed_official 52:a51c77007319 227 assert_param(IS_EXTI_LINE(EXTI_Line));
mbed_official 52:a51c77007319 228
mbed_official 52:a51c77007319 229 EXTI->PR = EXTI_Line;
mbed_official 52:a51c77007319 230 }
mbed_official 52:a51c77007319 231
mbed_official 52:a51c77007319 232 /**
mbed_official 52:a51c77007319 233 * @brief Checks whether the specified EXTI line is asserted or not.
mbed_official 52:a51c77007319 234 * @param EXTI_Line: specifies the EXTI line to check.
mbed_official 52:a51c77007319 235 * This parameter can be:
mbed_official 52:a51c77007319 236 * @arg EXTI_Linex: External interrupt line x where x(0..19)
mbed_official 52:a51c77007319 237 * @retval The new state of EXTI_Line (SET or RESET).
mbed_official 52:a51c77007319 238 */
mbed_official 52:a51c77007319 239 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
mbed_official 52:a51c77007319 240 {
mbed_official 52:a51c77007319 241 ITStatus bitstatus = RESET;
mbed_official 52:a51c77007319 242 uint32_t enablestatus = 0;
mbed_official 52:a51c77007319 243 /* Check the parameters */
mbed_official 52:a51c77007319 244 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
mbed_official 52:a51c77007319 245
mbed_official 52:a51c77007319 246 enablestatus = EXTI->IMR & EXTI_Line;
mbed_official 52:a51c77007319 247 if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
mbed_official 52:a51c77007319 248 {
mbed_official 52:a51c77007319 249 bitstatus = SET;
mbed_official 52:a51c77007319 250 }
mbed_official 52:a51c77007319 251 else
mbed_official 52:a51c77007319 252 {
mbed_official 52:a51c77007319 253 bitstatus = RESET;
mbed_official 52:a51c77007319 254 }
mbed_official 52:a51c77007319 255 return bitstatus;
mbed_official 52:a51c77007319 256 }
mbed_official 52:a51c77007319 257
mbed_official 52:a51c77007319 258 /**
mbed_official 52:a51c77007319 259 * @brief Clears the EXTI's line pending bits.
mbed_official 52:a51c77007319 260 * @param EXTI_Line: specifies the EXTI lines to clear.
mbed_official 52:a51c77007319 261 * This parameter can be any combination of EXTI_Linex where x can be (0..19).
mbed_official 52:a51c77007319 262 * @retval None
mbed_official 52:a51c77007319 263 */
mbed_official 52:a51c77007319 264 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
mbed_official 52:a51c77007319 265 {
mbed_official 52:a51c77007319 266 /* Check the parameters */
mbed_official 52:a51c77007319 267 assert_param(IS_EXTI_LINE(EXTI_Line));
mbed_official 52:a51c77007319 268
mbed_official 52:a51c77007319 269 EXTI->PR = EXTI_Line;
mbed_official 52:a51c77007319 270 }
mbed_official 52:a51c77007319 271
mbed_official 52:a51c77007319 272 /**
mbed_official 52:a51c77007319 273 * @}
mbed_official 52:a51c77007319 274 */
mbed_official 52:a51c77007319 275
mbed_official 52:a51c77007319 276 /**
mbed_official 52:a51c77007319 277 * @}
mbed_official 52:a51c77007319 278 */
mbed_official 52:a51c77007319 279
mbed_official 52:a51c77007319 280 /**
mbed_official 52:a51c77007319 281 * @}
mbed_official 52:a51c77007319 282 */
mbed_official 52:a51c77007319 283
mbed_official 52:a51c77007319 284 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/