Skip to content

Commit 8892f71

Browse files
committed
stmhal: Exclude code for UARTs that don't exist in hardware.
1 parent 73f1a49 commit 8892f71

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

stmhal/uart.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ STATIC bool uart_init2(pyb_uart_obj_t *uart_obj) {
153153
__USART2_CLK_ENABLE();
154154
break;
155155

156+
#if defined(USART3)
156157
// USART3 is on PB10/PB11 (CK,CTS,RTS on PB12,PB13,PB14), PC10/PC11 (CK on PC12), PD8/PD9 (CK on PD10)
157158
case PYB_UART_3:
158159
UARTx = USART3;
@@ -175,7 +176,9 @@ STATIC bool uart_init2(pyb_uart_obj_t *uart_obj) {
175176
#endif
176177
__USART3_CLK_ENABLE();
177178
break;
179+
#endif
178180

181+
#if defined(UART4)
179182
// UART4 is on PA0/PA1, PC10/PC11
180183
case PYB_UART_4:
181184
UARTx = UART4;
@@ -187,6 +190,7 @@ STATIC bool uart_init2(pyb_uart_obj_t *uart_obj) {
187190

188191
__UART4_CLK_ENABLE();
189192
break;
193+
#endif
190194

191195
// USART6 is on PC6/PC7 (CK on PC8)
192196
case PYB_UART_6:
@@ -570,16 +574,20 @@ STATIC mp_obj_t pyb_uart_deinit(mp_obj_t self_in) {
570574
__USART2_FORCE_RESET();
571575
__USART2_RELEASE_RESET();
572576
__USART2_CLK_DISABLE();
577+
#if defined(USART3)
573578
} else if (uart->Instance == USART3) {
574579
HAL_NVIC_DisableIRQ(USART3_IRQn);
575580
__USART3_FORCE_RESET();
576581
__USART3_RELEASE_RESET();
577582
__USART3_CLK_DISABLE();
583+
#endif
584+
#if defined(UART4)
578585
} else if (uart->Instance == UART4) {
579586
HAL_NVIC_DisableIRQ(UART4_IRQn);
580587
__UART4_FORCE_RESET();
581588
__UART4_RELEASE_RESET();
582589
__UART4_CLK_DISABLE();
590+
#endif
583591
} else if (uart->Instance == USART6) {
584592
HAL_NVIC_DisableIRQ(USART6_IRQn);
585593
__USART6_FORCE_RESET();

0 commit comments

Comments
 (0)