diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/STM32/STM32F37x/stm32_isr.c')
-rw-r--r-- | lib/chibios/os/hal/ports/STM32/STM32F37x/stm32_isr.c | 255 |
1 files changed, 255 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/STM32/STM32F37x/stm32_isr.c b/lib/chibios/os/hal/ports/STM32/STM32F37x/stm32_isr.c new file mode 100644 index 000000000..3336d030b --- /dev/null +++ b/lib/chibios/os/hal/ports/STM32/STM32F37x/stm32_isr.c | |||
@@ -0,0 +1,255 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file STM32F3xx/stm32_isr.c | ||
19 | * @brief STM32F3xx ISR handler code. | ||
20 | * | ||
21 | * @addtogroup STM32F3xx_ISR | ||
22 | * @{ | ||
23 | */ | ||
24 | |||
25 | #include "hal.h" | ||
26 | |||
27 | /*===========================================================================*/ | ||
28 | /* Driver local definitions. */ | ||
29 | /*===========================================================================*/ | ||
30 | |||
31 | /*===========================================================================*/ | ||
32 | /* Driver exported variables. */ | ||
33 | /*===========================================================================*/ | ||
34 | |||
35 | /*===========================================================================*/ | ||
36 | /* Driver local variables. */ | ||
37 | /*===========================================================================*/ | ||
38 | |||
39 | /*===========================================================================*/ | ||
40 | /* Driver local functions. */ | ||
41 | /*===========================================================================*/ | ||
42 | |||
43 | #define exti_serve_irq(pr, channel) { \ | ||
44 | \ | ||
45 | if ((pr) & (1U << (channel))) { \ | ||
46 | _pal_isr_code(channel); \ | ||
47 | } \ | ||
48 | } | ||
49 | |||
50 | /*===========================================================================*/ | ||
51 | /* Driver interrupt handlers. */ | ||
52 | /*===========================================================================*/ | ||
53 | |||
54 | #if (HAL_USE_PAL && (PAL_USE_WAIT || PAL_USE_CALLBACKS)) || defined(__DOXYGEN__) | ||
55 | #if !defined(STM32_DISABLE_EXTI0_HANDLER) | ||
56 | /** | ||
57 | * @brief EXTI[0] interrupt handler. | ||
58 | * | ||
59 | * @isr | ||
60 | */ | ||
61 | OSAL_IRQ_HANDLER(Vector58) { | ||
62 | uint32_t pr; | ||
63 | |||
64 | OSAL_IRQ_PROLOGUE(); | ||
65 | |||
66 | pr = EXTI->PR; | ||
67 | pr &= EXTI->IMR & (1U << 0); | ||
68 | EXTI->PR = pr; | ||
69 | |||
70 | exti_serve_irq(pr, 0); | ||
71 | |||
72 | OSAL_IRQ_EPILOGUE(); | ||
73 | } | ||
74 | #endif | ||
75 | |||
76 | #if !defined(STM32_DISABLE_EXTI1_HANDLER) | ||
77 | /** | ||
78 | * @brief EXTI[1] interrupt handler. | ||
79 | * | ||
80 | * @isr | ||
81 | */ | ||
82 | OSAL_IRQ_HANDLER(Vector5C) { | ||
83 | uint32_t pr; | ||
84 | |||
85 | OSAL_IRQ_PROLOGUE(); | ||
86 | |||
87 | pr = EXTI->PR; | ||
88 | pr &= EXTI->IMR & (1U << 1); | ||
89 | EXTI->PR = pr; | ||
90 | |||
91 | exti_serve_irq(pr, 1); | ||
92 | |||
93 | OSAL_IRQ_EPILOGUE(); | ||
94 | } | ||
95 | #endif | ||
96 | |||
97 | #if !defined(STM32_DISABLE_EXTI2_HANDLER) | ||
98 | /** | ||
99 | * @brief EXTI[2] interrupt handler. | ||
100 | * | ||
101 | * @isr | ||
102 | */ | ||
103 | OSAL_IRQ_HANDLER(Vector60) { | ||
104 | uint32_t pr; | ||
105 | |||
106 | OSAL_IRQ_PROLOGUE(); | ||
107 | |||
108 | pr = EXTI->PR; | ||
109 | pr &= EXTI->IMR & (1U << 2); | ||
110 | EXTI->PR = pr; | ||
111 | |||
112 | exti_serve_irq(pr, 2); | ||
113 | |||
114 | OSAL_IRQ_EPILOGUE(); | ||
115 | } | ||
116 | #endif | ||
117 | |||
118 | #if !defined(STM32_DISABLE_EXTI3_HANDLER) | ||
119 | /** | ||
120 | * @brief EXTI[3] interrupt handler. | ||
121 | * | ||
122 | * @isr | ||
123 | */ | ||
124 | OSAL_IRQ_HANDLER(Vector64) { | ||
125 | uint32_t pr; | ||
126 | |||
127 | OSAL_IRQ_PROLOGUE(); | ||
128 | |||
129 | pr = EXTI->PR; | ||
130 | pr &= EXTI->IMR & (1U << 3); | ||
131 | EXTI->PR = pr; | ||
132 | |||
133 | exti_serve_irq(pr, 3); | ||
134 | |||
135 | OSAL_IRQ_EPILOGUE(); | ||
136 | } | ||
137 | #endif | ||
138 | |||
139 | #if !defined(STM32_DISABLE_EXTI4_HANDLER) | ||
140 | /** | ||
141 | * @brief EXTI[4] interrupt handler. | ||
142 | * | ||
143 | * @isr | ||
144 | */ | ||
145 | OSAL_IRQ_HANDLER(Vector68) { | ||
146 | uint32_t pr; | ||
147 | |||
148 | OSAL_IRQ_PROLOGUE(); | ||
149 | |||
150 | pr = EXTI->PR; | ||
151 | pr &= EXTI->IMR & (1U << 4); | ||
152 | EXTI->PR = pr; | ||
153 | |||
154 | exti_serve_irq(pr, 4); | ||
155 | |||
156 | OSAL_IRQ_EPILOGUE(); | ||
157 | } | ||
158 | #endif | ||
159 | |||
160 | #if !defined(STM32_DISABLE_EXTI5_9_HANDLER) | ||
161 | /** | ||
162 | * @brief EXTI[5]...EXTI[9] interrupt handler. | ||
163 | * | ||
164 | * @isr | ||
165 | */ | ||
166 | OSAL_IRQ_HANDLER(Vector9C) { | ||
167 | uint32_t pr; | ||
168 | |||
169 | OSAL_IRQ_PROLOGUE(); | ||
170 | |||
171 | pr = EXTI->PR; | ||
172 | pr &= EXTI->IMR & ((1U << 5) | (1U << 6) | (1U << 7) | (1U << 8) | | ||
173 | (1U << 9)); | ||
174 | EXTI->PR = pr; | ||
175 | |||
176 | exti_serve_irq(pr, 5); | ||
177 | exti_serve_irq(pr, 6); | ||
178 | exti_serve_irq(pr, 7); | ||
179 | exti_serve_irq(pr, 8); | ||
180 | exti_serve_irq(pr, 9); | ||
181 | |||
182 | OSAL_IRQ_EPILOGUE(); | ||
183 | } | ||
184 | #endif | ||
185 | |||
186 | #if !defined(STM32_DISABLE_EXTI10_15_HANDLER) | ||
187 | /** | ||
188 | * @brief EXTI[10]...EXTI[15] interrupt handler. | ||
189 | * | ||
190 | * @isr | ||
191 | */ | ||
192 | OSAL_IRQ_HANDLER(VectorE0) { | ||
193 | uint32_t pr; | ||
194 | |||
195 | OSAL_IRQ_PROLOGUE(); | ||
196 | |||
197 | pr = EXTI->PR; | ||
198 | pr &= EXTI->IMR & ((1U << 10) | (1U << 11) | (1U << 12) | (1U << 13) | | ||
199 | (1U << 14) | (1U << 15)); | ||
200 | EXTI->PR = pr; | ||
201 | |||
202 | exti_serve_irq(pr, 10); | ||
203 | exti_serve_irq(pr, 11); | ||
204 | exti_serve_irq(pr, 12); | ||
205 | exti_serve_irq(pr, 13); | ||
206 | exti_serve_irq(pr, 14); | ||
207 | exti_serve_irq(pr, 15); | ||
208 | |||
209 | OSAL_IRQ_EPILOGUE(); | ||
210 | } | ||
211 | #endif | ||
212 | |||
213 | #endif /* HAL_USE_PAL */ | ||
214 | |||
215 | /*===========================================================================*/ | ||
216 | /* Driver exported functions. */ | ||
217 | /*===========================================================================*/ | ||
218 | |||
219 | /** | ||
220 | * @brief Enables IRQ sources. | ||
221 | * | ||
222 | * @notapi | ||
223 | */ | ||
224 | void irqInit(void) { | ||
225 | |||
226 | #if HAL_USE_PAL | ||
227 | nvicEnableVector(EXTI0_IRQn, STM32_IRQ_EXTI0_PRIORITY); | ||
228 | nvicEnableVector(EXTI1_IRQn, STM32_IRQ_EXTI1_PRIORITY); | ||
229 | nvicEnableVector(EXTI2_TSC_IRQn, STM32_IRQ_EXTI2_PRIORITY); | ||
230 | nvicEnableVector(EXTI3_IRQn, STM32_IRQ_EXTI3_PRIORITY); | ||
231 | nvicEnableVector(EXTI4_IRQn, STM32_IRQ_EXTI4_PRIORITY); | ||
232 | nvicEnableVector(EXTI9_5_IRQn, STM32_IRQ_EXTI5_9_PRIORITY); | ||
233 | nvicEnableVector(EXTI15_10_IRQn, STM32_IRQ_EXTI10_15_PRIORITY); | ||
234 | #endif | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * @brief Disables IRQ sources. | ||
239 | * | ||
240 | * @notapi | ||
241 | */ | ||
242 | void irqDeinit(void) { | ||
243 | |||
244 | #if HAL_USE_PAL | ||
245 | nvicDisableVector(EXTI0_IRQn); | ||
246 | nvicDisableVector(EXTI1_IRQn); | ||
247 | nvicDisableVector(EXTI2_TSC_IRQn); | ||
248 | nvicDisableVector(EXTI3_IRQn); | ||
249 | nvicDisableVector(EXTI4_IRQn); | ||
250 | nvicDisableVector(EXTI9_5_IRQn); | ||
251 | nvicDisableVector(EXTI15_10_IRQn); | ||
252 | #endif | ||
253 | } | ||
254 | |||
255 | /** @} */ | ||