Skip to content

Commit 98dd715

Browse files
committed
[U(S)ART] Add USART10 support
Available in some STM32H7 mcu Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 750710a commit 98dd715

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

cores/arduino/HardwareSerial.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@
9595
#endif
9696

9797
#if defined(HAVE_HWSERIAL10)
98-
HardwareSerial Serial10(UART10);
98+
#if defined(USART10)
99+
HardwareSerial Serial10(USART10);
100+
#else
101+
HardwareSerial Serial10(UART10);
102+
#endif
99103
void serialEvent10() __attribute__((weak));
100104
#endif
101105

@@ -218,16 +222,22 @@ HardwareSerial::HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex)
218222
setTx(PIN_SERIAL8_TX);
219223
} else
220224
#endif
221-
#if defined(PIN_SERIAL9_TX) && defined(UART9)
225+
#if defined(PIN_SERIAL9_TX) && defined(UART9_BASE)
222226
if (peripheral == UART9) {
223227
#if defined(PIN_SERIAL9_RX)
224228
setRx(PIN_SERIAL9_RX);
225229
#endif
226230
setTx(PIN_SERIAL9_TX);
227231
} else
228232
#endif
229-
#if defined(PIN_SERIAL10_TX) && defined(UART10)
230-
if (peripheral == UART10) {
233+
#if defined(PIN_SERIAL10_TX) &&\
234+
(defined(USART10_BASE) || defined(UART10_BASE))
235+
#if defined(USART10_BASE)
236+
if (peripheral == USART10)
237+
#elif defined(UART10_BASE)
238+
if (peripheral == UART10)
239+
#endif
240+
{
231241
#if defined(PIN_SERIAL10_RX)
232242
setRx(PIN_SERIAL10_RX);
233243
#endif

cores/arduino/WSerial.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ WEAK void serialEventRun(void)
4848
}
4949
#endif
5050
#if defined(HAVE_HWSERIAL10)
51-
if (serialEventl10 && Serial10.available()) {
51+
if (serialEvent10 && Serial10.available()) {
5252
serialEvent10();
5353
}
5454
#endif

cores/arduino/WSerial.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
#endif
165165
#endif
166166
#if defined(ENABLE_HWSERIAL10)
167-
#if defined(UART10_BASE)
167+
#if defined(USART10_BASE) || defined(UART10_BASE)
168168
#define HAVE_HWSERIAL10
169169
#endif
170170
#endif

keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ USART7 LITERAL1
796796
UART8 LITERAL1
797797
UART9 LITERAL1
798798
UART10 LITERAL1
799+
USART10 LITERAL1
799800
LPUART1 LITERAL1
800801

801802
# Port

libraries/SrcWrapper/src/stm32/uart.c

+30-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ typedef enum {
8787
#if defined(UART9_BASE)
8888
UART9_INDEX,
8989
#endif
90-
#if defined(UART10_BASE)
90+
#if defined(UART10_BASE) || defined(USART10_BASE)
9191
UART10_INDEX,
9292
#endif
9393
#if defined(LPUART1_BASE)
@@ -284,6 +284,15 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
284284
obj->irq = UART10_IRQn;
285285
}
286286
#endif
287+
#if defined(USART10_BASE)
288+
else if (obj->uart == USART10) {
289+
__HAL_RCC_USART10_FORCE_RESET();
290+
__HAL_RCC_USART10_RELEASE_RESET();
291+
__HAL_RCC_USART10_CLK_ENABLE();
292+
obj->index = UART10_INDEX;
293+
obj->irq = USART10_IRQn;
294+
}
295+
#endif
287296

288297
#if defined(STM32F091xC) || defined (STM32F098xx)
289298
/* Enable SYSCFG Clock */
@@ -487,6 +496,13 @@ void uart_deinit(serial_t *obj)
487496
__HAL_RCC_UART10_RELEASE_RESET();
488497
__HAL_RCC_UART10_CLK_DISABLE();
489498
break;
499+
#endif
500+
#if defined(USART10_BASE)
501+
case UART10_INDEX:
502+
__HAL_RCC_USART10_FORCE_RESET();
503+
__HAL_RCC_USART10_RELEASE_RESET();
504+
__HAL_RCC_USART10_CLK_DISABLE();
505+
break;
490506
#endif
491507
}
492508

@@ -1062,6 +1078,19 @@ void UART10_IRQHandler(void)
10621078
}
10631079
#endif
10641080

1081+
/**
1082+
* @brief USART 10 IRQ handler
1083+
* @param None
1084+
* @retval None
1085+
*/
1086+
#if defined(USART10_BASE)
1087+
void USART10_IRQHandler(void)
1088+
{
1089+
HAL_NVIC_ClearPendingIRQ(USART10_IRQn);
1090+
HAL_UART_IRQHandler(uart_handlers[UART10_INDEX]);
1091+
}
1092+
#endif
1093+
10651094
/**
10661095
* @brief HAL UART Call Back
10671096
* @param UART handler

0 commit comments

Comments
 (0)