adc.h 481 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __ADC_H
  2. #define __ADC_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define ADC_FILTER_LEN 20
  7. typedef struct {
  8. float sum;
  9. uint8_t head;
  10. uint8_t count;
  11. float buf[ADC_FILTER_LEN];
  12. } ADC_FILTER_t;
  13. //
  14. void adc_init(void);
  15. //
  16. void adc_dma_init(ADC_HandleTypeDef *hadc);
  17. //
  18. float adc_get_bat_voltage(void);
  19. //
  20. float adc_average(ADC_FILTER_t *flt, float new_value);
  21. //
  22. void adc_task(void);
  23. //
  24. void adc_print_data(void);
  25. #ifdef __cplusplus
  26. }
  27. #endif
  28. #endif