inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

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