Skip to content

Commit 4691fff

Browse files
committed
[utest][driver][serial_v2] 优化flush判断逻辑
1 parent c8f0a26 commit 4691fff

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

components/drivers/serial/utest/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ menu "Serial Test"
1616
string "Device Name for Serial Test"
1717
default "uart2"
1818

19+
config RT_SERIAL_TC_DEVICE_USING_TX_DMA
20+
bool "Selected serial device is using TX DMA"
21+
default n
22+
1923
config RT_SERIAL_TC_RXBUF_SIZE
2024
int "RX Buffer Size for Serial Test"
2125
default 128

components/drivers/serial/utest/v2/uart_flush_txb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static rt_err_t test_item(rt_uint8_t *uart_write_buffer, rt_uint32_t send_size)
6464
rt_device_control(&serial->parent, RT_SERIAL_CTRL_TX_FLUSH, RT_NULL);
6565
tick_diff = rt_tick_get() - old_tick;
6666

67-
if (tick_diff < expect_time || tick_diff > (expect_time + 10))
67+
rt_uint32_t lower_bound = (expect_time > 2) ? (expect_time - 2) : 0;
68+
if (tick_diff < lower_bound || tick_diff > (expect_time + 10))
6869
{
6970
LOG_E("send_size [%4d], time required for TXB mode transmission to complete [%3d], expect_time [%3d]", send_size, tick_diff, expect_time);
7071
return -RT_ERROR;

components/drivers/serial/utest/v2/uart_flush_txnb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static rt_err_t test_item(rt_uint8_t *uart_write_buffer, rt_uint32_t send_size)
6464
rt_device_control(&serial->parent, RT_SERIAL_CTRL_TX_FLUSH, RT_NULL);
6565
tick_diff = rt_tick_get() - old_tick;
6666

67-
if (tick_diff < expect_time || tick_diff > (expect_time + 10))
67+
rt_uint32_t lower_bound = (expect_time > 2) ? (expect_time - 2) : 0;
68+
if (tick_diff < lower_bound || tick_diff > (expect_time + 10))
6869
{
6970
LOG_E("send_size [%4d], time required for TXNB mode transmission to complete [%3d], expect_time [%3d]", send_size, tick_diff, expect_time);
7071
return -RT_ERROR;

components/drivers/serial/utest/v2/uart_timeout_txb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <stdlib.h>
1515

1616
#ifdef RT_UTEST_SERIAL_V2
17-
#ifndef BSP_UART2_TX_USING_DMA
17+
#ifndef RT_SERIAL_TC_DEVICE_USING_TX_DMA
1818

1919
static struct rt_serial_device *serial;
2020

0 commit comments

Comments
 (0)