Linux驱动分析——PWM子系统

stm32mp157  盘古开发板  Linux内核版本4.19

1、首先了解在Linux系统上面怎么使用PWM,比如设置某个引脚输出某个PWM脉冲

内核文档linux-st\Documentation\ABI\testing\sysfs-class-pwm描述:

What:		/sys/class/pwm/
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		The pwm/ class sub-directory belongs to the Generic PWM
		Framework and provides a sysfs interface for using PWM
		channels.

What:		/sys/class/pwm/pwmchipN/
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		A /sys/class/pwm/pwmchipN directory is created for each
		probed PWM controller/chip where N is the base of the
		PWM chip.

What:		/sys/class/pwm/pwmchipN/npwm
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		The number of PWM channels supported by the PWM chip.

What:		/sys/class/pwm/pwmchipN/export
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		Exports a PWM channel from the PWM chip for sysfs control.
		Value is between 0 and /sys/class/pwm/pwmchipN/npwm - 1.

What:		/sys/class/pwm/pwmchipN/unexport
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		Unexports a PWM channel.

What:		/sys/class/pwm/pwmchipN/pwmX
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		A /sys/class/pwm/pwmchipN/pwmX directory is created for
		each exported PWM channel where X is the exported PWM
		channel number.

What:		/sys/class/pwm/pwmchipN/pwmX/period
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		Sets the PWM signal period in nanoseconds.

What:		/sys/class/pwm/pwmchipN/pwmX/duty_cycle
Date:		May 2013
KernelVersion:	3.11
Contact:	H Hartley Sweeten <[email protected]>
Description:
		Sets the PWM signal duty cycle in nanoseconds.

What:		/sys/class/pwm/pwmchipN/pw
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,我无法找到关于Linux PWM子系统的reload操作的具体信息。但是,我可以为您提供一些关于Linux PWM子系统的基本介绍和操作方法。 Linux PWM子系统是用于控制嵌入式系统中的脉冲宽度调制(PWM)信号的一个子系统。它允许用户通过软件来生成和控制PWM信号,用于控制各种外设,如LED灯、电机等。 要使用Linux PWM子系统,您需要进行以下步骤: 1. 确保您的系统已经加载了PWM驱动程序。您可以通过运行以下命令来检查: ```shell ls /sys/class/pwm/ ``` 如果该目录存在,则表示PWM驱动程序已加载。 2. 找到您想要使用的PWM通道。PWM通道通常在/sys/class/pwm/目录下以pwmchipX的形式表示,其中X是通道的编号。您可以运行以下命令来查看可用的PWM通道: ```shell ls /sys/class/pwm/ ``` 3. 配置PWM通道的属性。您可以通过修改/sys/class/pwm/pwmchipX/pwmY/目录下的相应属性文件来配置PWM通道的参数,其中X是PWM通道的编号,Y是具体通道的编号。例如,您可以通过修改/sys/class/pwm/pwmchip0/pwm0/目录下的duty_cycle文件来设置PWM信号的占空比。 4. 启动PWM信号。您可以通过将1写入/sys/class/pwm/pwmchipX/pwmY/enable文件来启动PWM信号,其中X是PWM通道的编号,Y是具体通道的编号。例如,您可以运行以下命令来启动PWM信号: ```shell echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable ``` 请注意,具体的PWM子系统操作可能因不同的硬件平台和Linux内核版本而有所差异。因此,我建议您查阅相关的文档和资料以获取更详细和准确的信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值