summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2017-11-15 18:07:26 +0800
committerGitHub <[email protected]>2017-11-15 18:07:26 +0800
commit66ddbbfef9b86e54e71d9f2abffe62fe4beeae08 (patch)
tree6ea94619d1a5da1937bc7f49f1c347ec8905b89b /components
parent849a1e19017a646c722b010113194393488a14b3 (diff)
parentbe3953fd36230829ab577db30c2a14fa43781dc5 (diff)
Merge pull request #1002 from JasonJiaJie/master
[DeviceDriver][serial]Fix compile error when RT_USING_POSIX_TERMIOS is not define.
Diffstat (limited to 'components')
-rw-r--r--components/drivers/serial/serial.c88
1 files changed, 45 insertions, 43 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index 149cfaff3e..3aad9e4ab7 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -365,48 +365,6 @@ static rt_size_t _serial_fifo_calc_recved_len(struct rt_serial_device *serial)
}
}
-static void _serial_flush(struct rt_serial_device *serial, int queue)
-{
- int ch = -1;
- struct rt_serial_rx_fifo *rx_fifo = RT_NULL;
- struct rt_device *device = RT_NULL;
-
- RT_ASSERT(serial != RT_NULL);
-
- device = &(serial->parent);
- rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx;
-
- switch(queue)
- {
- case TCIFLUSH:
- case TCIOFLUSH:
-
- RT_ASSERT(rx_fifo != RT_NULL);
-
- if((device->open_flag & RT_DEVICE_FLAG_INT_RX) || (device->open_flag & RT_DEVICE_FLAG_DMA_RX))
- {
- RT_ASSERT(RT_NULL != rx_fifo);
- rt_memset(rx_fifo->buffer, 0, serial->config.bufsz);
- rx_fifo->put_index = 0;
- rx_fifo->get_index = 0;
- rx_fifo->is_full = RT_FALSE;
- }
- else
- {
- while (1)
- {
- ch = serial->ops->getc(serial);
- if (ch == -1) break;
- }
- }
-
- break;
-
- case TCOFLUSH:
- break;
- }
-
-}
/**
* Calculate DMA received data length.
*
@@ -897,6 +855,50 @@ static int _get_baudrate(speed_t speed)
return 0;
}
+
+static void _tc_flush(struct rt_serial_device *serial, int queue)
+{
+ int ch = -1;
+ struct rt_serial_rx_fifo *rx_fifo = RT_NULL;
+ struct rt_device *device = RT_NULL;
+
+ RT_ASSERT(serial != RT_NULL);
+
+ device = &(serial->parent);
+ rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx;
+
+ switch(queue)
+ {
+ case TCIFLUSH:
+ case TCIOFLUSH:
+
+ RT_ASSERT(rx_fifo != RT_NULL);
+
+ if((device->open_flag & RT_DEVICE_FLAG_INT_RX) || (device->open_flag & RT_DEVICE_FLAG_DMA_RX))
+ {
+ RT_ASSERT(RT_NULL != rx_fifo);
+ rt_memset(rx_fifo->buffer, 0, serial->config.bufsz);
+ rx_fifo->put_index = 0;
+ rx_fifo->get_index = 0;
+ rx_fifo->is_full = RT_FALSE;
+ }
+ else
+ {
+ while (1)
+ {
+ ch = serial->ops->getc(serial);
+ if (ch == -1) break;
+ }
+ }
+
+ break;
+
+ case TCOFLUSH:
+ break;
+ }
+
+}
+
#endif
static rt_err_t rt_serial_control(struct rt_device *dev,
@@ -1026,7 +1028,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
{
int queue = (int)args;
- _serial_flush(serial, queue);
+ _tc_flush(serial, queue);
}
break;