Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TUKS-COURSE-TIMER by
stm32l4xx_ll_exti.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_ll_exti.c 00004 * @author MCD Application Team 00005 * @version V1.5.1 00006 * @date 31-May-2016 00007 * @brief EXTI LL module driver. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 #if defined(USE_FULL_LL_DRIVER) 00038 00039 /* Includes ------------------------------------------------------------------*/ 00040 #include "stm32l4xx_ll_exti.h" 00041 #ifdef USE_FULL_ASSERT 00042 #include "stm32_assert.h" 00043 #else 00044 #define assert_param(expr) ((void)0U) 00045 #endif 00046 00047 /** @addtogroup STM32L4xx_LL_Driver 00048 * @{ 00049 */ 00050 00051 #if defined (EXTI) 00052 00053 /** @defgroup EXTI_LL EXTI 00054 * @{ 00055 */ 00056 00057 /* Private types -------------------------------------------------------------*/ 00058 /* Private variables ---------------------------------------------------------*/ 00059 /* Private constants ---------------------------------------------------------*/ 00060 /* Private macros ------------------------------------------------------------*/ 00061 /** @addtogroup EXTI_LL_Private_Macros 00062 * @{ 00063 */ 00064 00065 #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U) 00066 #define IS_LL_EXTI_LINE_32_63(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_32_63) == 0x00000000U) 00067 00068 #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \ 00069 || ((__VALUE__) == LL_EXTI_MODE_EVENT) \ 00070 || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT)) 00071 00072 00073 #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \ 00074 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \ 00075 || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \ 00076 || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING)) 00077 00078 /** 00079 * @} 00080 */ 00081 00082 /* Private function prototypes -----------------------------------------------*/ 00083 00084 /* Exported functions --------------------------------------------------------*/ 00085 /** @addtogroup EXTI_LL_Exported_Functions 00086 * @{ 00087 */ 00088 00089 /** @addtogroup EXTI_LL_EF_Init 00090 * @{ 00091 */ 00092 00093 /** 00094 * @brief De-initialize the EXTI registers to their default reset values. 00095 * @retval An ErrorStatus enumeration value: 00096 * - SUCCESS: EXTI registers are de-initialized 00097 * - ERROR: not applicable 00098 */ 00099 uint32_t LL_EXTI_DeInit(void) 00100 { 00101 /* Interrupt mask register set to default reset values */ 00102 LL_EXTI_WriteReg(IMR1, 0xFF820000U); 00103 /* Event mask register set to default reset values */ 00104 LL_EXTI_WriteReg(EMR1, 0x00000000U); 00105 /* Rising Trigger selection register set to default reset values */ 00106 LL_EXTI_WriteReg(RTSR1, 0x00000000U); 00107 /* Falling Trigger selection register set to default reset values */ 00108 LL_EXTI_WriteReg(FTSR1, 0x00000000U); 00109 /* Software interrupt event register set to default reset values */ 00110 LL_EXTI_WriteReg(SWIER1, 0x00000000U); 00111 /* Pending register set to default reset values */ 00112 LL_EXTI_WriteReg(PR1, 0x007DFFFFU); 00113 00114 /* Interrupt mask register 2 set to default reset values */ 00115 LL_EXTI_WriteReg(IMR2, 0x00000087U); 00116 /* Event mask register 2 set to default reset values */ 00117 LL_EXTI_WriteReg(EMR2, 0x00000000U); 00118 /* Rising Trigger selection register 2 set to default reset values */ 00119 LL_EXTI_WriteReg(RTSR2, 0x00000000U); 00120 /* Falling Trigger selection register 2 set to default reset values */ 00121 LL_EXTI_WriteReg(FTSR2, 0x00000000U); 00122 /* Software interrupt event register 2 set to default reset values */ 00123 LL_EXTI_WriteReg(SWIER2, 0x00000000U); 00124 /* Pending register 2 set to default reset values */ 00125 LL_EXTI_WriteReg(PR2, 0x00000078U); 00126 00127 return SUCCESS; 00128 } 00129 00130 /** 00131 * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct. 00132 * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure. 00133 * @retval An ErrorStatus enumeration value: 00134 * - SUCCESS: EXTI registers are initialized 00135 * - ERROR: not applicable 00136 */ 00137 uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct) 00138 { 00139 ErrorStatus status = SUCCESS; 00140 /* Check the parameters */ 00141 assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31)); 00142 assert_param(IS_LL_EXTI_LINE_32_63(EXTI_InitStruct->Line_32_63)); 00143 assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand)); 00144 assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode)); 00145 00146 /* ENABLE LineCommand */ 00147 if (EXTI_InitStruct->LineCommand != DISABLE) 00148 { 00149 assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger)); 00150 00151 /* Configure EXTI Lines in range from 0 to 31 */ 00152 if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE) 00153 { 00154 switch (EXTI_InitStruct->Mode) 00155 { 00156 case LL_EXTI_MODE_IT: 00157 /* First Disable Event on provided Lines */ 00158 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); 00159 /* Then Enable IT on provided Lines */ 00160 LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); 00161 break; 00162 case LL_EXTI_MODE_EVENT: 00163 /* First Disable IT on provided Lines */ 00164 LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); 00165 /* Then Enable Event on provided Lines */ 00166 LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); 00167 break; 00168 case LL_EXTI_MODE_IT_EVENT: 00169 /* Directly Enable IT & Event on provided Lines */ 00170 LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); 00171 LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); 00172 break; 00173 default: 00174 status = ERROR; 00175 break; 00176 } 00177 if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE) 00178 { 00179 switch (EXTI_InitStruct->Trigger) 00180 { 00181 case LL_EXTI_TRIGGER_RISING: 00182 /* First Disable Falling Trigger on provided Lines */ 00183 LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 00184 /* Then Enable Rising Trigger on provided Lines */ 00185 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 00186 break; 00187 case LL_EXTI_TRIGGER_FALLING: 00188 /* First Disable Rising Trigger on provided Lines */ 00189 LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 00190 /* Then Enable Falling Trigger on provided Lines */ 00191 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 00192 break; 00193 case LL_EXTI_TRIGGER_RISING_FALLING: 00194 LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 00195 LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 00196 break; 00197 default: 00198 status = ERROR; 00199 break; 00200 } 00201 } 00202 } 00203 /* Configure EXTI Lines in range from 32 to 63 */ 00204 if (EXTI_InitStruct->Line_32_63 != LL_EXTI_LINE_NONE) 00205 { 00206 switch (EXTI_InitStruct->Mode) 00207 { 00208 case LL_EXTI_MODE_IT: 00209 /* First Disable Event on provided Lines */ 00210 LL_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63); 00211 /* Then Enable IT on provided Lines */ 00212 LL_EXTI_EnableIT_32_63(EXTI_InitStruct->Line_32_63); 00213 break; 00214 case LL_EXTI_MODE_EVENT: 00215 /* First Disable IT on provided Lines */ 00216 LL_EXTI_DisableIT_32_63(EXTI_InitStruct->Line_32_63); 00217 /* Then Enable Event on provided Lines */ 00218 LL_EXTI_EnableEvent_32_63(EXTI_InitStruct->Line_32_63); 00219 break; 00220 case LL_EXTI_MODE_IT_EVENT: 00221 /* Directly Enable IT & Event on provided Lines */ 00222 LL_EXTI_EnableIT_32_63(EXTI_InitStruct->Line_32_63); 00223 LL_EXTI_EnableEvent_32_63(EXTI_InitStruct->Line_32_63); 00224 break; 00225 default: 00226 status = ERROR; 00227 break; 00228 } 00229 if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE) 00230 { 00231 switch (EXTI_InitStruct->Trigger) 00232 { 00233 case LL_EXTI_TRIGGER_RISING: 00234 /* First Disable Falling Trigger on provided Lines */ 00235 LL_EXTI_DisableFallingTrig_32_63(EXTI_InitStruct->Line_32_63); 00236 /* Then Enable IT on provided Lines */ 00237 LL_EXTI_EnableRisingTrig_32_63(EXTI_InitStruct->Line_32_63); 00238 break; 00239 case LL_EXTI_TRIGGER_FALLING: 00240 /* First Disable Rising Trigger on provided Lines */ 00241 LL_EXTI_DisableRisingTrig_32_63(EXTI_InitStruct->Line_32_63); 00242 /* Then Enable Falling Trigger on provided Lines */ 00243 LL_EXTI_EnableFallingTrig_32_63(EXTI_InitStruct->Line_32_63); 00244 break; 00245 case LL_EXTI_TRIGGER_RISING_FALLING: 00246 LL_EXTI_EnableRisingTrig_32_63(EXTI_InitStruct->Line_32_63); 00247 LL_EXTI_EnableFallingTrig_32_63(EXTI_InitStruct->Line_32_63); 00248 break; 00249 default: 00250 status = ERROR; 00251 break; 00252 } 00253 } 00254 } 00255 } 00256 /* DISABLE LineCommand */ 00257 else 00258 { 00259 /* De-configure EXTI Lines in range from 0 to 31 */ 00260 LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); 00261 LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); 00262 /* De-configure EXTI Lines in range from 32 to 63 */ 00263 LL_EXTI_DisableIT_32_63(EXTI_InitStruct->Line_32_63); 00264 LL_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63); 00265 } 00266 return status; 00267 } 00268 00269 /** 00270 * @brief Set each @ref LL_EXTI_InitTypeDef field to default value. 00271 * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure. 00272 * @retval None 00273 */ 00274 void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct) 00275 { 00276 EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE; 00277 EXTI_InitStruct->Line_32_63 = LL_EXTI_LINE_NONE; 00278 EXTI_InitStruct->LineCommand = DISABLE; 00279 EXTI_InitStruct->Mode = LL_EXTI_MODE_IT; 00280 EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING; 00281 } 00282 00283 /** 00284 * @} 00285 */ 00286 00287 /** 00288 * @} 00289 */ 00290 00291 /** 00292 * @} 00293 */ 00294 00295 #endif /* defined (EXTI) */ 00296 00297 /** 00298 * @} 00299 */ 00300 00301 #endif /* USE_FULL_LL_DRIVER */ 00302 00303 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:38:50 by
