|
10 | 10 | #include <stm32_ll_rcc.h> |
11 | 11 | #include "can_stm32fd.h" |
12 | 12 | #include <pinmux/pinmux_stm32.h> |
| 13 | +#include <shared_irq.h> |
13 | 14 |
|
14 | 15 | #include <logging/log.h> |
15 | 16 | LOG_MODULE_DECLARE(can_driver, CONFIG_CAN_LOG_LEVEL); |
@@ -208,18 +209,22 @@ static const struct can_driver_api can_api_funcs = { |
208 | 209 | #endif |
209 | 210 | }; |
210 | 211 |
|
| 212 | +/* |
| 213 | + * If a shared-irq with matching name exists and has status okay use the |
| 214 | + * shared-irq driver, otherwise, connect to normal IRQ. |
| 215 | + */ |
211 | 216 | #define CAN_STM32FD_IRQ_CFG_FUNCTION(inst) \ |
212 | 217 | static void config_can_##inst##_irq(void) \ |
213 | 218 | { \ |
214 | 219 | LOG_DBG("Enable CAN" #inst " IRQ"); \ |
215 | | - IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, line_0, irq), \ |
216 | | - DT_INST_IRQ_BY_NAME(inst, line_0, priority), \ |
217 | | - can_stm32fd_line_0_isr, DEVICE_DT_INST_GET(inst), 0); \ |
218 | | - irq_enable(DT_INST_IRQ_BY_NAME(inst, line_0, irq)); \ |
219 | | - IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, line_1, irq), \ |
220 | | - DT_INST_IRQ_BY_NAME(inst, line_1, priority), \ |
221 | | - can_stm32fd_line_1_isr, DEVICE_DT_INST_GET(inst), 0); \ |
222 | | - irq_enable(DT_INST_IRQ_BY_NAME(inst, line_1, irq)); \ |
| 220 | + SHARED_IRQ_CONNECT_IRQ_BY_NAME_COND(DT_DRV_INST(inst), line_0, \ |
| 221 | + can_stm32fd_line_0_isr, \ |
| 222 | + DEVICE_DT_INST_GET(inst), 0); \ |
| 223 | + SHARED_IRQ_CONNECT_IRQ_BY_NAME_COND(DT_DRV_INST(inst), line_1, \ |
| 224 | + can_stm32fd_line_1_isr, \ |
| 225 | + DEVICE_DT_INST_GET(inst), 0); \ |
| 226 | + SHARED_IRQ_ENABLE_BY_NAME_COND(DT_DRV_INST(inst), line_0); \ |
| 227 | + SHARED_IRQ_ENABLE_BY_NAME_COND(DT_DRV_INST(inst), line_1); \ |
223 | 228 | } |
224 | 229 |
|
225 | 230 | #ifdef CONFIG_CAN_FD_MODE |
|
0 commit comments