[PATCH 5/7] grlib: Add apbuart_outbyte_wait()
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Jun 10 13:24:04 UTC 2021
---
bsps/include/grlib/apbuart.h | 8 +++---
bsps/riscv/griscv/console/printk_support.c | 3 ++-
bsps/shared/grlib/uart/apbuart_cons.c | 2 +-
bsps/shared/grlib/uart/apbuart_polled.c | 30 +++++++++++-----------
bsps/shared/grlib/uart/apbuart_termios.c | 2 +-
bsps/sparc/leon3/console/printk_support.c | 3 ++-
6 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/bsps/include/grlib/apbuart.h b/bsps/include/grlib/apbuart.h
index 2ca67b20e8..68bcf1bffa 100644
--- a/bsps/include/grlib/apbuart.h
+++ b/bsps/include/grlib/apbuart.h
@@ -62,11 +62,9 @@ extern "C" {
#define APBUART_STATUS_TF 0x200
#define APBUART_STATUS_RF 0x400
-void apbuart_outbyte_polled(
- struct apbuart_regs *regs,
- unsigned char ch,
- int wait_sent
-);
+void apbuart_outbyte_wait(const struct apbuart_regs *regs);
+
+void apbuart_outbyte_polled(struct apbuart_regs *regs, unsigned char ch);
int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
diff --git a/bsps/riscv/griscv/console/printk_support.c b/bsps/riscv/griscv/console/printk_support.c
index 4c8acd55c5..f232203520 100644
--- a/bsps/riscv/griscv/console/printk_support.c
+++ b/bsps/riscv/griscv/console/printk_support.c
@@ -100,7 +100,8 @@ static void bsp_out_char(char c)
*/
}
- apbuart_outbyte_polled(grlib_debug_uart, c, 1);
+ apbuart_outbyte_polled(grlib_debug_uart, c);
+ apbuart_outbyte_wait(grlib_debug_uart);
}
/*
diff --git a/bsps/shared/grlib/uart/apbuart_cons.c b/bsps/shared/grlib/uart/apbuart_cons.c
index e7dda50565..a0a265ab31 100644
--- a/bsps/shared/grlib/uart/apbuart_cons.c
+++ b/bsps/shared/grlib/uart/apbuart_cons.c
@@ -641,7 +641,7 @@ static void write_polled(
int nwrite = 0;
while (nwrite < len) {
- apbuart_outbyte_polled(uart->regs, *buf++, 0);
+ apbuart_outbyte_polled(uart->regs, *buf++);
nwrite++;
}
}
diff --git a/bsps/shared/grlib/uart/apbuart_polled.c b/bsps/shared/grlib/uart/apbuart_polled.c
index 948e0966b8..8a596808b2 100644
--- a/bsps/shared/grlib/uart/apbuart_polled.c
+++ b/bsps/shared/grlib/uart/apbuart_polled.c
@@ -9,27 +9,27 @@
#include <grlib/apbuart.h>
-void apbuart_outbyte_polled(
- struct apbuart_regs *regs,
- unsigned char ch,
- int wait_sent
-)
+#include <rtems/score/cpuimpl.h>
+
+void apbuart_outbyte_wait(const struct apbuart_regs *regs)
{
while ( (regs->status & APBUART_STATUS_TE) == 0 ) {
/* Lower bus utilization while waiting for UART */
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
+ _CPU_Instruction_no_operation();
+ _CPU_Instruction_no_operation();
+ _CPU_Instruction_no_operation();
+ _CPU_Instruction_no_operation();
+ _CPU_Instruction_no_operation();
+ _CPU_Instruction_no_operation();
+ _CPU_Instruction_no_operation();
+ _CPU_Instruction_no_operation();
}
+}
+void apbuart_outbyte_polled(struct apbuart_regs *regs, char ch)
+{
+ apbuart_outbyte_wait(regs);
regs->data = (unsigned int) ch;
-
- /* Wait until the character has been sent? */
- if (wait_sent) {
- while ((regs->status & APBUART_STATUS_TE) == 0)
- ;
- }
}
int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
diff --git a/bsps/shared/grlib/uart/apbuart_termios.c b/bsps/shared/grlib/uart/apbuart_termios.c
index 5fb69902fe..9014a1c735 100644
--- a/bsps/shared/grlib/uart/apbuart_termios.c
+++ b/bsps/shared/grlib/uart/apbuart_termios.c
@@ -78,7 +78,7 @@ static void apbuart_write_polled(
size_t nwrite = 0;
while (nwrite < len) {
- apbuart_outbyte_polled(uart->regs, *buf++, 0);
+ apbuart_outbyte_polled(uart->regs, *buf++);
nwrite++;
}
}
diff --git a/bsps/sparc/leon3/console/printk_support.c b/bsps/sparc/leon3/console/printk_support.c
index aa05e1cf6f..f9cf0b7520 100644
--- a/bsps/sparc/leon3/console/printk_support.c
+++ b/bsps/sparc/leon3/console/printk_support.c
@@ -34,7 +34,8 @@ static void bsp_debug_uart_discard(char c)
static void bsp_debug_uart_output_char(char c)
{
- apbuart_outbyte_polled(leon3_debug_uart, c, 1);
+ apbuart_outbyte_polled(leon3_debug_uart, c);
+ apbuart_outbyte_wait(leon3_debug_uart);
}
static int bsp_debug_uart_poll_char(void)
--
2.26.2
More information about the devel
mailing list