forked from Imagelibrary/rtems
bsps/microblaze: Fix UART transmit interrupt
This commit is contained in:
committed by
Joel Sherrill
parent
c627a13239
commit
fe6a5d0f7a
@@ -51,7 +51,9 @@ typedef struct {
|
|||||||
uint32_t initial_baud;
|
uint32_t initial_baud;
|
||||||
uint32_t enabled;
|
uint32_t enabled;
|
||||||
#ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS
|
#ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS
|
||||||
|
struct rtems_termios_tty *tty;
|
||||||
bool transmitting;
|
bool transmitting;
|
||||||
|
size_t tx_queued;
|
||||||
uint32_t irq;
|
uint32_t irq;
|
||||||
#endif
|
#endif
|
||||||
} uart_lite_context;
|
} uart_lite_context;
|
||||||
|
|||||||
@@ -48,8 +48,11 @@ static void microblaze_uart_interrupt( void *arg )
|
|||||||
rtems_termios_enqueue_raw_characters( tty, &c, 1 );
|
rtems_termios_enqueue_raw_characters( tty, &c, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( ctx->transmitting && !XUartLite_IsTransmitEmpty( ctx->address ) ) {
|
if ( ctx->transmitting && XUartLite_IsTransmitEmpty( ctx->address ) ) {
|
||||||
rtems_termios_dequeue_characters( tty, 1 );
|
size_t sent = ctx->tx_queued;
|
||||||
|
ctx->transmitting = false;
|
||||||
|
ctx->tx_queued = 0;
|
||||||
|
rtems_termios_dequeue_characters( tty, sent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -81,6 +84,8 @@ static bool uart_first_open(
|
|||||||
if ( sc != RTEMS_SUCCESSFUL ) {
|
if ( sc != RTEMS_SUCCESSFUL ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->tty = tty;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -120,10 +125,17 @@ static void uart_write(
|
|||||||
|
|
||||||
#ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS
|
#ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS
|
||||||
if ( n > 0 ) {
|
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;
|
ctx->transmitting = true;
|
||||||
XUartLite_SendByte( ctx->address, s[0] );
|
ctx->tx_queued = n - remaining;
|
||||||
} else {
|
|
||||||
ctx->transmitting = false;
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user