drv_adc.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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-08-18 guohp1128 the first version
  9. */
  10. #ifndef __DRV_ADC_H__
  11. #define __DRV_ADC_H__
  12. #include <board.h>
  13. #include "rtdevice.h"
  14. #include <hal/nrf_saadc.h>
  15. #include <drivers/include/nrfx_saadc.h>
  16. #define ADC_NAME "adc"
  17. /*
  18. previous definition in application
  19. set single-ended mode or differential mode.
  20. selection ADC input pin, and config the number of Channel.
  21. mode: 0 single-ended mode,1 differential mode
  22. pin_p: 0-7
  23. pin_n: 0-7,if single-ended mode, pin_n invalid
  24. channel_num: 0-7
  25. */
  26. typedef struct
  27. {
  28. nrf_saadc_mode_t mode; ///< SAADC mode. Single-ended or differential.
  29. uint8_t pin_p; ///< Input positive pin selection.
  30. uint8_t pin_n; ///< Input negative pin selection.
  31. uint8_t channel_num; ///< Channel number.
  32. } drv_nrfx_saadc_channel_t;
  33. typedef struct
  34. {
  35. nrfx_saadc_channel_t channels[8];
  36. uint8_t channel_count;
  37. nrf_saadc_value_t result_buffer[8];
  38. uint8_t done;
  39. } drv_nrfx_saadc_result_t;
  40. #endif /* __DRV_ADC_H__ */