rt_device_pwm 不符合rtt device命名习惯,改为rt_pwm_device
This commit is contained in:
@ -35,24 +35,24 @@ struct rt_pwm_configuration
|
||||
rt_bool_t complementary;
|
||||
};
|
||||
|
||||
struct rt_device_pwm;
|
||||
struct rt_pwm_device;
|
||||
struct rt_pwm_ops
|
||||
{
|
||||
rt_err_t (*control)(struct rt_device_pwm *device, int cmd, void *arg);
|
||||
rt_err_t (*control)(struct rt_pwm_device *device, int cmd, void *arg);
|
||||
};
|
||||
|
||||
struct rt_device_pwm
|
||||
struct rt_pwm_device
|
||||
{
|
||||
struct rt_device parent;
|
||||
const struct rt_pwm_ops *ops;
|
||||
};
|
||||
|
||||
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_device_register(struct rt_pwm_device *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_enable(struct rt_pwm_device *device, int channel);
|
||||
rt_err_t rt_pwm_disable(struct rt_pwm_device *device, int channel);
|
||||
rt_err_t rt_pwm_set(struct rt_pwm_device *device, int channel, rt_uint32_t period, rt_uint32_t pulse);
|
||||
rt_err_t rt_pwm_set_period(struct rt_pwm_device *device, int channel, rt_uint32_t period);
|
||||
rt_err_t rt_pwm_set_pulse(struct rt_pwm_device *device, int channel, rt_uint32_t pulse);
|
||||
|
||||
#endif /* __DRV_PWM_H_INCLUDE__ */
|
||||
|
@ -15,7 +15,7 @@
|
||||
static rt_err_t _pwm_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device_pwm *pwm = (struct rt_device_pwm *)dev;
|
||||
struct rt_pwm_device *pwm = (struct rt_pwm_device *)dev;
|
||||
|
||||
if (pwm->ops->control)
|
||||
{
|
||||
@ -34,7 +34,7 @@ size : number of pulse, only set to sizeof(rt_uint32_t).
|
||||
static rt_size_t _pwm_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device_pwm *pwm = (struct rt_device_pwm *)dev;
|
||||
struct rt_pwm_device *pwm = (struct rt_pwm_device *)dev;
|
||||
rt_uint32_t *pulse = (rt_uint32_t *)buffer;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
|
||||
@ -62,7 +62,7 @@ size : number of pulse, only set to sizeof(rt_uint32_t).
|
||||
static rt_size_t _pwm_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device_pwm *pwm = (struct rt_device_pwm *)dev;
|
||||
struct rt_pwm_device *pwm = (struct rt_pwm_device *)dev;
|
||||
rt_uint32_t *pulse = (rt_uint32_t *)buffer;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
|
||||
@ -100,11 +100,11 @@ static const struct rt_device_ops pwm_device_ops =
|
||||
};
|
||||
#endif /* RT_USING_DEVICE_OPS */
|
||||
|
||||
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_device_register(struct rt_pwm_device *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
rt_memset(device, 0, sizeof(struct rt_device_pwm));
|
||||
rt_memset(device, 0, sizeof(struct rt_pwm_device));
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
device->parent.ops = &pwm_device_ops;
|
||||
@ -126,7 +126,7 @@ rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name,
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_pwm_enable(struct rt_device_pwm *device, int channel)
|
||||
rt_err_t rt_pwm_enable(struct rt_pwm_device *device, int channel)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
@ -143,7 +143,7 @@ rt_err_t rt_pwm_enable(struct rt_device_pwm *device, int channel)
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_pwm_disable(struct rt_device_pwm *device, int channel)
|
||||
rt_err_t rt_pwm_disable(struct rt_pwm_device *device, int channel)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
@ -160,7 +160,7 @@ rt_err_t rt_pwm_disable(struct rt_device_pwm *device, int channel)
|
||||
return result;
|
||||
}
|
||||
|
||||
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(struct rt_pwm_device *device, int channel, rt_uint32_t period, rt_uint32_t pulse)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
@ -178,7 +178,7 @@ rt_err_t rt_pwm_set(struct rt_device_pwm *device, int channel, rt_uint32_t perio
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_pwm_set_period(struct rt_device_pwm *device, int channel, rt_uint32_t period)
|
||||
rt_err_t rt_pwm_set_period(struct rt_pwm_device *device, int channel, rt_uint32_t period)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
@ -195,7 +195,7 @@ rt_err_t rt_pwm_set_period(struct rt_device_pwm *device, int channel, rt_uint32_
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_pwm_set_pulse(struct rt_device_pwm *device, int channel, rt_uint32_t pulse)
|
||||
rt_err_t rt_pwm_set_pulse(struct rt_pwm_device *device, int channel, rt_uint32_t pulse)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
@ -212,7 +212,7 @@ rt_err_t rt_pwm_set_pulse(struct rt_device_pwm *device, int channel, rt_uint32_t
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg)
|
||||
rt_err_t rt_pwm_get(struct rt_pwm_device *device, struct rt_pwm_configuration *cfg)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
@ -235,7 +235,7 @@ static int pwm(int argc, char **argv)
|
||||
{
|
||||
rt_err_t result = -RT_ERROR;
|
||||
char *result_str;
|
||||
static struct rt_device_pwm *pwm_device = RT_NULL;
|
||||
static struct rt_pwm_device *pwm_device = RT_NULL;
|
||||
struct rt_pwm_configuration cfg = {0};
|
||||
|
||||
if(argc > 1)
|
||||
@ -244,7 +244,7 @@ static int pwm(int argc, char **argv)
|
||||
{
|
||||
if(argc == 3)
|
||||
{
|
||||
pwm_device = (struct rt_device_pwm *)rt_device_find(argv[2]);
|
||||
pwm_device = (struct rt_pwm_device *)rt_device_find(argv[2]);
|
||||
result_str = (pwm_device == RT_NULL) ? "failure" : "success";
|
||||
rt_kprintf("probe %s %s\n", argv[2], result_str);
|
||||
}
|
||||
|
Reference in New Issue
Block a user