drv_adc.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-5-26 lik first version
  9. */
  10. #ifndef __DRV_ADC_H__
  11. #define __DRV_ADC_H__
  12. #include "board.h"
  13. struct swm_adc_cfg
  14. {
  15. const char *name;
  16. ADC_TypeDef *ADCx;
  17. ADC_InitStructure adc_initstruct;
  18. };
  19. struct swm_adc
  20. {
  21. struct swm_adc_cfg *cfg;
  22. struct rt_adc_device adc_device;
  23. };
  24. #ifdef BSP_USING_ADC0
  25. #ifndef ADC0_CFG
  26. #define ADC0_CFG \
  27. { \
  28. .name = "adc0", \
  29. .ADCx = ADC0, \
  30. .adc_initstruct.clk_src = ADC_CLKSRC_VCO_DIV64, \
  31. .adc_initstruct.clk_div = 25, \
  32. .adc_initstruct.pga_ref = PGA_REF_INTERNAL, \
  33. .adc_initstruct.channels = 0, \
  34. .adc_initstruct.samplAvg = ADC_AVG_SAMPLE1, \
  35. .adc_initstruct.trig_src = ADC_TRIGSRC_SW, \
  36. .adc_initstruct.Continue = 0, \
  37. .adc_initstruct.EOC_IEn = 0, \
  38. .adc_initstruct.OVF_IEn = 0, \
  39. .adc_initstruct.HFULL_IEn = 0, \
  40. .adc_initstruct.FULL_IEn = 0, \
  41. }
  42. #endif /* ADC0_CFG */
  43. #endif /* BSP_USING_ADC0 */
  44. #ifdef BSP_USING_ADC1
  45. #ifndef ADC1_CFG
  46. #define ADC1_CFG \
  47. { \
  48. .name = "adc1", \
  49. .ADCx = ADC1, \
  50. .adc_initstruct.clk_src = ADC_CLKSRC_VCO_DIV64, \
  51. .adc_initstruct.clk_div = 25, \
  52. .adc_initstruct.pga_ref = PGA_REF_INTERNAL, \
  53. .adc_initstruct.channels = 0, \
  54. .adc_initstruct.samplAvg = ADC_AVG_SAMPLE1, \
  55. .adc_initstruct.trig_src = ADC_TRIGSRC_SW, \
  56. .adc_initstruct.Continue = 0, \
  57. .adc_initstruct.EOC_IEn = 0, \
  58. .adc_initstruct.OVF_IEn = 0, \
  59. .adc_initstruct.HFULL_IEn = 0, \
  60. .adc_initstruct.FULL_IEn = 0, \
  61. }
  62. #endif /* ADC1_CFG */
  63. #endif /* BSP_USING_ADC1 */
  64. #endif /* __DRV_ADC_H__ */