diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_uart5.inc')
-rw-r--r-- | lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_uart5.inc | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_uart5.inc b/lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_uart5.inc new file mode 100644 index 000000000..b382d849d --- /dev/null +++ b/lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_uart5.inc | |||
@@ -0,0 +1,121 @@ | |||
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 USARTv2/stm32_uart5.inc | ||
19 | * @brief Shared UART5 handler. | ||
20 | * | ||
21 | * @addtogroup STM32_UART5_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_UART5) | ||
35 | #error "STM32_HAS_UART5 not defined in registry" | ||
36 | #endif | ||
37 | |||
38 | #if STM32_HAS_UART5 | ||
39 | |||
40 | /* Priority settings checks.*/ | ||
41 | #if !defined(STM32_IRQ_UART5_PRIORITY) | ||
42 | #error "STM32_IRQ_UART5_PRIORITY not defined in mcuconf.h" | ||
43 | #endif | ||
44 | |||
45 | #if !OSAL_IRQ_IS_VALID_PRIORITY(STM32_IRQ_UART5_PRIORITY) | ||
46 | #error "Invalid IRQ priority assigned to STM32_IRQ_UART5_PRIORITY" | ||
47 | #endif | ||
48 | |||
49 | #endif /* STM32_HAS_UART5 */ | ||
50 | |||
51 | /* Other checks.*/ | ||
52 | #if (HAL_USE_SERIAL && STM32_SERIAL_USE_UART5) && \ | ||
53 | (HAL_USE_UART && STM32_UART_USE_UART5) | ||
54 | #error "UART5 used by multiple drivers" | ||
55 | #endif | ||
56 | |||
57 | #if (HAL_USE_SERIAL && STM32_SERIAL_USE_UART5) || \ | ||
58 | (HAL_USE_UART && STM32_UART_USE_UART5) | ||
59 | #define STM32_UART5_IS_USED TRUE | ||
60 | #else | ||
61 | #define STM32_UART5_IS_USED FALSE | ||
62 | #endif | ||
63 | |||
64 | /*===========================================================================*/ | ||
65 | /* Driver exported variables. */ | ||
66 | /*===========================================================================*/ | ||
67 | |||
68 | /*===========================================================================*/ | ||
69 | /* Driver local variables. */ | ||
70 | /*===========================================================================*/ | ||
71 | |||
72 | /*===========================================================================*/ | ||
73 | /* Driver local functions. */ | ||
74 | /*===========================================================================*/ | ||
75 | |||
76 | static inline void uart5_irq_init(void) { | ||
77 | #if STM32_UART5_IS_USED | ||
78 | nvicEnableVector(STM32_UART5_NUMBER, STM32_IRQ_UART5_PRIORITY); | ||
79 | #endif | ||
80 | } | ||
81 | |||
82 | static inline void uart5_irq_deinit(void) { | ||
83 | #if STM32_UART5_IS_USED | ||
84 | nvicDisableVector(STM32_UART5_NUMBER); | ||
85 | #endif | ||
86 | } | ||
87 | |||
88 | /*===========================================================================*/ | ||
89 | /* Driver interrupt handlers. */ | ||
90 | /*===========================================================================*/ | ||
91 | |||
92 | #if STM32_UART5_IS_USED || defined(__DOXYGEN__) | ||
93 | /** | ||
94 | * @brief UART5 interrupt handler. | ||
95 | * | ||
96 | * @isr | ||
97 | */ | ||
98 | OSAL_IRQ_HANDLER(STM32_UART5_HANDLER) { | ||
99 | |||
100 | OSAL_IRQ_PROLOGUE(); | ||
101 | |||
102 | #if HAL_USE_SERIAL | ||
103 | #if STM32_SERIAL_USE_UART5 | ||
104 | sd_lld_serve_interrupt(&SD5); | ||
105 | #endif | ||
106 | #endif | ||
107 | #if HAL_USE_UART | ||
108 | #if STM32_UART_USE_UART5 | ||
109 | uart_lld_serve_interrupt(&UARTD5); | ||
110 | #endif | ||
111 | #endif | ||
112 | |||
113 | OSAL_IRQ_EPILOGUE(); | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | /*===========================================================================*/ | ||
118 | /* Driver exported functions. */ | ||
119 | /*===========================================================================*/ | ||
120 | |||
121 | /** @} */ | ||