Linux下pwm用法总结
pwm在背光,电机等用的比较多,总结下用法 内核上有pwm来发射红外波的demohttps://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/media/rc/pwm-ir-tx.c?h=v5.8.10dts参考配置irled {compatible = "pwm-ir-tx";pwms = <&a
·
pwm在背光,电机等用的比较多,总结下用法
内核上有pwm来发射红外波的demo
dts参考配置
irled {
compatible = "pwm-ir-tx";
pwms = <&pwm0 0 10000000>;
};
//pwms = <&pwms 0 10000000>;周期为10000000ns(10ms)
关键的几个api
pwm_ir->pwm = devm_pwm_get(&pdev->dev, NULL);//获取dts里的pwm
period = xxxx;//不配置就是dts的周期
duty = yyyy;//高电平时间
pwm_config(pwm, duty, period);--->pwm->chip->ops->config(pwm->chip, pwm,state->duty_cycle,state->period)
pwm_enable(pwm)/pwm_disable(pwm)--->pwm->chip->ops->enable(pwm->chip, pwm)/pwm->chip->ops->disable(pwm->chip, pwm)
更多推荐
已为社区贡献6条内容
所有评论(0)