Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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