diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_usart_v2.c b/bsp/stm32/libraries/HAL_Drivers/drv_usart_v2.c
index b1b224005a32b58887d01e7c08fb56a3ecdc19a6..1f84d848a0ede562207d0c19b6904392d979fb97 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_usart_v2.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_usart_v2.c
@@ -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)
diff --git a/bsp/stm32/stm32l475-atk-pandora/project.uvprojx b/bsp/stm32/stm32l475-atk-pandora/project.uvprojx
index 6089d4c37134a194a3fc676da4eb8dd626698f42..a41acfebf111f06a73f581f5bc2535380c22e226 100644
--- a/bsp/stm32/stm32l475-atk-pandora/project.uvprojx
+++ b/bsp/stm32/stm32l475-atk-pandora/project.uvprojx
@@ -338,7 +338,7 @@
USE_HAL_DRIVER, __RTTHREAD__, STM32L475xx
- .;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
+ .;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
@@ -388,15 +388,20 @@
applications\main.c
- uart_sample.c
+ uart_rxblocking_txblocking.c
1
- .\applications\uart_sample.c
+ .\applications\uart_rxblocking_txblocking.c
CPU
+
+ backtrace.c
+ 1
+ ..\..\..\libcpu\arm\common\backtrace.c
+
showmem.c
1
@@ -408,20 +413,15 @@
..\..\..\libcpu\arm\common\div0.c
- backtrace.c
- 1
- ..\..\..\libcpu\arm\common\backtrace.c
+ context_rvds.S
+ 2
+ ..\..\..\libcpu\arm\cortex-m4\context_rvds.S
cpuport.c
1
..\..\..\libcpu\arm\cortex-m4\cpuport.c
-
- context_rvds.S
- 2
- ..\..\..\libcpu\arm\cortex-m4\context_rvds.S
-
@@ -438,14 +438,9 @@
..\..\..\components\drivers\serial\serial_v2.c
- completion.c
- 1
- ..\..\..\components\drivers\src\completion.c
-
-
- ringbuffer.c
+ ringblk_buf.c
1
- ..\..\..\components\drivers\src\ringbuffer.c
+ ..\..\..\components\drivers\src\ringblk_buf.c
waitqueue.c
@@ -453,14 +448,14 @@
..\..\..\components\drivers\src\waitqueue.c
- ringblk_buf.c
+ workqueue.c
1
- ..\..\..\components\drivers\src\ringblk_buf.c
+ ..\..\..\components\drivers\src\workqueue.c
- dataqueue.c
+ ringbuffer.c
1
- ..\..\..\components\drivers\src\dataqueue.c
+ ..\..\..\components\drivers\src\ringbuffer.c
pipe.c
@@ -468,9 +463,14 @@
..\..\..\components\drivers\src\pipe.c
- workqueue.c
+ completion.c
1
- ..\..\..\components\drivers\src\workqueue.c
+ ..\..\..\components\drivers\src\completion.c
+
+
+ dataqueue.c
+ 1
+ ..\..\..\components\drivers\src\dataqueue.c
@@ -533,9 +533,14 @@
Kernel
- idle.c
+ device.c
1
- ..\..\..\src\idle.c
+ ..\..\..\src\device.c
+
+
+ timer.c
+ 1
+ ..\..\..\src\timer.c
kservice.c
@@ -543,14 +548,19 @@
..\..\..\src\kservice.c
- device.c
+ irq.c
1
- ..\..\..\src\device.c
+ ..\..\..\src\irq.c
- clock.c
+ ipc.c
1
- ..\..\..\src\clock.c
+ ..\..\..\src\ipc.c
+
+
+ idle.c
+ 1
+ ..\..\..\src\idle.c
mempool.c
@@ -563,24 +573,19 @@
..\..\..\src\scheduler.c
- mem.c
- 1
- ..\..\..\src\mem.c
-
-
- components.c
+ clock.c
1
- ..\..\..\src\components.c
+ ..\..\..\src\clock.c
- ipc.c
+ thread.c
1
- ..\..\..\src\ipc.c
+ ..\..\..\src\thread.c
- irq.c
+ mem.c
1
- ..\..\..\src\irq.c
+ ..\..\..\src\mem.c
object.c
@@ -588,14 +593,9 @@
..\..\..\src\object.c
- thread.c
- 1
- ..\..\..\src\thread.c
-
-
- timer.c
+ components.c
1
- ..\..\..\src\timer.c
+ ..\..\..\src\components.c
@@ -709,6 +709,16 @@
+
+ UTest
+
+
+ utest.c
+ 1
+ ..\..\..\components\utilities\utest\utest.c
+
+
+
diff --git a/components/drivers/include/drivers/serial_v2.h b/components/drivers/include/drivers/serial_v2.h
index 51306a4bb4a44690c1aa023ba7ee832d4d390013..3ba46bdcdd1bebb65d71032fda64ec5a6d3eaaf8 100644
--- a/components/drivers/include/drivers/serial_v2.h
+++ b/components/drivers/include/drivers/serial_v2.h
@@ -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;
diff --git a/components/drivers/serial/SConscript b/components/drivers/serial/SConscript
index f3f69991f522381d72025bb5f217056ca88de452..81d791803a090039a08b924f63d099e2319387bc 100644
--- a/components/drivers/serial/SConscript
+++ b/components/drivers/serial/SConscript
@@ -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')
diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c
index 1019b73e678dffe61a45157921c12ddfa67b9f58..8670a99aa891c3fabab6a0e9da7a256b4750830e 100644
--- a/components/drivers/serial/serial_v2.c
+++ b/components/drivers/serial/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);