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