summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-10 15:01:49 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-17 12:58:33 +0200
commitaf69a8693b4f4a7f1ea41d2948c3550a46ae6e17 (patch)
tree70396dad726a196df3699357ab439390604c0502
parentgrlib: Remove NL -> CR in apbuart_outbyte_polled() (diff)
downloadrtems-af69a8693b4f4a7f1ea41d2948c3550a46ae6e17.tar.bz2
grlib: Add apbuart_outbyte_wait()
-rw-r--r--bsps/include/grlib/apbuart.h8
-rw-r--r--bsps/riscv/griscv/console/printk_support.c3
-rw-r--r--bsps/shared/grlib/uart/apbuart_cons.c2
-rw-r--r--bsps/shared/grlib/uart/apbuart_polled.c30
-rw-r--r--bsps/shared/grlib/uart/apbuart_termios.c2
-rw-r--r--bsps/sparc/leon3/console/printk_support.c3
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)