dac.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-06-19 thread-liu the first version
  9. */
  10. #ifndef __DAC_H__
  11. #define __DAC_H__
  12. #include <rtthread.h>
  13. struct rt_dac_device;
  14. struct rt_dac_ops
  15. {
  16. rt_err_t (*disabled)(struct rt_dac_device *device, rt_uint32_t channel);
  17. rt_err_t (*enabled)(struct rt_dac_device *device, rt_uint32_t channel);
  18. rt_err_t (*convert)(struct rt_dac_device *device, rt_uint32_t channel, rt_uint32_t *value);
  19. };
  20. struct rt_dac_device
  21. {
  22. struct rt_device parent;
  23. const struct rt_dac_ops *ops;
  24. };
  25. typedef struct rt_dac_device *rt_dac_device_t;
  26. typedef enum
  27. {
  28. RT_DAC_CMD_ENABLE,
  29. RT_DAC_CMD_DISABLE,
  30. } rt_dac_cmd_t;
  31. rt_err_t rt_hw_dac_register(rt_dac_device_t dac,const char *name, const struct rt_dac_ops *ops, const void *user_data);
  32. rt_uint32_t rt_dac_write(rt_dac_device_t dev, rt_uint32_t channel, rt_uint32_t value);
  33. rt_err_t rt_dac_enable(rt_dac_device_t dev, rt_uint32_t channel);
  34. rt_err_t rt_dac_disable(rt_dac_device_t dev, rt_uint32_t channel);
  35. #endif /* __dac_H__ */