aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_usart3.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_usart3.inc')
-rw-r--r--lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_usart3.inc121
1 files changed, 121 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_usart3.inc b/lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_usart3.inc
new file mode 100644
index 000000000..ff5dbda86
--- /dev/null
+++ b/lib/chibios/os/hal/ports/STM32/LLD/USARTv2/stm32_usart3.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_usart3.inc
19 * @brief Shared USART3 handler.
20 *
21 * @addtogroup STM32_USART3_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_USART3)
35#error "STM32_HAS_USART3 not defined in registry"
36#endif
37
38#if STM32_HAS_USART3
39
40/* Priority settings checks.*/
41#if !defined(STM32_IRQ_USART3_PRIORITY)
42#error "STM32_IRQ_USART3_PRIORITY not defined in mcuconf.h"
43#endif
44
45#if !OSAL_IRQ_IS_VALID_PRIORITY(STM32_IRQ_USART3_PRIORITY)
46#error "Invalid IRQ priority assigned to STM32_IRQ_USART3_PRIORITY"
47#endif
48
49#endif /* STM32_HAS_USART3 */
50
51/* Other checks.*/
52#if (HAL_USE_SERIAL && STM32_SERIAL_USE_USART3) && \
53 (HAL_USE_UART && STM32_UART_USE_USART3)
54#error "USART3 used by multiple drivers"
55#endif
56
57#if (HAL_USE_SERIAL && STM32_SERIAL_USE_USART3) || \
58 (HAL_USE_UART && STM32_UART_USE_USART3)
59#define STM32_USART3_IS_USED TRUE
60#else
61#define STM32_USART3_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
76static inline void usart3_irq_init(void) {
77#if STM32_USART3_IS_USED
78 nvicEnableVector(STM32_USART3_NUMBER, STM32_IRQ_USART3_PRIORITY);
79#endif
80}
81
82static inline void usart3_irq_deinit(void) {
83#if STM32_USART3_IS_USED
84 nvicDisableVector(STM32_USART3_NUMBER);
85#endif
86}
87
88/*===========================================================================*/
89/* Driver interrupt handlers. */
90/*===========================================================================*/
91
92#if STM32_USART3_IS_USED || defined(__DOXYGEN__)
93/**
94 * @brief USART3 interrupt handler.
95 *
96 * @isr
97 */
98OSAL_IRQ_HANDLER(STM32_USART3_HANDLER) {
99
100 OSAL_IRQ_PROLOGUE();
101
102#if HAL_USE_SERIAL
103#if STM32_SERIAL_USE_USART3
104 sd_lld_serve_interrupt(&SD3);
105#endif
106#endif
107#if HAL_USE_UART
108#if STM32_UART_USE_USART3
109 uart_lld_serve_interrupt(&UARTD3);
110#endif
111#endif
112
113 OSAL_IRQ_EPILOGUE();
114}
115#endif
116
117/*===========================================================================*/
118/* Driver exported functions. */
119/*===========================================================================*/
120
121/** @} */