RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
|
结构体 | |
struct | rt_pwm_configuration |
struct | rt_pwm_ops |
struct | rt_device_pwm |
宏定义 | |
#define | PWM_CMD_ENABLE (RT_DEVICE_CTRL_BASE(PWM) + 0) |
#define | PWM_CMD_DISABLE (RT_DEVICE_CTRL_BASE(PWM) + 1) |
#define | PWM_CMD_SET (RT_DEVICE_CTRL_BASE(PWM) + 2) |
#define | PWM_CMD_GET (RT_DEVICE_CTRL_BASE(PWM) + 3) |
#define | PWMN_CMD_ENABLE (RT_DEVICE_CTRL_BASE(PWM) + 4) |
#define | PWMN_CMD_DISABLE (RT_DEVICE_CTRL_BASE(PWM) + 5) |
#define | PWM_CMD_SET_PERIOD (RT_DEVICE_CTRL_BASE(PWM) + 6) |
#define | PWM_CMD_SET_PULSE (RT_DEVICE_CTRL_BASE(PWM) + 7) |
#define | PWM_CMD_SET_DEAD_TIME (RT_DEVICE_CTRL_BASE(PWM) + 8) |
#define | PWM_CMD_SET_PHASE (RT_DEVICE_CTRL_BASE(PWM) + 9) |
#define | PWM_CMD_ENABLE_IRQ (RT_DEVICE_CTRL_BASE(PWM) + 10) |
#define | PWM_CMD_DISABLE_IRQ (RT_DEVICE_CTRL_BASE(PWM) + 11) |
函数 | |
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) |
rt_err_t | rt_pwm_enable (struct rt_device_pwm *device, int channel) |
rt_err_t | rt_pwm_disable (struct rt_device_pwm *device, int channel) |
rt_err_t | rt_pwm_set (struct rt_device_pwm *device, int channel, rt_uint32_t period, rt_uint32_t pulse) |
rt_err_t | rt_pwm_set_period (struct rt_device_pwm *device, int channel, rt_uint32_t period) |
rt_err_t | rt_pwm_set_pulse (struct rt_device_pwm *device, int channel, rt_uint32_t pulse) |
rt_err_t | rt_pwm_set_dead_time (struct rt_device_pwm *device, int channel, rt_uint32_t dead_time) |
rt_err_t | rt_pwm_set_phase (struct rt_device_pwm *device, int channel, rt_uint32_t phase) |
PWM driver api
Example
#define PWM_CMD_ENABLE (RT_DEVICE_CTRL_BASE(PWM) + 0) |
#define PWM_CMD_DISABLE (RT_DEVICE_CTRL_BASE(PWM) + 1) |
#define PWM_CMD_SET (RT_DEVICE_CTRL_BASE(PWM) + 2) |
#define PWM_CMD_GET (RT_DEVICE_CTRL_BASE(PWM) + 3) |
#define PWMN_CMD_ENABLE (RT_DEVICE_CTRL_BASE(PWM) + 4) |
#define PWMN_CMD_DISABLE (RT_DEVICE_CTRL_BASE(PWM) + 5) |
#define PWM_CMD_SET_PERIOD (RT_DEVICE_CTRL_BASE(PWM) + 6) |
#define PWM_CMD_SET_PULSE (RT_DEVICE_CTRL_BASE(PWM) + 7) |
#define PWM_CMD_SET_DEAD_TIME (RT_DEVICE_CTRL_BASE(PWM) + 8) |
#define PWM_CMD_SET_PHASE (RT_DEVICE_CTRL_BASE(PWM) + 9) |
#define PWM_CMD_ENABLE_IRQ (RT_DEVICE_CTRL_BASE(PWM) + 10) |
#define PWM_CMD_DISABLE_IRQ (RT_DEVICE_CTRL_BASE(PWM) + 11) |
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 ) |
register a PWM device
device | the PWM device |
name | the name of PWM device |
ops | the operations of PWM device |
user_data | the user data of PWM device |
rt_err_t rt_pwm_enable | ( | struct rt_device_pwm * | device, |
int | channel ) |
rt_err_t rt_pwm_disable | ( | struct rt_device_pwm * | device, |
int | channel ) |
rt_err_t rt_pwm_set | ( | struct rt_device_pwm * | device, |
int | channel, | ||
rt_uint32_t | period, | ||
rt_uint32_t | pulse ) |
set the PWM channel
device | the PWM device |
channel | the channel of PWM |
period | the period of PWM |
pulse | the pulse of PWM |
rt_err_t rt_pwm_set_period | ( | struct rt_device_pwm * | device, |
int | channel, | ||
rt_uint32_t | period ) |
set the PWM channel period
device | the PWM device |
channel | the channel of PWM |
period | the period of PWM |
rt_err_t rt_pwm_set_pulse | ( | struct rt_device_pwm * | device, |
int | channel, | ||
rt_uint32_t | pulse ) |
set the PWM channel pulse
device | the PWM device |
channel | the channel of PWM |
pulse | the period of PWM |
rt_err_t rt_pwm_set_dead_time | ( | struct rt_device_pwm * | device, |
int | channel, | ||
rt_uint32_t | dead_time ) |
set the dead zone time of PWM
device | the PWM device |
channel | the channel of PWM |
dead_time | dead zone time |
rt_err_t rt_pwm_set_phase | ( | struct rt_device_pwm * | device, |
int | channel, | ||
rt_uint32_t | phase ) |
set the phase of PWM
device | the PWM device |
channel | the channel of PWM |
phase | phase |