Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * @file stm32f1xx_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</center></h2> |
||
| 10 | * |
||
| 11 | * Redistribution and use in source and binary forms, with or without modification, |
||
| 12 | * are permitted provided that the following conditions are met: |
||
| 13 | * 1. Redistributions of source code must retain the above copyright notice, |
||
| 14 | * this list of conditions and the following disclaimer. |
||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
| 16 | * this list of conditions and the following disclaimer in the documentation |
||
| 17 | * and/or other materials provided with the distribution. |
||
| 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
| 19 | * may be used to endorse or promote products derived from this software |
||
| 20 | * without specific prior written permission. |
||
| 21 | * |
||
| 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
| 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
| 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
| 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
| 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
| 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
| 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
| 32 | * |
||
| 33 | ****************************************************************************** |
||
| 34 | */ |
||
| 35 | #if defined(USE_FULL_LL_DRIVER) |
||
| 36 | |||
| 37 | /* Includes ------------------------------------------------------------------*/ |
||
| 38 | #include "stm32f1xx_ll_exti.h" |
||
| 39 | #ifdef USE_FULL_ASSERT |
||
| 40 | #include "stm32_assert.h" |
||
| 41 | #else |
||
| 42 | #define assert_param(expr) ((void)0U) |
||
| 43 | #endif |
||
| 44 | |||
| 45 | /** @addtogroup STM32F1xx_LL_Driver |
||
| 46 | * @{ |
||
| 47 | */ |
||
| 48 | |||
| 49 | #if defined (EXTI) |
||
| 50 | |||
| 51 | /** @defgroup EXTI_LL EXTI |
||
| 52 | * @{ |
||
| 53 | */ |
||
| 54 | |||
| 55 | /* Private types -------------------------------------------------------------*/ |
||
| 56 | /* Private variables ---------------------------------------------------------*/ |
||
| 57 | /* Private constants ---------------------------------------------------------*/ |
||
| 58 | /* Private macros ------------------------------------------------------------*/ |
||
| 59 | /** @addtogroup EXTI_LL_Private_Macros |
||
| 60 | * @{ |
||
| 61 | */ |
||
| 62 | |||
| 63 | #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U) |
||
| 64 | |||
| 65 | #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \ |
||
| 66 | || ((__VALUE__) == LL_EXTI_MODE_EVENT) \ |
||
| 67 | || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT)) |
||
| 68 | |||
| 69 | |||
| 70 | #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \ |
||
| 71 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \ |
||
| 72 | || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \ |
||
| 73 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING)) |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @} |
||
| 77 | */ |
||
| 78 | |||
| 79 | /* Private function prototypes -----------------------------------------------*/ |
||
| 80 | |||
| 81 | /* Exported functions --------------------------------------------------------*/ |
||
| 82 | /** @addtogroup EXTI_LL_Exported_Functions |
||
| 83 | * @{ |
||
| 84 | */ |
||
| 85 | |||
| 86 | /** @addtogroup EXTI_LL_EF_Init |
||
| 87 | * @{ |
||
| 88 | */ |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @brief De-initialize the EXTI registers to their default reset values. |
||
| 92 | * @retval An ErrorStatus enumeration value: |
||
| 93 | * - SUCCESS: EXTI registers are de-initialized |
||
| 94 | * - ERROR: not applicable |
||
| 95 | */ |
||
| 96 | uint32_t LL_EXTI_DeInit(void) |
||
| 97 | { |
||
| 98 | /* Interrupt mask register set to default reset values */ |
||
| 99 | LL_EXTI_WriteReg(IMR, 0x00000000U); |
||
| 100 | /* Event mask register set to default reset values */ |
||
| 101 | LL_EXTI_WriteReg(EMR, 0x00000000U); |
||
| 102 | /* Rising Trigger selection register set to default reset values */ |
||
| 103 | LL_EXTI_WriteReg(RTSR, 0x00000000U); |
||
| 104 | /* Falling Trigger selection register set to default reset values */ |
||
| 105 | LL_EXTI_WriteReg(FTSR, 0x00000000U); |
||
| 106 | /* Software interrupt event register set to default reset values */ |
||
| 107 | LL_EXTI_WriteReg(SWIER, 0x00000000U); |
||
| 108 | /* Pending register clear */ |
||
| 109 | LL_EXTI_WriteReg(PR, 0x000FFFFFU); |
||
| 110 | |||
| 111 | return SUCCESS; |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct. |
||
| 116 | * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure. |
||
| 117 | * @retval An ErrorStatus enumeration value: |
||
| 118 | * - SUCCESS: EXTI registers are initialized |
||
| 119 | * - ERROR: not applicable |
||
| 120 | */ |
||
| 121 | uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct) |
||
| 122 | { |
||
| 123 | ErrorStatus status = SUCCESS; |
||
| 124 | /* Check the parameters */ |
||
| 125 | assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31)); |
||
| 126 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand)); |
||
| 127 | assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode)); |
||
| 128 | |||
| 129 | /* ENABLE LineCommand */ |
||
| 130 | if (EXTI_InitStruct->LineCommand != DISABLE) |
||
| 131 | { |
||
| 132 | assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger)); |
||
| 133 | |||
| 134 | /* Configure EXTI Lines in range from 0 to 31 */ |
||
| 135 | if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE) |
||
| 136 | { |
||
| 137 | switch (EXTI_InitStruct->Mode) |
||
| 138 | { |
||
| 139 | case LL_EXTI_MODE_IT: |
||
| 140 | /* First Disable Event on provided Lines */ |
||
| 141 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); |
||
| 142 | /* Then Enable IT on provided Lines */ |
||
| 143 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); |
||
| 144 | break; |
||
| 145 | case LL_EXTI_MODE_EVENT: |
||
| 146 | /* First Disable IT on provided Lines */ |
||
| 147 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); |
||
| 148 | /* Then Enable Event on provided Lines */ |
||
| 149 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); |
||
| 150 | break; |
||
| 151 | case LL_EXTI_MODE_IT_EVENT: |
||
| 152 | /* Directly Enable IT & Event on provided Lines */ |
||
| 153 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); |
||
| 154 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); |
||
| 155 | break; |
||
| 156 | default: |
||
| 157 | status = ERROR; |
||
| 158 | break; |
||
| 159 | } |
||
| 160 | if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE) |
||
| 161 | { |
||
| 162 | switch (EXTI_InitStruct->Trigger) |
||
| 163 | { |
||
| 164 | case LL_EXTI_TRIGGER_RISING: |
||
| 165 | /* First Disable Falling Trigger on provided Lines */ |
||
| 166 | LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); |
||
| 167 | /* Then Enable Rising Trigger on provided Lines */ |
||
| 168 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); |
||
| 169 | break; |
||
| 170 | case LL_EXTI_TRIGGER_FALLING: |
||
| 171 | /* First Disable Rising Trigger on provided Lines */ |
||
| 172 | LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); |
||
| 173 | /* Then Enable Falling Trigger on provided Lines */ |
||
| 174 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); |
||
| 175 | break; |
||
| 176 | case LL_EXTI_TRIGGER_RISING_FALLING: |
||
| 177 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); |
||
| 178 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); |
||
| 179 | break; |
||
| 180 | default: |
||
| 181 | status = ERROR; |
||
| 182 | break; |
||
| 183 | } |
||
| 184 | } |
||
| 185 | } |
||
| 186 | } |
||
| 187 | /* DISABLE LineCommand */ |
||
| 188 | else |
||
| 189 | { |
||
| 190 | /* De-configure EXTI Lines in range from 0 to 31 */ |
||
| 191 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); |
||
| 192 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); |
||
| 193 | } |
||
| 194 | return status; |
||
| 195 | } |
||
| 196 | |||
| 197 | /** |
||
| 198 | * @brief Set each @ref LL_EXTI_InitTypeDef field to default value. |
||
| 199 | * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure. |
||
| 200 | * @retval None |
||
| 201 | */ |
||
| 202 | void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct) |
||
| 203 | { |
||
| 204 | EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE; |
||
| 205 | EXTI_InitStruct->LineCommand = DISABLE; |
||
| 206 | EXTI_InitStruct->Mode = LL_EXTI_MODE_IT; |
||
| 207 | EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING; |
||
| 208 | } |
||
| 209 | |||
| 210 | /** |
||
| 211 | * @} |
||
| 212 | */ |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @} |
||
| 216 | */ |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @} |
||
| 220 | */ |
||
| 221 | |||
| 222 | #endif /* defined (EXTI) */ |
||
| 223 | |||
| 224 | /** |
||
| 225 | * @} |
||
| 226 | */ |
||
| 227 | |||
| 228 | #endif /* USE_FULL_LL_DRIVER */ |
||
| 229 | |||
| 230 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |