forked from Imagelibrary/rtems
LEON3: added TX-wait-complete and CR on NL support for UART
Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
This commit is contained in:
committed by
Gedare Bloom
parent
605b4b649d
commit
5d48037f83
@@ -50,8 +50,11 @@ int syscon_uart_index __attribute__((weak)) = 0;
|
|||||||
|
|
||||||
extern void apbuart_outbyte_polled(
|
extern void apbuart_outbyte_polled(
|
||||||
ambapp_apb_uart *regs,
|
ambapp_apb_uart *regs,
|
||||||
char ch
|
unsigned char ch,
|
||||||
);
|
int do_cr_on_newline,
|
||||||
|
int wait_sent
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/* body is in debugputs.c */
|
/* body is in debugputs.c */
|
||||||
|
|
||||||
@@ -156,7 +159,7 @@ ssize_t console_write_polled(int minor, const char *buf, size_t len)
|
|||||||
port = minor - 1;
|
port = minor - 1;
|
||||||
|
|
||||||
while (nwrite < len) {
|
while (nwrite < len) {
|
||||||
apbuart_outbyte_polled(apbuarts[port].regs, *buf++);
|
apbuart_outbyte_polled(apbuarts[port].regs, *buf++, 1, 0);
|
||||||
nwrite++;
|
nwrite++;
|
||||||
}
|
}
|
||||||
return nwrite;
|
return nwrite;
|
||||||
@@ -323,7 +326,7 @@ rtems_device_driver console_initialize(
|
|||||||
* On a MP system one should not open UARTs that other OS instances use.
|
* On a MP system one should not open UARTs that other OS instances use.
|
||||||
*/
|
*/
|
||||||
if (syscon_uart_index < uarts) {
|
if (syscon_uart_index < uarts) {
|
||||||
status = rtems_io_register_name( "/dev/console", major, 0 );
|
status = rtems_io_register_name("/dev/console", major, 0);
|
||||||
if (status != RTEMS_SUCCESSFUL)
|
if (status != RTEMS_SUCCESSFUL)
|
||||||
rtems_fatal_error_occurred(status);
|
rtems_fatal_error_occurred(status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,9 +89,12 @@ int bsp_debug_uart_init(void)
|
|||||||
*/
|
*/
|
||||||
void apbuart_outbyte_polled(
|
void apbuart_outbyte_polled(
|
||||||
ambapp_apb_uart *regs,
|
ambapp_apb_uart *regs,
|
||||||
unsigned char ch
|
unsigned char ch,
|
||||||
|
int do_cr_on_newline,
|
||||||
|
int wait_sent
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
send:
|
||||||
while ( (regs->status & LEON_REG_UART_STATUS_THE) == 0 ) {
|
while ( (regs->status & LEON_REG_UART_STATUS_THE) == 0 ) {
|
||||||
/* Lower bus utilization while waiting for UART */
|
/* Lower bus utilization while waiting for UART */
|
||||||
asm volatile ("nop"::); asm volatile ("nop"::);
|
asm volatile ("nop"::); asm volatile ("nop"::);
|
||||||
@@ -100,6 +103,17 @@ void apbuart_outbyte_polled(
|
|||||||
asm volatile ("nop"::); asm volatile ("nop"::);
|
asm volatile ("nop"::); asm volatile ("nop"::);
|
||||||
}
|
}
|
||||||
regs->data = (unsigned int) ch;
|
regs->data = (unsigned int) ch;
|
||||||
|
|
||||||
|
if ((ch == '\n') && do_cr_on_newline) {
|
||||||
|
ch = '\r';
|
||||||
|
goto send;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait until the character has been sent? */
|
||||||
|
if (wait_sent) {
|
||||||
|
while ((regs->status & LEON_REG_UART_STATUS_THE) == 0)
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -129,7 +143,7 @@ static void bsp_out_char(char c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
apbuart_outbyte_polled(dbg_uart, c);
|
apbuart_outbyte_polled(dbg_uart, c, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user