| 1 | /**
|
|---|
| 2 | ******************************************************************************
|
|---|
| 3 | * @file stm32f4xx_ll_exti.c
|
|---|
| 4 | * @author MCD Application Team
|
|---|
| 5 | * @brief EXTI LL module driver.
|
|---|
| 6 | ******************************************************************************
|
|---|
| 7 | * @attention
|
|---|
| 8 | *
|
|---|
| 9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|---|
| 10 | * All rights reserved.</center></h2>
|
|---|
| 11 | *
|
|---|
| 12 | * This software component is licensed by ST under BSD 3-Clause license,
|
|---|
| 13 | * the "License"; You may not use this file except in compliance with the
|
|---|
| 14 | * License. You may obtain a copy of the License at:
|
|---|
| 15 | * opensource.org/licenses/BSD-3-Clause
|
|---|
| 16 | *
|
|---|
| 17 | ******************************************************************************
|
|---|
| 18 | */
|
|---|
| 19 | #if defined(USE_FULL_LL_DRIVER)
|
|---|
| 20 |
|
|---|
| 21 | /* Includes ------------------------------------------------------------------*/
|
|---|
| 22 | #include "stm32f4xx_ll_exti.h"
|
|---|
| 23 | #ifdef USE_FULL_ASSERT
|
|---|
| 24 | #include "stm32_assert.h"
|
|---|
| 25 | #else
|
|---|
| 26 | #define assert_param(expr) ((void)0U)
|
|---|
| 27 | #endif
|
|---|
| 28 |
|
|---|
| 29 | /** @addtogroup STM32F4xx_LL_Driver
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 |
|
|---|
| 33 | #if defined (EXTI)
|
|---|
| 34 |
|
|---|
| 35 | /** @defgroup EXTI_LL EXTI
|
|---|
| 36 | * @{
|
|---|
| 37 | */
|
|---|
| 38 |
|
|---|
| 39 | /* Private types -------------------------------------------------------------*/
|
|---|
| 40 | /* Private variables ---------------------------------------------------------*/
|
|---|
| 41 | /* Private constants ---------------------------------------------------------*/
|
|---|
| 42 | /* Private macros ------------------------------------------------------------*/
|
|---|
| 43 | /** @addtogroup EXTI_LL_Private_Macros
|
|---|
| 44 | * @{
|
|---|
| 45 | */
|
|---|
| 46 |
|
|---|
| 47 | #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
|
|---|
| 48 |
|
|---|
| 49 | #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \
|
|---|
| 50 | || ((__VALUE__) == LL_EXTI_MODE_EVENT) \
|
|---|
| 51 | || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \
|
|---|
| 55 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \
|
|---|
| 56 | || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \
|
|---|
| 57 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
|
|---|
| 58 |
|
|---|
| 59 | /**
|
|---|
| 60 | * @}
|
|---|
| 61 | */
|
|---|
| 62 |
|
|---|
| 63 | /* Private function prototypes -----------------------------------------------*/
|
|---|
| 64 |
|
|---|
| 65 | /* Exported functions --------------------------------------------------------*/
|
|---|
| 66 | /** @addtogroup EXTI_LL_Exported_Functions
|
|---|
| 67 | * @{
|
|---|
| 68 | */
|
|---|
| 69 |
|
|---|
| 70 | /** @addtogroup EXTI_LL_EF_Init
|
|---|
| 71 | * @{
|
|---|
| 72 | */
|
|---|
| 73 |
|
|---|
| 74 | /**
|
|---|
| 75 | * @brief De-initialize the EXTI registers to their default reset values.
|
|---|
| 76 | * @retval An ErrorStatus enumeration value:
|
|---|
| 77 | * - SUCCESS: EXTI registers are de-initialized
|
|---|
| 78 | * - ERROR: not applicable
|
|---|
| 79 | */
|
|---|
| 80 | uint32_t LL_EXTI_DeInit(void)
|
|---|
| 81 | {
|
|---|
| 82 | /* Interrupt mask register set to default reset values */
|
|---|
| 83 | LL_EXTI_WriteReg(IMR, 0x00000000U);
|
|---|
| 84 | /* Event mask register set to default reset values */
|
|---|
| 85 | LL_EXTI_WriteReg(EMR, 0x00000000U);
|
|---|
| 86 | /* Rising Trigger selection register set to default reset values */
|
|---|
| 87 | LL_EXTI_WriteReg(RTSR, 0x00000000U);
|
|---|
| 88 | /* Falling Trigger selection register set to default reset values */
|
|---|
| 89 | LL_EXTI_WriteReg(FTSR, 0x00000000U);
|
|---|
| 90 | /* Software interrupt event register set to default reset values */
|
|---|
| 91 | LL_EXTI_WriteReg(SWIER, 0x00000000U);
|
|---|
| 92 | /* Pending register set to default reset values */
|
|---|
| 93 | LL_EXTI_WriteReg(PR, 0x00FFFFFFU);
|
|---|
| 94 |
|
|---|
| 95 | return SUCCESS;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | /**
|
|---|
| 99 | * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
|
|---|
| 100 | * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
|
|---|
| 101 | * @retval An ErrorStatus enumeration value:
|
|---|
| 102 | * - SUCCESS: EXTI registers are initialized
|
|---|
| 103 | * - ERROR: not applicable
|
|---|
| 104 | */
|
|---|
| 105 | uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
|
|---|
| 106 | {
|
|---|
| 107 | ErrorStatus status = SUCCESS;
|
|---|
| 108 | /* Check the parameters */
|
|---|
| 109 | assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
|
|---|
| 110 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
|
|---|
| 111 | assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
|
|---|
| 112 |
|
|---|
| 113 | /* ENABLE LineCommand */
|
|---|
| 114 | if (EXTI_InitStruct->LineCommand != DISABLE)
|
|---|
| 115 | {
|
|---|
| 116 | assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
|
|---|
| 117 |
|
|---|
| 118 | /* Configure EXTI Lines in range from 0 to 31 */
|
|---|
| 119 | if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
|
|---|
| 120 | {
|
|---|
| 121 | switch (EXTI_InitStruct->Mode)
|
|---|
| 122 | {
|
|---|
| 123 | case LL_EXTI_MODE_IT:
|
|---|
| 124 | /* First Disable Event on provided Lines */
|
|---|
| 125 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 126 | /* Then Enable IT on provided Lines */
|
|---|
| 127 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 128 | break;
|
|---|
| 129 | case LL_EXTI_MODE_EVENT:
|
|---|
| 130 | /* First Disable IT on provided Lines */
|
|---|
| 131 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 132 | /* Then Enable Event on provided Lines */
|
|---|
| 133 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 134 | break;
|
|---|
| 135 | case LL_EXTI_MODE_IT_EVENT:
|
|---|
| 136 | /* Directly Enable IT & Event on provided Lines */
|
|---|
| 137 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 138 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 139 | break;
|
|---|
| 140 | default:
|
|---|
| 141 | status = ERROR;
|
|---|
| 142 | break;
|
|---|
| 143 | }
|
|---|
| 144 | if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
|
|---|
| 145 | {
|
|---|
| 146 | switch (EXTI_InitStruct->Trigger)
|
|---|
| 147 | {
|
|---|
| 148 | case LL_EXTI_TRIGGER_RISING:
|
|---|
| 149 | /* First Disable Falling Trigger on provided Lines */
|
|---|
| 150 | LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 151 | /* Then Enable Rising Trigger on provided Lines */
|
|---|
| 152 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 153 | break;
|
|---|
| 154 | case LL_EXTI_TRIGGER_FALLING:
|
|---|
| 155 | /* First Disable Rising Trigger on provided Lines */
|
|---|
| 156 | LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 157 | /* Then Enable Falling Trigger on provided Lines */
|
|---|
| 158 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 159 | break;
|
|---|
| 160 | case LL_EXTI_TRIGGER_RISING_FALLING:
|
|---|
| 161 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 162 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 163 | break;
|
|---|
| 164 | default:
|
|---|
| 165 | status = ERROR;
|
|---|
| 166 | break;
|
|---|
| 167 | }
|
|---|
| 168 | }
|
|---|
| 169 | }
|
|---|
| 170 | }
|
|---|
| 171 | /* DISABLE LineCommand */
|
|---|
| 172 | else
|
|---|
| 173 | {
|
|---|
| 174 | /* De-configure EXTI Lines in range from 0 to 31 */
|
|---|
| 175 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 176 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
|
|---|
| 177 | }
|
|---|
| 178 | return status;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | /**
|
|---|
| 182 | * @brief Set each @ref LL_EXTI_InitTypeDef field to default value.
|
|---|
| 183 | * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
|
|---|
| 184 | * @retval None
|
|---|
| 185 | */
|
|---|
| 186 | void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
|
|---|
| 187 | {
|
|---|
| 188 | EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE;
|
|---|
| 189 | EXTI_InitStruct->LineCommand = DISABLE;
|
|---|
| 190 | EXTI_InitStruct->Mode = LL_EXTI_MODE_IT;
|
|---|
| 191 | EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | /**
|
|---|
| 195 | * @}
|
|---|
| 196 | */
|
|---|
| 197 |
|
|---|
| 198 | /**
|
|---|
| 199 | * @}
|
|---|
| 200 | */
|
|---|
| 201 |
|
|---|
| 202 | /**
|
|---|
| 203 | * @}
|
|---|
| 204 | */
|
|---|
| 205 |
|
|---|
| 206 | #endif /* defined (EXTI) */
|
|---|
| 207 |
|
|---|
| 208 | /**
|
|---|
| 209 | * @}
|
|---|
| 210 | */
|
|---|
| 211 |
|
|---|
| 212 | #endif /* USE_FULL_LL_DRIVER */
|
|---|
| 213 |
|
|---|
| 214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|---|