diff options
| author | aozima <[email protected]> | 2018-11-24 17:23:12 +0800 |
|---|---|---|
| committer | aozima <[email protected]> | 2018-11-24 17:29:50 +0800 |
| commit | 669eb13ed97a7e6573dc8f2467c25d8728709abe (patch) | |
| tree | e0b4dbe9023e1edfc71b72e49cdfcf72fc318b31 | |
| parent | 37dc32a8967e0b1185d9c27dd91f49492a8af579 (diff) | |
[DeviceDriver] update RT_USING_DEVICE_OPS.
1. fixed audio_pipe.c compile error.
2. update pwm driver: support RT_USING_DEVICE_OPS.
| -rw-r--r-- | components/drivers/audio/audio_pipe.c | 2 | ||||
| -rw-r--r-- | components/drivers/misc/rt_drv_pwm.c | 31 |
2 files changed, 24 insertions, 9 deletions
diff --git a/components/drivers/audio/audio_pipe.c b/components/drivers/audio/audio_pipe.c index 242305e204..a372ae0625 100644 --- a/components/drivers/audio/audio_pipe.c +++ b/components/drivers/audio/audio_pipe.c @@ -188,7 +188,7 @@ static rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args) } #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, diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c index 6890e0e793..2b7986b4d8 100644 --- a/components/drivers/misc/rt_drv_pwm.c +++ b/components/drivers/misc/rt_drv_pwm.c @@ -88,21 +88,36 @@ static rt_size_t _pwm_write(rt_device_t dev, rt_off_t pos, const void *buffer, r 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 result = RT_EOK; memset(device, 0, sizeof(struct rt_device_pwm)); - device->parent.type = RT_Device_Class_Miscellaneous; - - device->parent.init = RT_NULL; - device->parent.open = RT_NULL; - device->parent.close = RT_NULL; - device->parent.read = _pwm_read; - device->parent.write = _pwm_write; - device->parent.control = _pwm_control; +#ifdef RT_USING_DEVICE_OPS + device->parent.ops = &pwm_device_ops; +#else + device->parent.init = RT_NULL; + device->parent.open = RT_NULL; + device->parent.close = RT_NULL; + device->parent.read = _pwm_read; + 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->parent.user_data = (void *)user_data; |
