diff options
Diffstat (limited to '')
-rw-r--r-- | bsps/microblaze/shared/dev/serial/uartlite.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/bsps/microblaze/shared/dev/serial/uartlite.c b/bsps/microblaze/shared/dev/serial/uartlite.c index 7387e22635..611c339371 100644 --- a/bsps/microblaze/shared/dev/serial/uartlite.c +++ b/bsps/microblaze/shared/dev/serial/uartlite.c @@ -35,6 +35,7 @@ #include <bsp/irq.h> #include <dev/serial/uartlite.h> +#include <bspopts.h> #ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS static void microblaze_uart_interrupt( void *arg ) @@ -47,8 +48,11 @@ static void microblaze_uart_interrupt( void *arg ) rtems_termios_enqueue_raw_characters( tty, &c, 1 ); } - while ( ctx->transmitting && !XUartLite_IsTransmitEmpty( ctx ) ) { - rtems_termios_dequeue_characters( tty, 1 ); + if ( ctx->transmitting && XUartLite_IsTransmitEmpty( ctx->address ) ) { + size_t sent = ctx->tx_queued; + ctx->transmitting = false; + ctx->tx_queued = 0; + rtems_termios_dequeue_characters( tty, sent ); } } #endif @@ -69,8 +73,9 @@ static bool uart_first_open( #ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS XUartLite_EnableIntr( ctx->address ); + sc = rtems_interrupt_handler_install( - 1, + ctx->irq, "UART", RTEMS_INTERRUPT_SHARED, microblaze_uart_interrupt, @@ -79,6 +84,8 @@ static bool uart_first_open( if ( sc != RTEMS_SUCCESSFUL ) { return false; } + + ctx->tty = tty; #endif return true; @@ -118,10 +125,17 @@ static void uart_write( #ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS if ( n > 0 ) { + size_t remaining = n; + const char *p = &s[0]; + + while (!XUartLite_IsTransmitFull( ctx->address ) && remaining > 0) { + XUartLite_SendByte( ctx->address, *p ); + p++; + remaining--; + } + ctx->transmitting = true; - XUartLite_SendByte( ctx->address, s[0] ); - } else { - ctx->transmitting = false; + ctx->tx_queued = n - remaining; } #else size_t i = 0; |