drv_adc.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2006-2025, 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__ */