drv_adc.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-03-28 shelton first version
  9. */
  10. #ifndef __ADC_CONFIG_H__
  11. #define __ADC_CONFIG_H__
  12. #include <rtthread.h>
  13. #include "cyhal.h"
  14. #include "cybsp.h"
  15. #ifdef __cplusplus
  16. extern "C"
  17. {
  18. #endif
  19. #if defined(BSP_USING_ADC1) || defined(BSP_USING_ADC2)
  20. cyhal_adc_t adc_obj;
  21. cyhal_adc_channel_t adc_chan_obj;
  22. const cyhal_adc_config_t adc_config =
  23. {
  24. .continuous_scanning = false, // Continuous Scanning is disabled
  25. .average_count = 1, // Average count disabled
  26. .vref = CYHAL_ADC_REF_VDDA, // VREF for Single ended channel set to VDDA
  27. .vneg = CYHAL_ADC_VNEG_VSSA, // VNEG for Single ended channel set to VSSA
  28. .resolution = 12u, // 12-bit resolution
  29. .ext_vref = NC, // No connection
  30. .bypass_pin = NC // No connection
  31. };
  32. #ifndef ADC1_CONFIG
  33. #define ADC1_CONFIG \
  34. { \
  35. .adc_ch = &adc_chan_obj, \
  36. .name = "adc1", \
  37. }
  38. #endif /* ADC1_CONFIG */
  39. #endif
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* __ADC_CONFIG_H__ */