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; diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 1033e2c998..0b3cc41699 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -139,13 +139,13 @@ static int finsh_getchar(void) #ifdef RT_USING_POSIX return getchar(); #else - int ch = 0; + char ch = 0; RT_ASSERT(shell != RT_NULL); while (rt_device_read(shell->device, -1, &ch, 1) != 1) rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER); - return ch; + return (int)ch; #endif }