ADC.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*********************************************************************************************************
  2. * 模块名称:ADC.h
  3. * 摘 要:内部ADC应用,采用12bit。
  4. * 当前版本:1.0.0
  5. * 作 者:anycrying
  6. * 完成日期:2024年04月06日
  7. * 内 容:
  8. * 注 意:
  9. **********************************************************************************************************
  10. * 取代版本:
  11. * 作 者:
  12. * 完成日期:
  13. * 修改内容:
  14. * 修改文件:
  15. *********************************************************************************************************/
  16. #ifndef _ADC_H_
  17. #define _ADC_H_
  18. /*********************************************************************************************************
  19. * 包含头文件
  20. *********************************************************************************************************/
  21. #include "Main.h"
  22. #include "gd32e230x_conf.h"
  23. #include "SysTick.h"
  24. #include "ADC.h"
  25. #include "board_cnf.h"
  26. /*********************************************************************************************************
  27. * 宏定义
  28. *********************************************************************************************************/
  29. #define ADC_Vref 33 //实际ADC参考电压3.3V,扩大成33
  30. #define ADC_V_Gain 4020 //实际 200.9 扩大2009
  31. #define ADC_Fulscale 4096 //ADC满量程值,12位,即4096
  32. #define I_sens 0.66 //实际电流传感器的灵敏度,单位是V/A,扩大成1
  33. #if SUPPORT_STM32_ADC
  34. #define A_gain 2 //电压放大倍数
  35. #else
  36. #define A_gain 3 //电压放大倍数
  37. #endif
  38. #define ADC_CH_N 8 //通道数
  39. #define ADC_Avg_N 12 //平均次数
  40. #define ADC_0_5_RCU RCU_GPIOA
  41. #define ADC_67_RCU RCU_GPIOB
  42. #define ADC_0_5_IO GPIOA
  43. #define ADC_67_IO GPIOB
  44. #define ADC_VOL 8
  45. #define ADC_ch0 GPIO_PIN_0
  46. #define ADC_ch1 GPIO_PIN_1
  47. #define ADC_ch2 GPIO_PIN_4
  48. #define ADC_ch3 GPIO_PIN_5
  49. #define ADC_ch4 GPIO_PIN_6
  50. #define ADC_ch5 GPIO_PIN_7
  51. #define ADC_ch6 GPIO_PIN_0
  52. #define ADC_ch7 GPIO_PIN_1
  53. #if SUPPORT_2_V_GA_CHN
  54. #define ADC_Vol_ch1 GPIO_PIN_2
  55. #define ADC_Vol_ch2 GPIO_PIN_3
  56. #endif
  57. /*********************************************************************************************************
  58. * 内部函数声明
  59. *********************************************************************************************************/
  60. void Init_ADC(void);
  61. void ConfigADCGPIO(void);
  62. void ADC_dma_config(void);
  63. uint32_t DC_I_calfunction(uint16_t da,uint8_t channel);
  64. #if SUPPORT_2_V_GA_CHN
  65. uint32_t DC_V_calfunction(uint16_t va);
  66. #endif
  67. void read_adc_val(void);
  68. #endif