bsp: k230: add support for PWM driver#10556
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.
第四次 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.
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.
rt_device_pwm_register 的第三个参数确定需要传入吗?
|
|
||
| if GetDepend('BSP_USING_PWM'): | ||
| src += ['test_pwm.c'] | ||
|
|
bsp/k230/drivers/utest/test_pwm.c
Outdated
|
|
||
| void pwm_demo(void) | ||
| { | ||
| rt_kprintf("set gpio52 in PWM1 start.\n"); |
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.
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