drv_adc.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2006-2020, 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. /*
  17. previous definition in application
  18. set single-ended mode or differential mode.
  19. selection ADC input pin, and config the number of Channel.
  20. mode: 0 single-ended mode,1 differential mode
  21. pin_p: 0-7
  22. pin_n: 0-7,if single-ended mode, pin_n invalid
  23. channel_num: 0-7
  24. */
  25. typedef struct
  26. {
  27. nrf_saadc_mode_t mode; ///< SAADC mode. Single-ended or differential.
  28. uint8_t pin_p; ///< Input positive pin selection.
  29. uint8_t pin_n; ///< Input negative pin selection.
  30. uint8_t channel_num; ///< Channel number.
  31. } drv_nrfx_saadc_channel_t;
  32. typedef struct
  33. {
  34. nrfx_saadc_channel_t channels[8];
  35. uint8_t channel_count;
  36. nrf_saadc_value_t result_buffer[8];
  37. uint8_t done;
  38. } drv_nrfx_saadc_result_t;
  39. #endif /* __DRV_ADC_H__ */