From 97c930cd657561dd243dd47bc71e736c61a58a7b Mon Sep 17 00:00:00 2001 From: misonyo Date: Sat, 23 Mar 2019 09:47:45 +0800 Subject: [components]add rt_device_ops for adc device and fix finsh_getchar() return wrong value in Big-endian status. --- components/drivers/misc/adc.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'components/drivers/misc') diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c index b2fd9ba430..fec4f736e0 100644 --- a/components/drivers/misc/adc.c +++ b/components/drivers/misc/adc.c @@ -60,19 +60,37 @@ static rt_err_t _adc_control(rt_device_t dev, int cmd, void *args) return result; } +#ifdef RT_USING_DEVICE_OPS +const static struct rt_device_ops adc_ops = +{ + RT_NULL, + RT_NULL, + RT_NULL, + _adc_read, + RT_NULL, + _adc_control, +}; +#endif + rt_err_t rt_hw_adc_register(rt_adc_device_t device, const char *name, const struct rt_adc_ops *ops, const void *user_data) { rt_err_t result = RT_EOK; RT_ASSERT(ops != RT_NULL && ops->convert != RT_NULL); 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 = _adc_read; - device->parent.write = RT_NULL; - device->parent.control = _adc_control; - + device->parent.rx_indicate = RT_NULL; + device->parent.tx_complete = RT_NULL; + +#ifdef RT_USING_DEVICE_OPS + device->parent.ops = &adc_ops; +#else + device->parent.init = RT_NULL; + device->parent.open = RT_NULL; + device->parent.close = RT_NULL; + device->parent.read = _adc_read; + device->parent.write = RT_NULL; + device->parent.control = _adc_control; +#endif device->ops = ops; device->parent.user_data = (void *)user_data; -- cgit v1.3.1