1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2018-05-07 aozima the first version 9 * 2018-11-16 Ernest Chen add finsh command and update adc function 10 */ 11 12 #ifndef __ADC_H__ 13 #define __ADC_H__ 14 #include <rtthread.h> 15 16 struct rt_adc_device; 17 struct rt_adc_ops 18 { 19 rt_err_t (*enabled)(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled); 20 rt_err_t (*convert)(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value); 21 }; 22 23 struct rt_adc_device 24 { 25 struct rt_device parent; 26 const struct rt_adc_ops *ops; 27 }; 28 typedef struct rt_adc_device *rt_adc_device_t; 29 30 typedef enum 31 { 32 RT_ADC_CMD_ENABLE, 33 RT_ADC_CMD_DISABLE, 34 } rt_adc_cmd_t; 35 36 rt_err_t rt_hw_adc_register(rt_adc_device_t adc,const char *name, const struct rt_adc_ops *ops, const void *user_data); 37 38 rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel); 39 rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel); 40 rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel); 41 42 #endif /* __ADC_H__ */ 43