未验证 提交 3f55d915 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #2008 from aozima/rt_device_ops

[DeviceDriver] update RT_USING_DEVICE_OPS.
...@@ -188,7 +188,7 @@ static rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args) ...@@ -188,7 +188,7 @@ static rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args)
} }
#ifdef RT_USING_DEVICE_OPS #ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops audio_pipe_ops const static struct rt_device_ops audio_pipe_ops =
{ {
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
......
...@@ -88,21 +88,36 @@ static rt_size_t _pwm_write(rt_device_t dev, rt_off_t pos, const void *buffer, r ...@@ -88,21 +88,36 @@ static rt_size_t _pwm_write(rt_device_t dev, rt_off_t pos, const void *buffer, r
return size; return size;
} }
#ifdef RT_USING_DEVICE_OPS
static const struct rt_device_ops pwm_device_ops =
{
RT_NULL,
RT_NULL,
RT_NULL,
_pwm_read,
_pwm_write,
_pwm_control
};
#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_device_pwm_register(struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data)
{ {
rt_err_t result = RT_EOK; rt_err_t result = RT_EOK;
memset(device, 0, sizeof(struct rt_device_pwm)); memset(device, 0, sizeof(struct rt_device_pwm));
device->parent.type = RT_Device_Class_Miscellaneous; #ifdef RT_USING_DEVICE_OPS
device->parent.ops = &pwm_device_ops;
device->parent.init = RT_NULL; #else
device->parent.open = RT_NULL; device->parent.init = RT_NULL;
device->parent.close = RT_NULL; device->parent.open = RT_NULL;
device->parent.read = _pwm_read; device->parent.close = RT_NULL;
device->parent.write = _pwm_write; device->parent.read = _pwm_read;
device->parent.control = _pwm_control; device->parent.write = _pwm_write;
device->parent.control = _pwm_control;
#endif /* RT_USING_DEVICE_OPS */
device->parent.type = RT_Device_Class_Miscellaneous;
device->ops = ops; device->ops = ops;
device->parent.user_data = (void *)user_data; device->parent.user_data = (void *)user_data;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册