mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Mar 19 10:15:22 2014 +0000
Revision:
125:23cc3068a9e4
Synchronized with git revision ace35dfba3748c7cdc102eb38ec6b9e1067c3252

Full URL: https://github.com/mbedmicro/mbed/commit/ace35dfba3748c7cdc102eb38ec6b9e1067c3252/

[NUCLEO_F302R8] Add cmsis and hal files + change F401RE clock to 84MHz

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 125:23cc3068a9e4 1 /**
mbed_official 125:23cc3068a9e4 2 ******************************************************************************
mbed_official 125:23cc3068a9e4 3 * @file stm32f30x_exti.c
mbed_official 125:23cc3068a9e4 4 * @author MCD Application Team
mbed_official 125:23cc3068a9e4 5 * @version V1.1.0
mbed_official 125:23cc3068a9e4 6 * @date 27-February-2014
mbed_official 125:23cc3068a9e4 7 * @brief This file provides firmware functions to manage the following
mbed_official 125:23cc3068a9e4 8 * functionalities of the EXTI peripheral:
mbed_official 125:23cc3068a9e4 9 * + Initialization and Configuration
mbed_official 125:23cc3068a9e4 10 * + Interrupts and flags management
mbed_official 125:23cc3068a9e4 11 *
mbed_official 125:23cc3068a9e4 12 @verbatim
mbed_official 125:23cc3068a9e4 13 ===============================================================================
mbed_official 125:23cc3068a9e4 14 ##### EXTI features #####
mbed_official 125:23cc3068a9e4 15 ===============================================================================
mbed_official 125:23cc3068a9e4 16 [..] External interrupt/event lines are mapped as following:
mbed_official 125:23cc3068a9e4 17 (#) All available GPIO pins are connected to the 16 external
mbed_official 125:23cc3068a9e4 18 interrupt/event lines from EXTI0 to EXTI15.
mbed_official 125:23cc3068a9e4 19 (#) EXTI line 16 is connected to the PVD output
mbed_official 125:23cc3068a9e4 20 (#) EXTI line 17 is connected to the RTC Alarm event
mbed_official 125:23cc3068a9e4 21 (#) EXTI line 18 is connected to USB Device wakeup event
mbed_official 125:23cc3068a9e4 22 (#) EXTI line 19 is connected to the RTC Tamper and TimeStamp events
mbed_official 125:23cc3068a9e4 23 (#) EXTI line 20 is connected to the RTC wakeup event
mbed_official 125:23cc3068a9e4 24 (#) EXTI line 21 is connected to the Comparator 1 wakeup event
mbed_official 125:23cc3068a9e4 25 (#) EXTI line 22 is connected to the Comparator 2 wakeup event
mbed_official 125:23cc3068a9e4 26 (#) EXTI line 23 is connected to the I2C1 wakeup event
mbed_official 125:23cc3068a9e4 27 (#) EXTI line 24 is connected to the I2C2 wakeup event
mbed_official 125:23cc3068a9e4 28 (#) EXTI line 25 is connected to the USART1 wakeup event
mbed_official 125:23cc3068a9e4 29 (#) EXTI line 26 is connected to the USART2 wakeup event
mbed_official 125:23cc3068a9e4 30 (#) EXTI line 27 is reserved
mbed_official 125:23cc3068a9e4 31 (#) EXTI line 28 is connected to the USART3 wakeup event
mbed_official 125:23cc3068a9e4 32 (#) EXTI line 29 is connected to the Comparator 3 event
mbed_official 125:23cc3068a9e4 33 (#) EXTI line 30 is connected to the Comparator 4 event
mbed_official 125:23cc3068a9e4 34 (#) EXTI line 31 is connected to the Comparator 5 event
mbed_official 125:23cc3068a9e4 35 (#) EXTI line 32 is connected to the Comparator 6 event
mbed_official 125:23cc3068a9e4 36 (#) EXTI line 33 is connected to the Comparator 7 event
mbed_official 125:23cc3068a9e4 37 (#) EXTI line 34 is connected for thr UART4 wakeup event
mbed_official 125:23cc3068a9e4 38 (#) EXTI line 35 is connected for the UART5 wakeup event
mbed_official 125:23cc3068a9e4 39
mbed_official 125:23cc3068a9e4 40 ##### How to use this driver #####
mbed_official 125:23cc3068a9e4 41 ===============================================================================
mbed_official 125:23cc3068a9e4 42 [..] In order to use an I/O pin as an external interrupt source,
mbed_official 125:23cc3068a9e4 43 follow steps below:
mbed_official 125:23cc3068a9e4 44 (#) Configure the I/O in input mode using GPIO_Init().
mbed_official 125:23cc3068a9e4 45 (#) Select the input source pin for the EXTI line using
mbed_official 125:23cc3068a9e4 46 SYSCFG_EXTILineConfig().
mbed_official 125:23cc3068a9e4 47 (#) Select the mode(interrupt, event) and configure the trigger
mbed_official 125:23cc3068a9e4 48 selection (Rising, falling or both) using EXTI_Init(). For the
mbed_official 125:23cc3068a9e4 49 internal interrupt, the trigger selection is not needed
mbed_official 125:23cc3068a9e4 50 (the active edge is always the rising one).
mbed_official 125:23cc3068a9e4 51 (#) Configure NVIC IRQ channel mapped to the EXTI line using NVIC_Init().
mbed_official 125:23cc3068a9e4 52 (#) Optionally, you can generate a software interrupt using the function
mbed_official 125:23cc3068a9e4 53 EXTI_GenerateSWInterrupt().
mbed_official 125:23cc3068a9e4 54 [..]
mbed_official 125:23cc3068a9e4 55 (@) SYSCFG APB clock must be enabled to get write access to SYSCFG_EXTICRx
mbed_official 125:23cc3068a9e4 56 registers using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
mbed_official 125:23cc3068a9e4 57
mbed_official 125:23cc3068a9e4 58 @endverbatim
mbed_official 125:23cc3068a9e4 59
mbed_official 125:23cc3068a9e4 60 ******************************************************************************
mbed_official 125:23cc3068a9e4 61 * @attention
mbed_official 125:23cc3068a9e4 62 *
mbed_official 125:23cc3068a9e4 63 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 125:23cc3068a9e4 64 *
mbed_official 125:23cc3068a9e4 65 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 125:23cc3068a9e4 66 * are permitted provided that the following conditions are met:
mbed_official 125:23cc3068a9e4 67 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 125:23cc3068a9e4 68 * this list of conditions and the following disclaimer.
mbed_official 125:23cc3068a9e4 69 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 125:23cc3068a9e4 70 * this list of conditions and the following disclaimer in the documentation
mbed_official 125:23cc3068a9e4 71 * and/or other materials provided with the distribution.
mbed_official 125:23cc3068a9e4 72 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 125:23cc3068a9e4 73 * may be used to endorse or promote products derived from this software
mbed_official 125:23cc3068a9e4 74 * without specific prior written permission.
mbed_official 125:23cc3068a9e4 75 *
mbed_official 125:23cc3068a9e4 76 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 125:23cc3068a9e4 77 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 125:23cc3068a9e4 78 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 125:23cc3068a9e4 79 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 125:23cc3068a9e4 80 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 125:23cc3068a9e4 81 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 125:23cc3068a9e4 82 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 125:23cc3068a9e4 83 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 125:23cc3068a9e4 84 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 125:23cc3068a9e4 85 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 125:23cc3068a9e4 86 *
mbed_official 125:23cc3068a9e4 87 ******************************************************************************
mbed_official 125:23cc3068a9e4 88 */
mbed_official 125:23cc3068a9e4 89
mbed_official 125:23cc3068a9e4 90 /* Includes ------------------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 91 #include "stm32f30x_exti.h"
mbed_official 125:23cc3068a9e4 92
mbed_official 125:23cc3068a9e4 93 /** @addtogroup STM32F30x_StdPeriph_Driver
mbed_official 125:23cc3068a9e4 94 * @{
mbed_official 125:23cc3068a9e4 95 */
mbed_official 125:23cc3068a9e4 96
mbed_official 125:23cc3068a9e4 97 /** @defgroup EXTI
mbed_official 125:23cc3068a9e4 98 * @brief EXTI driver modules
mbed_official 125:23cc3068a9e4 99 * @{
mbed_official 125:23cc3068a9e4 100 */
mbed_official 125:23cc3068a9e4 101
mbed_official 125:23cc3068a9e4 102
mbed_official 125:23cc3068a9e4 103 /* Private typedef -----------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 104 /* Private define ------------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 105 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
mbed_official 125:23cc3068a9e4 106
mbed_official 125:23cc3068a9e4 107 /* Private macro -------------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 108 /* Private variables ---------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 109 /* Private function prototypes -----------------------------------------------*/
mbed_official 125:23cc3068a9e4 110 /* Private functions ---------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 111
mbed_official 125:23cc3068a9e4 112 /** @defgroup EXTI_Private_Functions
mbed_official 125:23cc3068a9e4 113 * @{
mbed_official 125:23cc3068a9e4 114 */
mbed_official 125:23cc3068a9e4 115
mbed_official 125:23cc3068a9e4 116 /** @defgroup EXTI_Group1 Initialization and Configuration functions
mbed_official 125:23cc3068a9e4 117 * @brief Initialization and Configuration functions
mbed_official 125:23cc3068a9e4 118 *
mbed_official 125:23cc3068a9e4 119 @verbatim
mbed_official 125:23cc3068a9e4 120 ===============================================================================
mbed_official 125:23cc3068a9e4 121 ##### Initialization and Configuration functions #####
mbed_official 125:23cc3068a9e4 122 ===============================================================================
mbed_official 125:23cc3068a9e4 123
mbed_official 125:23cc3068a9e4 124 @endverbatim
mbed_official 125:23cc3068a9e4 125 * @{
mbed_official 125:23cc3068a9e4 126 */
mbed_official 125:23cc3068a9e4 127
mbed_official 125:23cc3068a9e4 128 /**
mbed_official 125:23cc3068a9e4 129 * @brief Deinitializes the EXTI peripheral registers to their default reset
mbed_official 125:23cc3068a9e4 130 * values.
mbed_official 125:23cc3068a9e4 131 * @param None
mbed_official 125:23cc3068a9e4 132 * @retval None
mbed_official 125:23cc3068a9e4 133 */
mbed_official 125:23cc3068a9e4 134 void EXTI_DeInit(void)
mbed_official 125:23cc3068a9e4 135 {
mbed_official 125:23cc3068a9e4 136 EXTI->IMR = 0x1F800000;
mbed_official 125:23cc3068a9e4 137 EXTI->EMR = 0x00000000;
mbed_official 125:23cc3068a9e4 138 EXTI->RTSR = 0x00000000;
mbed_official 125:23cc3068a9e4 139 EXTI->FTSR = 0x00000000;
mbed_official 125:23cc3068a9e4 140 EXTI->SWIER = 0x00000000;
mbed_official 125:23cc3068a9e4 141 EXTI->PR = 0xE07FFFFF;
mbed_official 125:23cc3068a9e4 142 EXTI->IMR2 = 0x0000000C;
mbed_official 125:23cc3068a9e4 143 EXTI->EMR2 = 0x00000000;
mbed_official 125:23cc3068a9e4 144 EXTI->RTSR2 = 0x00000000;
mbed_official 125:23cc3068a9e4 145 EXTI->FTSR2 = 0x00000000;
mbed_official 125:23cc3068a9e4 146 EXTI->SWIER2 = 0x00000000;
mbed_official 125:23cc3068a9e4 147 EXTI->PR2 = 0x00000003;
mbed_official 125:23cc3068a9e4 148 }
mbed_official 125:23cc3068a9e4 149
mbed_official 125:23cc3068a9e4 150 /**
mbed_official 125:23cc3068a9e4 151 * @brief Initializes the EXTI peripheral according to the specified
mbed_official 125:23cc3068a9e4 152 * parameters in the EXTI_InitStruct.
mbed_official 125:23cc3068a9e4 153 * EXTI_Line specifies the EXTI line (EXTI0....EXTI35).
mbed_official 125:23cc3068a9e4 154 * EXTI_Mode specifies which EXTI line is used as interrupt or an event.
mbed_official 125:23cc3068a9e4 155 * EXTI_Trigger selects the trigger. When the trigger occurs, interrupt
mbed_official 125:23cc3068a9e4 156 * pending bit will be set.
mbed_official 125:23cc3068a9e4 157 * EXTI_LineCmd controls (Enable/Disable) the EXTI line.
mbed_official 125:23cc3068a9e4 158 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure that
mbed_official 125:23cc3068a9e4 159 * contains the configuration information for the EXTI peripheral.
mbed_official 125:23cc3068a9e4 160 * @retval None
mbed_official 125:23cc3068a9e4 161 */
mbed_official 125:23cc3068a9e4 162
mbed_official 125:23cc3068a9e4 163
mbed_official 125:23cc3068a9e4 164 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
mbed_official 125:23cc3068a9e4 165 {
mbed_official 125:23cc3068a9e4 166 uint32_t tmp = 0;
mbed_official 125:23cc3068a9e4 167
mbed_official 125:23cc3068a9e4 168 /* Check the parameters */
mbed_official 125:23cc3068a9e4 169 assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
mbed_official 125:23cc3068a9e4 170 assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
mbed_official 125:23cc3068a9e4 171 assert_param(IS_EXTI_LINE_ALL(EXTI_InitStruct->EXTI_Line));
mbed_official 125:23cc3068a9e4 172 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
mbed_official 125:23cc3068a9e4 173
mbed_official 125:23cc3068a9e4 174 tmp = (uint32_t)EXTI_BASE;
mbed_official 125:23cc3068a9e4 175
mbed_official 125:23cc3068a9e4 176 if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
mbed_official 125:23cc3068a9e4 177 {
mbed_official 125:23cc3068a9e4 178 /* Clear EXTI line configuration */
mbed_official 125:23cc3068a9e4 179 *(__IO uint32_t *) (((uint32_t) &(EXTI->IMR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 180 *(__IO uint32_t *) (((uint32_t) &(EXTI->EMR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 181
mbed_official 125:23cc3068a9e4 182 tmp += EXTI_InitStruct->EXTI_Mode + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20);
mbed_official 125:23cc3068a9e4 183
mbed_official 125:23cc3068a9e4 184 *(__IO uint32_t *) tmp |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 185
mbed_official 125:23cc3068a9e4 186 tmp = (uint32_t)EXTI_BASE;
mbed_official 125:23cc3068a9e4 187
mbed_official 125:23cc3068a9e4 188 /* Clear Rising Falling edge configuration */
mbed_official 125:23cc3068a9e4 189 *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 190 *(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 191
mbed_official 125:23cc3068a9e4 192 /* Select the trigger for the selected interrupts */
mbed_official 125:23cc3068a9e4 193 if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
mbed_official 125:23cc3068a9e4 194 {
mbed_official 125:23cc3068a9e4 195 /* Rising Falling edge */
mbed_official 125:23cc3068a9e4 196 *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 197 *(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 198 }
mbed_official 125:23cc3068a9e4 199 else
mbed_official 125:23cc3068a9e4 200 {
mbed_official 125:23cc3068a9e4 201 tmp += EXTI_InitStruct->EXTI_Trigger + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20);
mbed_official 125:23cc3068a9e4 202
mbed_official 125:23cc3068a9e4 203 *(__IO uint32_t *) tmp |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 204 }
mbed_official 125:23cc3068a9e4 205 }
mbed_official 125:23cc3068a9e4 206
mbed_official 125:23cc3068a9e4 207 else
mbed_official 125:23cc3068a9e4 208 {
mbed_official 125:23cc3068a9e4 209 tmp += EXTI_InitStruct->EXTI_Mode + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20);
mbed_official 125:23cc3068a9e4 210
mbed_official 125:23cc3068a9e4 211 /* Disable the selected external lines */
mbed_official 125:23cc3068a9e4 212 *(__IO uint32_t *) tmp &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 213 }
mbed_official 125:23cc3068a9e4 214
mbed_official 125:23cc3068a9e4 215 }
mbed_official 125:23cc3068a9e4 216
mbed_official 125:23cc3068a9e4 217 /**
mbed_official 125:23cc3068a9e4 218 * @brief Fills each EXTI_InitStruct member with its reset value.
mbed_official 125:23cc3068a9e4 219 * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will
mbed_official 125:23cc3068a9e4 220 * be initialized.
mbed_official 125:23cc3068a9e4 221 * @retval None
mbed_official 125:23cc3068a9e4 222 */
mbed_official 125:23cc3068a9e4 223 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
mbed_official 125:23cc3068a9e4 224 {
mbed_official 125:23cc3068a9e4 225 EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
mbed_official 125:23cc3068a9e4 226 EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
mbed_official 125:23cc3068a9e4 227 EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Rising_Falling;
mbed_official 125:23cc3068a9e4 228 EXTI_InitStruct->EXTI_LineCmd = DISABLE;
mbed_official 125:23cc3068a9e4 229 }
mbed_official 125:23cc3068a9e4 230
mbed_official 125:23cc3068a9e4 231 /**
mbed_official 125:23cc3068a9e4 232 * @brief Generates a Software interrupt on selected EXTI line.
mbed_official 125:23cc3068a9e4 233 * @param EXTI_Line: specifies the EXTI line on which the software interrupt
mbed_official 125:23cc3068a9e4 234 * will be generated.
mbed_official 125:23cc3068a9e4 235 * This parameter can be any combination of EXTI_Linex where x can be (0..20).
mbed_official 125:23cc3068a9e4 236 * @retval None
mbed_official 125:23cc3068a9e4 237 */
mbed_official 125:23cc3068a9e4 238 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
mbed_official 125:23cc3068a9e4 239 {
mbed_official 125:23cc3068a9e4 240 /* Check the parameters */
mbed_official 125:23cc3068a9e4 241 assert_param(IS_EXTI_LINE_EXT(EXTI_Line));
mbed_official 125:23cc3068a9e4 242
mbed_official 125:23cc3068a9e4 243 *(__IO uint32_t *) (((uint32_t) &(EXTI->SWIER)) + ((EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 244
mbed_official 125:23cc3068a9e4 245 }
mbed_official 125:23cc3068a9e4 246
mbed_official 125:23cc3068a9e4 247 /**
mbed_official 125:23cc3068a9e4 248 * @}
mbed_official 125:23cc3068a9e4 249 */
mbed_official 125:23cc3068a9e4 250
mbed_official 125:23cc3068a9e4 251 /** @defgroup EXTI_Group2 Interrupts and flags management functions
mbed_official 125:23cc3068a9e4 252 * @brief EXTI Interrupts and flags management functions
mbed_official 125:23cc3068a9e4 253 *
mbed_official 125:23cc3068a9e4 254 @verbatim
mbed_official 125:23cc3068a9e4 255 ===============================================================================
mbed_official 125:23cc3068a9e4 256 ##### Interrupts and flags management functions #####
mbed_official 125:23cc3068a9e4 257 ===============================================================================
mbed_official 125:23cc3068a9e4 258 [..]
mbed_official 125:23cc3068a9e4 259 This section provides functions allowing to configure the EXTI Interrupts
mbed_official 125:23cc3068a9e4 260 sources and check or clear the flags or pending bits status.
mbed_official 125:23cc3068a9e4 261
mbed_official 125:23cc3068a9e4 262 @endverbatim
mbed_official 125:23cc3068a9e4 263 * @{
mbed_official 125:23cc3068a9e4 264 */
mbed_official 125:23cc3068a9e4 265
mbed_official 125:23cc3068a9e4 266 /**
mbed_official 125:23cc3068a9e4 267 * @brief Checks whether the specified EXTI line flag is set or not.
mbed_official 125:23cc3068a9e4 268 * @param EXTI_Line: specifies the EXTI line flag to check.
mbed_official 125:23cc3068a9e4 269 * This parameter can be any combination of EXTI_Linex where x can be (0..20).
mbed_official 125:23cc3068a9e4 270 * @retval The new state of EXTI_Line (SET or RESET).
mbed_official 125:23cc3068a9e4 271 */
mbed_official 125:23cc3068a9e4 272 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
mbed_official 125:23cc3068a9e4 273 {
mbed_official 125:23cc3068a9e4 274 FlagStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 275
mbed_official 125:23cc3068a9e4 276 /* Check the parameters */
mbed_official 125:23cc3068a9e4 277 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
mbed_official 125:23cc3068a9e4 278
mbed_official 125:23cc3068a9e4 279 if ((*(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20)& (uint32_t)(1 << (EXTI_Line & 0x1F))) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 280 {
mbed_official 125:23cc3068a9e4 281 bitstatus = SET;
mbed_official 125:23cc3068a9e4 282 }
mbed_official 125:23cc3068a9e4 283 else
mbed_official 125:23cc3068a9e4 284 {
mbed_official 125:23cc3068a9e4 285 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 286 }
mbed_official 125:23cc3068a9e4 287 return bitstatus;
mbed_official 125:23cc3068a9e4 288 }
mbed_official 125:23cc3068a9e4 289
mbed_official 125:23cc3068a9e4 290 /**
mbed_official 125:23cc3068a9e4 291 * @brief Clears the EXTI's line pending flags.
mbed_official 125:23cc3068a9e4 292 * @param EXTI_Line: specifies the EXTI lines flags to clear.
mbed_official 125:23cc3068a9e4 293 * This parameter can be any combination of EXTI_Linex where x can be (0..20).
mbed_official 125:23cc3068a9e4 294 * @retval None
mbed_official 125:23cc3068a9e4 295 */
mbed_official 125:23cc3068a9e4 296 void EXTI_ClearFlag(uint32_t EXTI_Line)
mbed_official 125:23cc3068a9e4 297 {
mbed_official 125:23cc3068a9e4 298 /* Check the parameters */
mbed_official 125:23cc3068a9e4 299 assert_param(IS_EXTI_LINE_EXT(EXTI_Line));
mbed_official 125:23cc3068a9e4 300
mbed_official 125:23cc3068a9e4 301 *(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20) = (1 << (EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 302 }
mbed_official 125:23cc3068a9e4 303
mbed_official 125:23cc3068a9e4 304 /**
mbed_official 125:23cc3068a9e4 305 * @brief Checks whether the specified EXTI line is asserted or not.
mbed_official 125:23cc3068a9e4 306 * @param EXTI_Line: specifies the EXTI line to check.
mbed_official 125:23cc3068a9e4 307 * This parameter can be any combination of EXTI_Linex where x can be (0..20).
mbed_official 125:23cc3068a9e4 308 * @retval The new state of EXTI_Line (SET or RESET).
mbed_official 125:23cc3068a9e4 309 */
mbed_official 125:23cc3068a9e4 310 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
mbed_official 125:23cc3068a9e4 311 {
mbed_official 125:23cc3068a9e4 312 ITStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 313
mbed_official 125:23cc3068a9e4 314 /* Check the parameters */
mbed_official 125:23cc3068a9e4 315 assert_param(IS_GET_EXTI_LINE(EXTI_Line));
mbed_official 125:23cc3068a9e4 316
mbed_official 125:23cc3068a9e4 317 if ((*(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20)& (uint32_t)(1 << (EXTI_Line & 0x1F))) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 318 {
mbed_official 125:23cc3068a9e4 319 bitstatus = SET;
mbed_official 125:23cc3068a9e4 320 }
mbed_official 125:23cc3068a9e4 321 else
mbed_official 125:23cc3068a9e4 322 {
mbed_official 125:23cc3068a9e4 323 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 324 }
mbed_official 125:23cc3068a9e4 325 return bitstatus;
mbed_official 125:23cc3068a9e4 326
mbed_official 125:23cc3068a9e4 327 }
mbed_official 125:23cc3068a9e4 328
mbed_official 125:23cc3068a9e4 329 /**
mbed_official 125:23cc3068a9e4 330 * @brief Clears the EXTI's line pending bits.
mbed_official 125:23cc3068a9e4 331 * @param EXTI_Line: specifies the EXTI lines to clear.
mbed_official 125:23cc3068a9e4 332 * This parameter can be any combination of EXTI_Linex where x can be (0..20).
mbed_official 125:23cc3068a9e4 333 * @retval None
mbed_official 125:23cc3068a9e4 334 */
mbed_official 125:23cc3068a9e4 335 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
mbed_official 125:23cc3068a9e4 336 {
mbed_official 125:23cc3068a9e4 337 /* Check the parameters */
mbed_official 125:23cc3068a9e4 338 assert_param(IS_EXTI_LINE_EXT(EXTI_Line));
mbed_official 125:23cc3068a9e4 339
mbed_official 125:23cc3068a9e4 340 *(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20) = (1 << (EXTI_Line & 0x1F));
mbed_official 125:23cc3068a9e4 341 }
mbed_official 125:23cc3068a9e4 342
mbed_official 125:23cc3068a9e4 343 /**
mbed_official 125:23cc3068a9e4 344 * @}
mbed_official 125:23cc3068a9e4 345 */
mbed_official 125:23cc3068a9e4 346
mbed_official 125:23cc3068a9e4 347 /**
mbed_official 125:23cc3068a9e4 348 * @}
mbed_official 125:23cc3068a9e4 349 */
mbed_official 125:23cc3068a9e4 350
mbed_official 125:23cc3068a9e4 351 /**
mbed_official 125:23cc3068a9e4 352 * @}
mbed_official 125:23cc3068a9e4 353 */
mbed_official 125:23cc3068a9e4 354
mbed_official 125:23cc3068a9e4 355 /**
mbed_official 125:23cc3068a9e4 356 * @}
mbed_official 125:23cc3068a9e4 357 */
mbed_official 125:23cc3068a9e4 358
mbed_official 125:23cc3068a9e4 359 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/