-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[bsp][stm32] 增加uart的DMA发送功能 #2645
[bsp][stm32] 增加uart的DMA发送功能 #2645
Conversation
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.
这个有两项检查没有成功,看了一下都是stm32F103的开发板,在检查的时候发现uart的dma定义变了所以检查不通过,这个要怎么处理呀! |
需要对编译失败的两个BSP都进行修改,以确保无错。 |
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.
先解决一下冲突吧,正在看这个 PR,最近 serial.c 有一点修改。
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.
看上面你的回复,只添加 f4 系列的 DMA 发送的话在 ci 的时候 F1 系列会报错,所以你添加了 F1 系列的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.
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.
@zhouchuanfu 有很多测试用例没有通过,可以瞧瞧是哪里逻辑改的不太对了 |
好的 |
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.
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 发送时,程序会卡在
上面那一句代码清除中断标志,后面这几句就一直等下去了。 |
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.
另外现在 shell 的 DMA 方式还支持流模式,在 _serial_dma_tx
函数中实现,此时如果以 DMA 发送方式打开 shell 设备,就会出现只有换行没有回车的情况出现,如果有兴趣后面也可以为 shell DMA 发送添加流模式 RT_DEVICE_FLAG_STREAM
。
在该模式下,在 serial.c
文件中,shell 以轮询方式进行输出,会对 /n
字符进行处理,自动添加 /r
,代码如下:
if (*data == '\n' && (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM))
{
serial->ops->putc(serial, '\r');
}
不过话说回来,DMA 发送的流模式也没有太大意义,毕竟使用 DMA 是为了效率为先,所以这个还是不要加了,我只是提一下,有这个问题。以什么符号为换行符,可以在终端里面配置吧。
是的 可能单字节使用dma有点浪费 |
这里的问题是,要将发送的数据中的所有 \n 前面添加 \r ,这样其实就多了一遍的遍历操作,大大降低了 DMA 的发送效率。 |
修复dma_config里面rcc的bug。
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.
大概理解你的意思了,如果要改的话可以有两种思路,一种是在缓存+算法添加修改\r,理论上在控制台缓存定义位置需要添加一定大小用于扩展, 一种是通过调度+算法来解决,提前计算出\n的位置以及到这个位置的数据长度,并启动dma发送,然后再发送\r\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.
这个已经修复过了,可以进行测试了 |
好的,等会儿我看一下。 |
经过测试,功能上没有问题了,我再检查一下关于 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.
经过测试,串口 DMA 发送功能正常。
@misonyo 我这边已经 review 过了,你可以进一步试试了。 |
拉取/合并请求描述:(PR description)
[
增加uart的DMA发送功能。
此次修改会影响stm32目录下的其他bsp,需要修改
“rt-thread/bsp/stm32/libraries/HAL_Drivers/config/芯片类型目录/”
目录下的uart_config.h和dma_config.h,具体可参照 f4 芯片类型修改。
]
以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use web browser to visit PR, and check items one by one, and ticked them if no problem.
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up