From e22912db37182cc7e05970c8d7145bd8dc45c0aa Mon Sep 17 00:00:00 2001 From: Sebastien Lorquet Date: Tue, 1 Aug 2017 06:30:52 -0600 Subject: [PATCH] drivers/serial/serial.c: Add support for TCFLUSH --- drivers/serial/serial.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 49417a9685..cc0e2fe441 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -977,6 +977,37 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ret = 0; } break; + +#ifdef CONFIG_SERIAL_TERMIOS + case TCFLSH: + { + /* Empty the tx/rx buffers */ + + irqstate_t flags = enter_critical_section(); + + if (arg == TCIFLUSH || arg == TCIOFLUSH) + { + dev->recv.head = 0; + dev->recv.tail = 0; + } + + if (arg == TCOFLUSH || arg == TCIOFLUSH) + { + dev->xmit.head = 0; + dev->xmit.tail = 0; + } + + leave_critical_section(flags); + } + break; + +#if 0 + case TCDRN: + { + } + break; +#endif +#endif } }