-
Notifications
You must be signed in to change notification settings - Fork 5k
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: cvitek: fix cvitek uart driver can not repeat configure #9257
bsp: cvitek: fix cvitek uart driver can not repeat configure #9257
Conversation
bsp/cvitek/drivers/drv_uart.c
Outdated
@@ -132,6 +132,8 @@ static rt_err_t dw8250_uart_configure(struct rt_serial_device *serial, struct se | |||
clock_divisor = DIV_ROUND_CLOSEST(UART_INPUT_CLK, 16 * serial->config.baud_rate); | |||
dw8250_uart_setbrg(base, clock_divisor); | |||
|
|||
dw8250_write32(base, UART_IER, UART_IER_RDI); |
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.
已修改
9ca3d50
to
9e4dcf5
Compare
bsp/cvitek/drivers/drv_uart.c
Outdated
@@ -132,6 +134,9 @@ static rt_err_t dw8250_uart_configure(struct rt_serial_device *serial, struct se | |||
clock_divisor = DIV_ROUND_CLOSEST(UART_INPUT_CLK, 16 * serial->config.baud_rate); | |||
dw8250_uart_setbrg(base, clock_divisor); | |||
|
|||
if(last_ier_state == UART_IER_RDI) |
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.
if
和 (
之间应该有空格,这个 formating 检查不出来吗?
另外,直接判断 last_ier_state == UART_IER_RDI
不妥,而是要判断 IER[0]
这一位以前是否是 1,IER 其他位也可能会是 1。
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.
if
和(
之间应该有空格,这个 formating 检查不出来吗?另外,直接判断
last_ier_state == UART_IER_RDI
不妥,而是要判断IER[0]
这一位以前是否是 1,IER 其他位也可能会是 1。
其他的 bit 位是不是也应该恢复?所以这个 issue 的完整 fix 应该就是一个完整的 backup -> restore 的操作。
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.
formating没检查出来,已手动更改,位判断也已解决
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.
formating没检查出来,已手动更改,位判断也已解决
只恢复 UART_IER_RDI 这个位是不够的,其他 bit 的值也需要恢复。
BTW:我不知道 github 是否有机制重新发起下一次 review,你可以研究一下。
最土的方法,你下次每一次改好重新 push 后,可以在 PR 里明确 AT 所有的 reviewer 然后请求第 N 次 review。有时候 review 的 PR 多了我也不知道你是否改过了,以及是否重新 push 过。
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.
formating没检查出来,已手动更改,位判断也已解决
只恢复 UART_IER_RDI 这个位是不够的,其他 bit 的值也需要恢复。
BTW:我不知道 github 是否有机制重新发起下一次 review,你可以研究一下。 最土的方法,你下次每一次改好重新 push 后,可以在 PR 里明确 AT 所有的 reviewer 然后请求第 N 次 review。有时候 review 的 PR 多了我也不知道你是否改过了,以及是否重新 push 过。
追加一个问题:
为啥当初代码里是直接将 UART_IER 置 0,传统的做法一般是对需要的位设置,其他位保持不变。
另外,这个 dw8250_uart_configure 为什么用不到 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 传参进行配置这部分确实缺少了,需要补上
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
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.
comments 见上。
9e4dcf5
to
953db55
Compare
这个 PR 先解决 #9150 的问题吧,cfg 传参进行配置这部分缺少的问题后面再单独修改吧。 |
好的 明白 |
After first called from uart open, the dw8250_uart_configure API cannot be called again. Otherwise, this will mess up the device, and uart will not act properly to interrupt again. Analysis: Configure uart device will close recive interrupte, causing uart device to malfunction. Solution: After configure uart device, enable the device's recive interrupte. Signed-off-by: Shicheng Chu <[email protected]> Reviewed-by: Chen Wang <[email protected]>
953db55
to
9fb118d
Compare
bsp/cvitek/drivers/drv_uart.c
Outdated
@@ -132,6 +134,9 @@ static rt_err_t dw8250_uart_configure(struct rt_serial_device *serial, struct se | |||
clock_divisor = DIV_ROUND_CLOSEST(UART_INPUT_CLK, 16 * serial->config.baud_rate); | |||
dw8250_uart_setbrg(base, clock_divisor); | |||
|
|||
if (last_ier_state & UART_IER_RDI) | |||
dw8250_write32(base, UART_IER, UART_IER_RDI); |
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.
@unicornx 请确认这个PR是否可以合并? |
我这里没有问题了,也 approve 了。但我看熊大还没有 approve。 |
@BernardXiong hi, 请 review & commnet,谢谢。 |
After first called from uart open, the dw8250_uart_configure API cannot be called again. Otherwise, this will mess up the device, and uart will not act properly to interrupt again.
Analysis: Configure uart device will close recive interrupte, causing uart device to malfunction.
Solution: After configure uart device, enable the device's recive interrupte.
Reviewed-by: Chen Wang [email protected]
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
Fixed #9150
你的解决方案是什么 (what is your solution)
After configure uart device, enable the device's recive interrupte.
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 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