diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/STM32/LLD/FDCANv1/stm32_fdcan1.inc')
-rw-r--r-- | lib/chibios/os/hal/ports/STM32/LLD/FDCANv1/stm32_fdcan1.inc | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/STM32/LLD/FDCANv1/stm32_fdcan1.inc b/lib/chibios/os/hal/ports/STM32/LLD/FDCANv1/stm32_fdcan1.inc new file mode 100644 index 000000000..4f6fd3754 --- /dev/null +++ b/lib/chibios/os/hal/ports/STM32/LLD/FDCANv1/stm32_fdcan1.inc | |||
@@ -0,0 +1,106 @@ | |||
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 FDCANv1/stm32_fdcan1.inc | ||
19 | * @brief Shared FDCAN1 handler. | ||
20 | * | ||
21 | * @addtogroup STM32_FDCAN1_HANDLER | ||
22 | * @{ | ||
23 | */ | ||
24 | |||
25 | /*===========================================================================*/ | ||
26 | /* Driver local definitions. */ | ||
27 | /*===========================================================================*/ | ||
28 | |||
29 | /*===========================================================================*/ | ||
30 | /* Derived constants and error checks. */ | ||
31 | /*===========================================================================*/ | ||
32 | |||
33 | /* Registry checks for robustness.*/ | ||
34 | #if !defined(STM32_HAS_FDCAN1) | ||
35 | #error "STM32_HAS_FDCAN1 not defined in registry" | ||
36 | #endif | ||
37 | |||
38 | #if STM32_HAS_FDCAN1 | ||
39 | |||
40 | /* Priority settings checks.*/ | ||
41 | #if !defined(STM32_IRQ_FDCAN1_PRIORITY) | ||
42 | #error "STM32_IRQ_FDCAN1_PRIORITY not defined in mcuconf.h" | ||
43 | #endif | ||
44 | |||
45 | #if !OSAL_IRQ_IS_VALID_PRIORITY(STM32_IRQ_FDCAN1_PRIORITY) | ||
46 | #error "Invalid IRQ priority assigned to STM32_IRQ_FDCAN1_PRIORITY" | ||
47 | #endif | ||
48 | |||
49 | #endif /* STM32_HAS_FDCAN1 */ | ||
50 | |||
51 | /* Other checks.*/ | ||
52 | #if HAL_USE_CAN && STM32_CAN_USE_FDCAN1 | ||
53 | #define STM32_FDCAN1_IS_USED TRUE | ||
54 | #else | ||
55 | #define STM32_FDCAN1_IS_USED FALSE | ||
56 | #endif | ||
57 | |||
58 | /*===========================================================================*/ | ||
59 | /* Driver exported variables. */ | ||
60 | /*===========================================================================*/ | ||
61 | |||
62 | /*===========================================================================*/ | ||
63 | /* Driver local variables. */ | ||
64 | /*===========================================================================*/ | ||
65 | |||
66 | /*===========================================================================*/ | ||
67 | /* Driver local functions. */ | ||
68 | /*===========================================================================*/ | ||
69 | |||
70 | static inline void fdcan1_irq_init(void) { | ||
71 | #if STM32_FDCAN1_IS_USED | ||
72 | nvicEnableVector(STM32_FDCAN1_IT0_NUMBER, STM32_IRQ_FDCAN1_PRIORITY); | ||
73 | #endif | ||
74 | } | ||
75 | |||
76 | static inline void fdcan1_irq_deinit(void) { | ||
77 | #if STM32_FDCAN1_IS_USED | ||
78 | nvicDisableVector(STM32_FDCAN1_IT0_NUMBER); | ||
79 | #endif | ||
80 | } | ||
81 | |||
82 | /*===========================================================================*/ | ||
83 | /* Driver interrupt handlers. */ | ||
84 | /*===========================================================================*/ | ||
85 | |||
86 | #if STM32_FDCAN1_IS_USED|| defined(__DOXYGEN__) | ||
87 | /** | ||
88 | * @brief FDCAN1 interrupt handler. | ||
89 | * | ||
90 | * @isr | ||
91 | */ | ||
92 | OSAL_IRQ_HANDLER(STM32_FDCAN1_IT0_HANDLER) { | ||
93 | |||
94 | OSAL_IRQ_PROLOGUE(); | ||
95 | |||
96 | can_lld_serve_interrupt(&CAND1); | ||
97 | |||
98 | OSAL_IRQ_EPILOGUE(); | ||
99 | } | ||
100 | #endif | ||
101 | |||
102 | /*===========================================================================*/ | ||
103 | /* Driver exported functions. */ | ||
104 | /*===========================================================================*/ | ||
105 | |||
106 | /** @} */ | ||