-
Notifications
You must be signed in to change notification settings - Fork 5.3k
bsp:k230:add pdma support for uart driver #10628
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-27 10:59 CST)
📝 Review Instructions
|
|
麻烦 @unicornx 帮忙review一下 |
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
看得比较粗糙。提了些 genernal 的问题请看一下。比较大的问题是有关 uart 这里如何使用 dma 的方式,是否每次 write 时都要怎么操作一遍?还是一开始就申请好?这个操作方式上有些疑问。
btw:commit 的 title 上请加些空格,不要挤在一起:譬如写成:"bsp: k230: add ....."
bsp/k230/board/Kconfig
Outdated
| if BSP_USING_UART | ||
| config BSP_USING_UART0 | ||
| bool "Enable UART0" | ||
| default n |
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.
这个 default y 吧
| rt_uint32_t irqno; | ||
| }; | ||
|
|
||
| /* 支持的 UART 设备列表 */ |
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.
好的
| } | ||
|
|
||
| UTEST_TC_EXPORT(test_pdma, "pdma", utest_tc_init, utest_tc_cleanup, 10); | ||
| UTEST_TC_EXPORT(test_pdma, "pdma", utest_tc_init, utest_tc_cleanup, 10); |
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.
为何会改动这个文件?
bsp/k230/drivers/utest/test_uart.c
Outdated
| static void uart_tx_demo(void) | ||
| { | ||
| rt_device_t uart_dev; | ||
| char *msg = rt_malloc(2024); |
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.
为啥是 2024?为啥不用宏?
请尽量避免用立即数,此问题全文检查
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.
嗯嗯,这里2024就是随便搞个比较大的数测试
bsp/k230/drivers/utest/test_uart.c
Outdated
| * - 本测试基于 K230 平台; | ||
| * - UART3 为开发板上的一个串口接口; | ||
| * - 发送的数据为 2023 个 '[' 字符,可通过串口调试工具观察输出; | ||
| * - 本测试仅验证 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.
为啥不测试接收功能?
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做dma接收的功能有点困难,dma驱动里面有一个超时回调,如果是用rt_device_open去测试接受功能的话,没法做延时几秒等待键盘发送字符,目前关于接受功能的实现我还没有什么头绪。
|
|
||
| /* | ||
| * 测试 UART3 在 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.
感觉如果真要测试 uart3,需要注明一下编译时配置上要专门 enable uart3
| */ | ||
|
|
||
| #include <rthw.h> | ||
| #include <rtdevice.h> |
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.c 开头的 license 也顺便整理一下。
同理请将 drv_uart.h 开头的 license 也整理一下。
和其他驱动文件保证一致。
另外 drv_uart.h 中声明的一些函数好像没用了,也清理一下吧。
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.
好的
| #include <lwp_user_mm.h> | ||
| #include <ioremap.h> | ||
|
|
||
| #include <rtdbg.h> |
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.
为何要加这个?
| TEST_PDMA_EVENT_NONE, | ||
| TEST_PDMA_EVENT_COMPLETE, | ||
| TEST_PDMA_EVENT_TIMEOUT | ||
| } test_pdma_event_t; |
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 的驱动的一部分,我建议你把全文的符号(变量名、函数名、常量...) 都加上相应的前缀。譬如统一加上 "k230_uart_" 这样的前缀。
对 global 的函数加上统一的前缀,尽量避免名字污染。
static 的函数可以不加,但最好加上一些特殊标记,譬如以下划线开头标识这是一个内部符号 ......
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.
好的
| /* Configure DMA transfer */ | ||
| err = k230_pdma_request_channel(&ch); | ||
|
|
||
| usr_pdma_cfg_t pdma_cfg; |
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.
这个 cfg 对象每次 write 都要初始化一次?效率是不是很低啊?打个比方,如果我发送 100 次一个字节的数据,也要初始化 100 次?
能不能建一个 dma channel 让多个 uart 通道复用,当然这要考虑一下上锁互斥的问题。
或者一个 uart 占一个 dma channel?
你研究一下呢?
总之目前的做法看上去效率会有点低哎,不清楚的话,可以去问问 canaan 的人有什么好方法。
BTW, uart_canaan 里的 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.
好的,这个我研究一下
e3842bd to
08cb993
Compare
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
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