[PATCH 1/1] bsps/stm32f4: Fix usart_write_polled()

Duc Doan dtbpkmte at gmail.com
Wed Jul 27 10:02:55 UTC 2022


---
 bsps/arm/stm32f4/console/console-config.c | 4 +++-
 bsps/arm/stm32f4/console/usart.c          | 6 ++++++
 bsps/arm/stm32f4/include/bsp/usart.h      | 3 +++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/bsps/arm/stm32f4/console/console-config.c b/bsps/arm/stm32f4/console/console-config.c
index 13557ed186..43c82144b0 100644
--- a/bsps/arm/stm32f4/console/console-config.c
+++ b/bsps/arm/stm32f4/console/console-config.c
@@ -83,7 +83,9 @@ console_tbl Console_Configuration_Ports [] = {
     },
   #endif
 };
-
+#ifdef __rtems__
+console_tbl *stm32f4_default_console_tbl_ptr = &Console_Configuration_Ports[0];
+#endif /* __rtems__ */
 #define PORT_COUNT \
   (sizeof(Console_Configuration_Ports) \
     / sizeof(Console_Configuration_Ports [0]))
diff --git a/bsps/arm/stm32f4/console/usart.c b/bsps/arm/stm32f4/console/usart.c
index 37566ef9d7..706ab9d9f0 100644
--- a/bsps/arm/stm32f4/console/usart.c
+++ b/bsps/arm/stm32f4/console/usart.c
@@ -165,8 +165,14 @@ static int usart_read_polled(int minor)
 
 static void usart_write_polled(int minor, char c)
 {
+#ifndef __rtems__
   const console_tbl *ct = Console_Port_Tbl [minor];
   volatile stm32f4_usart *usart = usart_get_regs(ct);
+#endif /* __rtems__ */
+#ifdef __rtems__
+  const console_tbl *ct = stm32f4_default_console_tbl_ptr;
+  volatile stm32f4_usart *usart = usart_get_regs(ct);
+#endif /* __rtems__ */
 
   while ((usart->sr & STM32F4_USART_SR_TXE) == 0) {
     /* Wait */
diff --git a/bsps/arm/stm32f4/include/bsp/usart.h b/bsps/arm/stm32f4/include/bsp/usart.h
index 3c9fd3fd96..3ac8fce583 100644
--- a/bsps/arm/stm32f4/include/bsp/usart.h
+++ b/bsps/arm/stm32f4/include/bsp/usart.h
@@ -29,6 +29,9 @@ extern "C" {
 #endif /* __cplusplus */
 
 extern const console_fns stm32f4_usart_fns;
+#ifdef __rtems__
+extern console_tbl *stm32f4_default_console_tbl_ptr;
+#endif /* __rtems__ */
 
 /** @} */
 
-- 
2.37.1



More information about the devel mailing list