summaryrefslogtreecommitdiffstats
path: root/bsps
diff options
context:
space:
mode:
authorAdrien Chardon <adrien@reflexaerospace.com>2024-01-24 18:01:52 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2024-02-01 07:54:57 +0100
commitb1fdf753387189afe720d3fa1ac13af5fb9943c2 (patch)
tree719afc329cf4993febd5f7fb8dff16ec0b2b89c8 /bsps
parentcpukit/libblock: Ignore sync status prior to purge (diff)
downloadrtems-b1fdf753387189afe720d3fa1ac13af5fb9943c2.tar.bz2
bsp/tms570: Fix console receive interrupts
`tms570_sci_interrupt_handler()` is called when an RX interrupt fires. It checks in the register `FLR`, the `RXRDY` bit (Receiver ready flag - indicate that the SCIRD contains new data). If it is set, it calls `tms570_sci_read_received_chars()`. `tms570_sci_read_received_chars()` checks the register `RD` against 0. If it is non zero, it returns 1 to indicate that one byte was read. In the old behavior, if it is zero, the function returns 0 to indicate that no data was read. The new behavior is to not silently drop 0x00 bytes. Ignoring 0x00 bytes is fine when working with printable text (which, I assume, is how this driver was tested), but as soon as the UART is used in non canonical (raw) mode, with potentially 0x00 bytes, these bytes will be silently dropped, causing issues in the data/protocol layer above. Update #4982.
Diffstat (limited to 'bsps')
-rw-r--r--bsps/arm/tms570/console/tms570-sci.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/bsps/arm/tms570/console/tms570-sci.c b/bsps/arm/tms570/console/tms570-sci.c
index b945855986..63f8e7c8ee 100644
--- a/bsps/arm/tms570/console/tms570-sci.c
+++ b/bsps/arm/tms570/console/tms570-sci.c
@@ -49,8 +49,6 @@
#include <bsp/fatal.h>
#include <bsp/irq.h>
-#define TMS570_SCI_BUFFER_SIZE 1
-
/**
* @brief Table including all serial drivers
*
@@ -172,33 +170,6 @@ rtems_device_driver console_initialize(
}
/**
- * @brief Reads chars from HW
- *
- * Reads chars from HW peripheral specified in driver context.
- * TMS570 does not have HW buffer for serial line so this function can
- * return only 0 or 1 char
- *
- * @param[in] ctx context of the driver
- * @param[out] buf read data buffer
- * @param[in] N size of buffer
- * @retval x Number of read chars from peripherals
- */
-static int tms570_sci_read_received_chars(
- tms570_sci_context * ctx,
- char * buf,
- int N)
-{
- if ( N < 1 ) {
- return 0;
- }
- if ( ctx->regs->RD != 0 ) {
- buf[0] = ctx->regs->RD;
- return 1;
- }
- return 0;
-}
-
-/**
* @brief Enables RX interrupt
*
* Enables RX interrupt source of SCI peripheral
@@ -351,23 +322,25 @@ static void tms570_sci_interrupt_handler(void * arg)
{
rtems_termios_tty *tty = arg;
tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
- char buf[TMS570_SCI_BUFFER_SIZE];
- size_t n;
/*
* Check if we have received something.
*/
if ( (ctx->regs->FLR & TMS570_SCI_FLR_RXRDY ) == TMS570_SCI_FLR_RXRDY ) {
- n = tms570_sci_read_received_chars(ctx, buf, TMS570_SCI_BUFFER_SIZE);
- if ( n > 0 ) {
- /* Hand the data over to the Termios infrastructure */
- rtems_termios_enqueue_raw_characters(tty, buf, n);
- }
+ char buf[1];
+
+ /* Read the received byte */
+ buf[0] = ctx->regs->RD & 0x000000FF;
+
+ /* Hand the data over to the Termios infrastructure */
+ rtems_termios_enqueue_raw_characters(tty, buf, 1);
}
/*
* Check if we have something transmitted.
*/
if ( (ctx->regs->FLR & TMS570_SCI_FLR_TXRDY ) == TMS570_SCI_FLR_TXRDY ) {
+ size_t n;
+
n = tms570_sci_transmitted_chars(ctx);
if ( n > 0 ) {
/*