bsps/microblaze: Fix UART transmit interrupt

This commit is contained in:
Maldonado, Sergio E. (GSFC-580.0)
2023-02-27 22:49:20 -06:00
committed by Joel Sherrill
parent c627a13239
commit fe6a5d0f7a
2 changed files with 19 additions and 5 deletions

View File

@@ -51,7 +51,9 @@ typedef struct {
uint32_t initial_baud;
uint32_t enabled;
#ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS
struct rtems_termios_tty *tty;
bool transmitting;
size_t tx_queued;
uint32_t irq;
#endif
} uart_lite_context;

View File

@@ -48,8 +48,11 @@ static void microblaze_uart_interrupt( void *arg )
rtems_termios_enqueue_raw_characters( tty, &c, 1 );
}
while ( ctx->transmitting && !XUartLite_IsTransmitEmpty( ctx->address ) ) {
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
@@ -81,6 +84,8 @@ static bool uart_first_open(
if ( sc != RTEMS_SUCCESSFUL ) {
return false;
}
ctx->tty = tty;
#endif
return true;
@@ -120,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;