Merged in rnouse/nuttx (pull request #8)

UART 16550: putc logic fixup
This commit is contained in:
Gregory Nutt 2015-08-03 06:32:17 -06:00
commit 08d83cfae3
3 changed files with 3 additions and 30 deletions

View File

@ -337,18 +337,7 @@ config 16550_ADDRWIDTH
---help---
The bit width of registers. Options are 8, 16, or 32. Default: 8
config 16550_THRNE
bool "Use THRNE"
default n if !ARCH_CHIP_MOXART
default y if ARCH_CHIP_MOXART
---help---
The 16550 UART has a bit in the line status register, THRE, that
indicates that the Transmit Holding Register (THR) is Empty (N).
This bit is inverted in at least one variant (the moxART SoC).
In that case, this setting must be included to use this bit as
THR *Not* Empty (THRNE).
endif # 16550_UART
endif
#
# MCU serial peripheral driver?

View File

@ -1030,11 +1030,7 @@ static void u16550_txint(struct uart_dev_s *dev, bool enable)
static bool u16550_txready(struct uart_dev_s *dev)
{
struct u16550_s *priv = (struct u16550_s*)dev->priv;
#ifdef CONFIG_16550_THRNE
return ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRNE) == 0);
#else
return ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0);
#endif
}
/****************************************************************************
@ -1048,11 +1044,7 @@ static bool u16550_txready(struct uart_dev_s *dev)
static bool u16550_txempty(struct uart_dev_s *dev)
{
struct u16550_s *priv = (struct u16550_s*)dev->priv;
#ifdef CONFIG_16550_THRNE
return ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRNE) == 0);
#else
return ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0);
#endif
}
/****************************************************************************
@ -1065,11 +1057,7 @@ static bool u16550_txempty(struct uart_dev_s *dev)
static void u16550_putc(struct u16550_s *priv, int ch)
{
#ifdef CONFIG_16550_THRNE
while ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRNE) == 0);
#else
while ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) != 0);
#endif
while ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_THRE) == 0);
u16550_serialout(priv, UART_THR_OFFSET, (uart_datawidth_t)ch);
}

View File

@ -299,11 +299,7 @@
#define UART_LSR_PE (1 << 2) /* Bit 2: Parity Error */
#define UART_LSR_FE (1 << 3) /* Bit 3: Framing Error */
#define UART_LSR_BI (1 << 4) /* Bit 4: Break Interrupt */
#ifdef CONFIG_16550_THRNE
# define UART_LSR_THRNE (1 << 5) /* Bit 5: Transmitter Holding Register Not Empty */
#else
# define UART_LSR_THRE (1 << 5) /* Bit 5: Transmitter Holding Register Empty */
#endif
#define UART_LSR_THRE (1 << 5) /* Bit 5: Transmitter Holding Register Empty */
#define UART_LSR_TEMT (1 << 6) /* Bit 6: Transmitter Empty */
#define UART_LSR_RXFE (1 << 7) /* Bit 7: Error in RX FIFO (RXFE) */