-
Notifications
You must be signed in to change notification settings - Fork 5.3k
bsp: k230: add support for PWM driver #10556
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-07-29 13:27 CST)
📝 Review Instructions
|
|
新开这个 PR 继续 #10536 ,用 dev-pwm 开发分支代替原 PR 中的 master 分支。 |
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。
还有一些小问题,请继续修改。
| static rt_err_t pwm_start(kd_pwm_t *reg, int channel) | ||
| { | ||
| int ret; | ||
| ret = check_channel(channel); |
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.
check_channel 的返回值类型和定义不匹配,请统一。这有好几处请一并修改。
| struct k230_pwm_dev *dev = &pwm_devs[i]; | ||
| dev->base = (rt_ubase_t)rt_ioremap((void *)(dev->base), sizeof(kd_pwm_t)); | ||
| dev->device.ops = &drv_ops; | ||
| ret = rt_device_pwm_register(&dev->device, dev->name, &drv_ops, (void *)dev->base); |
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_device_pwm_register 的第三个参数确定需要传入吗?
|
|
||
| if GetDepend('BSP_USING_PWM'): | ||
| src += ['test_pwm.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.
17 和 20 行有行尾空格需要删掉。
bsp/k230/drivers/utest/test_pwm.c
Outdated
|
|
||
| void pwm_demo(void) | ||
| { | ||
| rt_kprintf("set gpio52 in PWM1 start.\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.
用 LOG_I,不要用 rt_kprintf
bsp/k230/drivers/utest/test_pwm.c
Outdated
| rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL); | ||
| sleep(2); | ||
| } | ||
| rt_pwm_disable(pwm_dev, PWM_DEV_CHANNEL); |
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_pwm_set/rt_pwm_enable/rt_pwm_disable 这些函数都有返回值的,需要 assert
|
好的,我改一下,感谢汪老师提醒 |
Added a PWM driver and a test file test_pwm.c. The test uses PWM to control the LED brightness, to check if the driver works correctly. Signed-off-by: XU HU <1337858472@qq.com>
|
@Rbb666 hi, 请 review 并 merge,谢谢。 |
Added a PWM driver and a test file test_pwm.c.
The test uses PWM to control the LED brightness,
to check if the driver works correctly.
Signed-off-by: XU HU 1337858472@qq.com