Martin Johnson / STM32F3-Discovery

Dependents:   Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more

Committer:
MartinJohnson
Date:
Mon May 09 04:00:25 2016 +0000
Revision:
0:404f5a4f1385
Initial library for STM32F3 discovery board

Who changed what in which revision?

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