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