diff options
| author | 朱天龙 (Armink) <[email protected]> | 2022-03-27 00:52:41 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-27 00:52:41 +0800 |
| commit | bae1be0f45bbc8ca974413930a3024946d88990f (patch) | |
| tree | 32938495d1111adc7b67f23e839ca269eaa9f367 /components | |
| parent | 961fe7de0bc025857fdc1e8ebc64bac0e50f0e56 (diff) | |
完善串口 V2 框架 (#5720)
* [stm32] fix h7 uart V2 driver unused code.
* [DeviceDriver][serialv2] fix the serialv2 when using for console device on DMA mode.
* [stm32][art-pi] using serial v2 by default
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/serial/serial_v2.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c index 404e7abae9..7a7a04de35 100644 --- a/components/drivers/serial/serial_v2.c +++ b/components/drivers/serial/serial_v2.c @@ -484,21 +484,27 @@ static rt_size_t _serial_fifo_tx_blocking_buf(struct rt_device *dev, { struct rt_serial_device *serial; struct rt_serial_tx_fifo *tx_fifo = RT_NULL; + rt_size_t length = size; + rt_size_t offset = 0; - RT_ASSERT(dev != RT_NULL); if (size == 0) return 0; + RT_ASSERT(dev != RT_NULL); serial = (struct rt_serial_device *)dev; RT_ASSERT((serial != RT_NULL) && (buffer != RT_NULL)); + tx_fifo = (struct rt_serial_tx_fifo *) serial->serial_tx; RT_ASSERT(tx_fifo != RT_NULL); + + if (rt_thread_self() == RT_NULL || (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM)) + { + /* using poll tx when the scheduler not startup or in stream mode */ + return _serial_poll_tx(dev, pos, buffer, size); + } /* When serial transmit in tx_blocking mode, * if the activated mode is RT_TRUE, it will return directly */ if (tx_fifo->activated == RT_TRUE) return 0; - tx_fifo->activated = RT_TRUE; - rt_size_t length = size; - rt_size_t offset = 0; while (size) { |
