[serial] 优化发送非阻塞时,serial_close未执行rt_completion_done的问题。
This commit is contained in:
parent
fac3c5cda1
commit
5ac5d92cbb
@ -456,6 +456,7 @@ static void uart_isr(struct rt_serial_device *serial)
|
||||
{
|
||||
if (__HAL_UART_GET_FLAG(&(uart->handle), UART_FLAG_ORE) != RESET)
|
||||
{
|
||||
LOG_E("(%s) serial device Overrun error!", serial->parent.parent.name);
|
||||
__HAL_UART_CLEAR_OREFLAG(&uart->handle);
|
||||
}
|
||||
if (__HAL_UART_GET_FLAG(&(uart->handle), UART_FLAG_NE) != RESET)
|
||||
|
@ -338,7 +338,7 @@
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER, __RTTHREAD__, STM32L475xx</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>.;applications;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;board\CubeMX_Config\Inc;board\ports;..\libraries\HAL_Drivers;..\libraries\HAL_Drivers\config;..\..\..\components\finsh;.;..\..\..\include;..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Inc;..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Include;..\libraries\STM32L4xx_HAL\CMSIS\Include</IncludePath>
|
||||
<IncludePath>.;applications;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;board\CubeMX_Config\Inc;board\ports;..\libraries\HAL_Drivers;..\libraries\HAL_Drivers\config;..\..\..\components\finsh;.;..\..\..\include;..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Inc;..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Include;..\libraries\STM32L4xx_HAL\CMSIS\Include;..\..\..\components\utilities\utest;..\..\..\examples\utest\testcases\kernel</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@ -388,15 +388,20 @@
|
||||
<FilePath>applications\main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart_sample.c</FileName>
|
||||
<FileName>uart_rxblocking_txblocking.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\applications\uart_sample.c</FilePath>
|
||||
<FilePath>.\applications\uart_rxblocking_txblocking.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>CPU</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>backtrace.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\common\backtrace.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>showmem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@ -408,20 +413,15 @@
|
||||
<FilePath>..\..\..\libcpu\arm\common\div0.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>backtrace.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\common\backtrace.c</FilePath>
|
||||
<FileName>context_rvds.S</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\cortex-m4\context_rvds.S</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cpuport.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\cortex-m4\cpuport.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>context_rvds.S</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\cortex-m4\context_rvds.S</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@ -438,14 +438,9 @@
|
||||
<FilePath>..\..\..\components\drivers\serial\serial_v2.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>completion.c</FileName>
|
||||
<FileName>ringblk_buf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\completion.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ringbuffer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\ringbuffer.c</FilePath>
|
||||
<FilePath>..\..\..\components\drivers\src\ringblk_buf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>waitqueue.c</FileName>
|
||||
@ -453,14 +448,14 @@
|
||||
<FilePath>..\..\..\components\drivers\src\waitqueue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ringblk_buf.c</FileName>
|
||||
<FileName>workqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\ringblk_buf.c</FilePath>
|
||||
<FilePath>..\..\..\components\drivers\src\workqueue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>dataqueue.c</FileName>
|
||||
<FileName>ringbuffer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\dataqueue.c</FilePath>
|
||||
<FilePath>..\..\..\components\drivers\src\ringbuffer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pipe.c</FileName>
|
||||
@ -468,9 +463,14 @@
|
||||
<FilePath>..\..\..\components\drivers\src\pipe.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>workqueue.c</FileName>
|
||||
<FileName>completion.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\workqueue.c</FilePath>
|
||||
<FilePath>..\..\..\components\drivers\src\completion.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>dataqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\dataqueue.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
@ -533,9 +533,14 @@
|
||||
<GroupName>Kernel</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>idle.c</FileName>
|
||||
<FileName>device.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\idle.c</FilePath>
|
||||
<FilePath>..\..\..\src\device.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\timer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>kservice.c</FileName>
|
||||
@ -543,14 +548,19 @@
|
||||
<FilePath>..\..\..\src\kservice.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>device.c</FileName>
|
||||
<FileName>irq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\device.c</FilePath>
|
||||
<FilePath>..\..\..\src\irq.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>clock.c</FileName>
|
||||
<FileName>ipc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\clock.c</FilePath>
|
||||
<FilePath>..\..\..\src\ipc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>idle.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\idle.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mempool.c</FileName>
|
||||
@ -563,29 +573,9 @@
|
||||
<FilePath>..\..\..\src\scheduler.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mem.c</FileName>
|
||||
<FileName>clock.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\mem.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>components.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\components.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ipc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\ipc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>irq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\irq.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>object.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\object.c</FilePath>
|
||||
<FilePath>..\..\..\src\clock.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>thread.c</FileName>
|
||||
@ -593,9 +583,19 @@
|
||||
<FilePath>..\..\..\src\thread.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer.c</FileName>
|
||||
<FileName>mem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\timer.c</FilePath>
|
||||
<FilePath>..\..\..\src\mem.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>object.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\object.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>components.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\components.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
@ -709,6 +709,16 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>UTest</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>utest.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\utilities\utest\utest.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
@ -118,8 +118,6 @@ struct rt_serial_rx_fifo
|
||||
{
|
||||
struct rt_ringbuffer rb;
|
||||
|
||||
rt_uint16_t rx_index;
|
||||
|
||||
struct rt_completion rx_cpt;
|
||||
|
||||
rt_uint16_t rx_cpt_index;
|
||||
|
@ -2,6 +2,7 @@ from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd + '/../include']
|
||||
group = []
|
||||
if GetDepend(['RT_USING_SERIAL']):
|
||||
if GetDepend(['RT_USING_SERIAL_V2']):
|
||||
src = Glob('serial_v2.c')
|
||||
|
@ -726,7 +726,6 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
|
||||
RT_ASSERT(rx_fifo != RT_NULL);
|
||||
rt_ringbuffer_init(&(rx_fifo->rb), rx_fifo->buffer, serial->config.rx_bufsz);
|
||||
|
||||
rx_fifo->rx_index = serial->config.rx_bufsz;
|
||||
serial->serial_rx = rx_fifo;
|
||||
dev->read = _serial_fifo_rx;
|
||||
|
||||
@ -813,6 +812,9 @@ static rt_err_t rt_serial_tx_disable(struct rt_device *dev,
|
||||
dev->write = RT_NULL;
|
||||
if (serial->serial_tx == RT_NULL) return RT_EOK;
|
||||
|
||||
tx_fifo = (struct rt_serial_tx_fifo *)serial->serial_tx;
|
||||
RT_ASSERT(tx_fifo != RT_NULL);
|
||||
|
||||
do
|
||||
{
|
||||
if (tx_oflag == RT_SERIAL_TX_NON_BLOCKING)
|
||||
@ -825,14 +827,13 @@ static rt_err_t rt_serial_tx_disable(struct rt_device *dev,
|
||||
break;
|
||||
}
|
||||
|
||||
rt_completion_done(&(tx_fifo->tx_cpt));
|
||||
dev->open_flag &= ~ RT_SERIAL_TX_BLOCKING;
|
||||
serial->ops->control(serial,
|
||||
RT_DEVICE_CTRL_CLR_INT,
|
||||
(void *)RT_SERIAL_TX_BLOCKING);
|
||||
} while (0);
|
||||
|
||||
tx_fifo = (struct rt_serial_tx_fifo *)serial->serial_tx;
|
||||
RT_ASSERT(tx_fifo != RT_NULL);
|
||||
rt_free(tx_fifo);
|
||||
serial->serial_tx = RT_NULL;
|
||||
|
||||
@ -876,6 +877,13 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
serial = (struct rt_serial_device *)dev;
|
||||
|
||||
/* Check that the device has been turned on */
|
||||
if ((dev->open_flag) & (15 << 12))
|
||||
{
|
||||
LOG_D("(%s) serial device has already been opened, it will run in its original configuration", dev->parent.name);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
LOG_D("open serial device: 0x%08x with open flag: 0x%04x",
|
||||
dev, oflag);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user