adc_config.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. * 2025-05-28 RTT the first version
  9. */
  10. #ifndef __ADC_CONFIG_H__
  11. #define __ADC_CONFIG_H__
  12. #include <rtthread.h>
  13. #include <rtdevice.h>
  14. #include "drv_common.h"
  15. #include "cyhal.h"
  16. #include "cybsp.h"
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif
  21. #if defined(BSP_USING_ADC1) || defined(BSP_USING_ADC2)
  22. cyhal_adc_t adc_obj;
  23. cyhal_adc_channel_t adc_chan_obj;
  24. const cyhal_adc_config_t adc_config = {
  25. .continuous_scanning = false, // Continuous Scanning is disabled
  26. .average_count = 1, // Average count disabled
  27. .vref = CYHAL_ADC_REF_VDDA, // VREF for Single ended channel set to VDDA
  28. .vneg = CYHAL_ADC_VNEG_VSSA, // VNEG for Single ended channel set to VSSA
  29. .resolution = 12u, // 12-bit resolution
  30. .ext_vref = NC, // No connection
  31. .bypass_pin = NC // No connection
  32. };
  33. struct ifx_adc
  34. {
  35. struct rt_adc_device ifx_adc_device;
  36. cyhal_adc_channel_t *adc_ch;
  37. char *name;
  38. };
  39. const cyhal_gpio_t adc_gpio[8] = {P14_0, P14_1, P14_2, P14_3, P14_4, P14_5, P14_6, P14_7};
  40. #ifndef ADC1_CONFIG
  41. #define ADC1_CONFIG \
  42. { \
  43. .adc_ch = &adc_chan_obj, \
  44. .name = "adc1", \
  45. }
  46. #endif
  47. #endif /* defined(BSP_USING_ADC1) || defined(BSP_USING_ADC2) */
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif /* __ADC_CONFIG_H__ */