ADC.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /*********************************************************************************************************
  26. * 宏定义
  27. *********************************************************************************************************/
  28. #define ADC_Vref 33 //实际ADC参考电压3.3V,扩大成33
  29. #define ADC_V_Gain 4020 //实际 200.9 扩大2009
  30. #define ADC_Fulscale 4096 //ADC满量程值,12位,即4096
  31. #define I_sens 1 //实际电流传感器的灵敏度,单位是V/A,扩大成1
  32. #define A_gain 3 //电压放大倍数
  33. #define ADC_CH_N 8 //通道数
  34. #define ADC_Avg_N 12 //平均次数
  35. #define ADC_0_5_RCU RCU_GPIOA
  36. #define ADC_67_RCU RCU_GPIOB
  37. #define ADC_0_5_IO GPIOA
  38. #define ADC_67_IO GPIOB
  39. #define ADC_ch0 GPIO_PIN_0
  40. #define ADC_ch1 GPIO_PIN_1
  41. #define ADC_ch2 GPIO_PIN_4
  42. #define ADC_ch3 GPIO_PIN_5
  43. #define ADC_ch4 GPIO_PIN_6
  44. #define ADC_ch5 GPIO_PIN_7
  45. #define ADC_ch6 GPIO_PIN_0
  46. #define ADC_ch7 GPIO_PIN_1
  47. #if NO_USE_IM1253E
  48. #define ADC_Vol_ch1 GPIO_PIN_2
  49. #define ADC_Vol_ch2 GPIO_PIN_3
  50. #endif
  51. /*********************************************************************************************************
  52. * 内部函数声明
  53. *********************************************************************************************************/
  54. void Init_ADC(void);
  55. void ConfigADCGPIO(void);
  56. void ADC_dma_config(void);
  57. uint32_t DC_I_calfunction(uint16_t da);
  58. uint32_t DC_V_calfunction(uint16_t va);
  59. void read_adc_val(void);
  60. #endif