adc.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #ifndef __ADC_H__
  12. #define __ADC_H__
  13. #include <rtthread.h>
  14. struct rt_adc_device;
  15. struct rt_adc_ops
  16. {
  17. rt_err_t (*enabled)(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
  18. rt_err_t (*convert)(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
  19. };
  20. struct rt_adc_device
  21. {
  22. struct rt_device parent;
  23. const struct rt_adc_ops *ops;
  24. };
  25. typedef struct rt_adc_device *rt_adc_device_t;
  26. typedef enum
  27. {
  28. RT_ADC_CMD_ENABLE,
  29. RT_ADC_CMD_DISABLE,
  30. } rt_adc_cmd_t;
  31. 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);
  32. rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel);
  33. rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel);
  34. rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel);
  35. #endif /* __ADC_H__ */