-
Notifications
You must be signed in to change notification settings - Fork 5.3k
bsp:k230:add pdma support for uart driver #10639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📌 Code Review Assignment🏷️ Tag: bsp_k230Reviewers: unicornx Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-08-28 18:07 CST)
📝 Review Instructions
|
|
该 PR 继续 #10628 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个算第二次 review,第一次见 #10628
除了下面的代码中的 comments 外, commit 的标题中前缀请加空格,“bsp: k230: xxxx"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RT_CONSOLE_DEVICE_NAME 这个配置你忘记改了,应该恢复成默认配置 uart0, 否则控制台无法工作
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
抱歉,这个是我的疏忽
| rt_uint32_t uart_to_size; | ||
| rt_uint32_t irqno; | ||
|
|
||
| #ifdef BSP_UART_USING_DMA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef 和 下面的 #end 请顶格写, 不要和代码一起缩进。这个问题你全文检查一下。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到
| #define read32(addr) readl((void*)(addr)) | ||
|
|
||
| #ifdef BSP_UART_USING_DMA | ||
| static void _k230_uart_pdma_call_back(rt_uint8_t ch, rt_bool_t is_done) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数和其他 dma 相关函数放一起。我希望代码整理后用条件编译(BSP_UART_USING_DMA)括起来的代码尽量都在一起,不要分散在好几处。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
| K230_UART_PDMA_EVENT_COMPLETE, | ||
| K230_UART_PDMA_EVENT_TIMEOUT | ||
| } uart_pdma_event_t; | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个枚举定义可以和 _k230_uart_pdma_call_back 放在一起。
| static rt_ssize_t _uart_dma_tran(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction); | ||
| #endif | ||
|
|
||
| const struct rt_uart_ops _uart_ops = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你调整一下 _uart_ops 的位置,放到文件的后面(rt_hw_uart_init() 之前)也是可以的,这样我理解上面部分函数声明都不需要了。你整理一下代码看看?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,我看一下
| drv_uart_getc, | ||
| //TODO: add DMA support | ||
| RT_NULL | ||
| .configure = _rt_uart_configure, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_rt_uart_configure() 这个函数我们并没有实现什么,就不需要定义可,直接设置回调为 NULL。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个东西我后来尝试了一下,如果去掉的话,测试会报错,得加上
| LOG_E("Failed to init DMA for %s, ret=%d\n", dev->name, ret); | ||
| return ret; | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一块代码缩进有问题,用 format 工具检查过吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
检查过,只不过感觉format工具有点问题,比如行尾空格消不掉
| rt_hw_interrupt_umask(uart->irqno); | ||
| rt_uint32_t flags; | ||
| flags = RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_INT_TX; | ||
| #ifdef BSP_UART_USING_DMA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef /#endif 不要和代码一起缩进,容易看混了。
2a7741f to
446fbb4
Compare
|
汪老师,那个_rt_uart_configure我尝试去掉之后,测试会报错,还是需要加上的 |
具体测试什么?会报什么错?直接给 |
unicornx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第三次 review,主要看了一下 test 部分代码。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于测试,有个问题,为啥不能 TX 要用 uart3?能否也用 uart0?
用 uart3 还要另外配置以及接线,会不会很麻烦?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,我待会再尝试一下,这个主要是涉及到要用dma的flag打开uart设备,用完之后可能没法正常用uart进行其他的输入输出了
bsp/k230/drivers/utest/test_uart.c
Outdated
| serial = rt_container_of(uart_dev, struct rt_serial_device, parent); | ||
| uassert_not_null(serial); | ||
| size_t len = TEXT_LENGTH; | ||
| ret = rt_device_write(serial,0,msg,len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里编译会告警,参数类型不匹配。
另外,这里代码风格不好,函数实参之间要用空格隔开。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
Added pdma support for uart driver and a test file test_uart.c. The test uses pdma to improve uart send speed, to check if the driver works correctly. Signed-off-by: XU HU 1337858472@qq.com
446fbb4 to
d07c6df
Compare
|
@Rbb666 请 review & merge 如果没问题的话。谢谢。 |
unicornx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第 4 次 review
Added pdma support for uart driver and a test file test_uart.c.
The test uses pdma to improve uart send speed,
to check if the driver works correctly.
Signed-off-by: XU HU 1337858472@qq.com