ADC.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #define ADC_Vref 33 //实际ADC参考电压3.3V,扩大成33
  12. #define ADC_V_Gain 4020 //实际 200.9 扩大2009
  13. #define ADC_Fulscale 4096 //ADC满量程值,12位,即4096
  14. #define I_sens 0.66 //实际电流传感器的灵敏度,单位是V/A,扩大成1
  15. #if SUPPORT_STM32_ADC
  16. #define A_gain 2 //电压放大倍数
  17. #else
  18. #define A_gain 3 //电压放大倍数
  19. #endif
  20. #define ADC_CH_N 8 //通道数
  21. #define ADC_Avg_N 12 //平均次数
  22. #define ADC_0_5_RCU RCU_GPIOA
  23. #define ADC_67_RCU RCU_GPIOB
  24. #define ADC_0_5_IO GPIOA
  25. #define ADC_67_IO GPIOB
  26. #define ADC_VOL 8
  27. #define ADC_ch0 GPIO_PIN_0
  28. #define ADC_ch1 GPIO_PIN_1
  29. #define ADC_ch2 GPIO_PIN_4
  30. #define ADC_ch3 GPIO_PIN_5
  31. #define ADC_ch4 GPIO_PIN_6
  32. #define ADC_ch5 GPIO_PIN_7
  33. #define ADC_ch6 GPIO_PIN_0
  34. #define ADC_ch7 GPIO_PIN_1
  35. #if SUPPORT_2_V_GA_CHN
  36. #define ADC_Vol_ch1 GPIO_PIN_2
  37. #define ADC_Vol_ch2 GPIO_PIN_3
  38. #endif
  39. void Init_ADC(void);
  40. void ConfigADCGPIO(void);
  41. void ADC_dma_config(void);
  42. void che442e_Init(void);
  43. void che442_change_ch(uint8_t channel);
  44. uint32_t DC_I_calfunction(uint16_t da,uint8_t channel);
  45. void read_adc_val(void);
  46. uint32_t read_voltage(uint8_t channel);
  47. #endif