ADC.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _ADC_H_
  2. #define _ADC_H_
  3. /*********************************************************************************************************
  4. * 包含头文件
  5. *********************************************************************************************************/
  6. #include "Main.h"
  7. #include "gd32e23x.h"
  8. #include "SysTick.h"
  9. #include "ADC.h"
  10. #include "board_cfg.h"
  11. /*********************************************************************************************************
  12. * 宏定义
  13. *********************************************************************************************************/
  14. #define ADC_Vref 33 //实际ADC参考电压3.3V,扩大成33
  15. #define ADC_V_Gain 4020 //实际 200.9 扩大2009
  16. #define ADC_Fulscale 4096 //ADC满量程值,12位,即4096
  17. #define I_sens 0.66 //实际电流传感器的灵敏度,单位是V/A,扩大成1
  18. #define A_gain 2 //电压放大倍数
  19. #define ADC_CH_N 8 //通道数
  20. #define ADC_Avg_N 12 //平均次数
  21. #define ADC_0_5_RCU RCU_GPIOA
  22. #define ADC_67_RCU RCU_GPIOB
  23. #define ADC_0_5_IO GPIOA
  24. #define ADC_67_IO GPIOB
  25. #define ADC_ch0 GPIO_PIN_0
  26. #define ADC_ch1 GPIO_PIN_1
  27. #define ADC_ch2 GPIO_PIN_4
  28. #define ADC_ch3 GPIO_PIN_5
  29. #define ADC_ch4 GPIO_PIN_6
  30. #define ADC_ch5 GPIO_PIN_7
  31. #define ADC_ch6 GPIO_PIN_0
  32. #define ADC_ch7 GPIO_PIN_1
  33. /*********************************************************************************************************
  34. * 内部函数声明
  35. *********************************************************************************************************/
  36. void Init_ADC(void);
  37. void ConfigADCGPIO(void);
  38. void ADC_dma_config(void);
  39. void che442e_Init(void);
  40. void che442_change_ch(uint8_t channel);
  41. uint32_t DC_I_calfunction(uint16_t da,uint8_t channel);
  42. void read_adc_val(void);
  43. uint32_t read_voltage(uint8_t channel);
  44. #endif