![]() |
RT-Thread API参考手册
4.0.3
嵌入式实时操作系统
|
PWM设备接口 更多...
结构体 | |
| struct | rt_pwm_configuration |
| PWM设备配置参数 更多... | |
| struct | rt_pwm_ops |
| PWM设备的操作方法 更多... | |
| struct | rt_device_pwm |
| PWM设备控制块 更多... | |
函数 | |
| rt_err_t | rt_device_pwm_register (struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data) |
| 注册PWM设备 更多... | |
| rt_err_t | rt_pwm_enable (struct rt_device_pwm *device, int channel) |
| 打开PWM通道 更多... | |
| rt_err_t | rt_pwm_disable (struct rt_device_pwm *device, int channel) |
| 关闭PWM通道 更多... | |
| rt_err_t | rt_pwm_set (struct rt_device_pwm *device, int channel, rt_uint32_t period, rt_uint32_t pulse) |
| 设置PWM参数 更多... | |
PWM设备接口
| rt_err_t rt_device_pwm_register | ( | struct rt_device_pwm * | device, |
| const char * | name, | ||
| const struct rt_pwm_ops * | ops, | ||
| const void * | user_data | ||
| ) |
注册PWM设备
调用此函数可以注册PWM设备到系统。
| device | PWM设备句柄 |
| name | 设备名称 |
| ops | PWM设备的操作方法 |
| user_data | PWM设备的私有数据 |
| rt_err_t rt_pwm_enable | ( | struct rt_device_pwm * | device, |
| int | channel | ||
| ) |
打开PWM通道
调用此函数可以使能指定的PWM通道
| device | PWM设备句柄 |
| channel | 指定的PWM通道 |
| rt_err_t rt_pwm_disable | ( | struct rt_device_pwm * | device, |
| int | channel | ||
| ) |
关闭PWM通道
调用此函数可以关闭指定的PWM通道
| device | PWM设备句柄 |
| channel | 指定的PWM通道 |
| rt_err_t rt_pwm_set | ( | struct rt_device_pwm * | device, |
| int | channel, | ||
| rt_uint32_t | period, | ||
| rt_uint32_t | pulse | ||
| ) |
设置PWM参数
该函数可以设定指定PWM通道的周期和占空参数。
| device | PWM设备句柄 |
| channel | 指定的PWM通道 |
| period | 周期 |
| pulse | 占空比 |