vbat.h 945 B

12345678910111213141516171819202122232425262728
  1. #ifndef VBAT_H
  2. #define VBAT_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #define VBAT_INVALID_VALUE ((uint32_t)(-1))
  6. typedef struct
  7. {
  8. bool (*Init)();
  9. void (*SetMeasureInterval)(uint32_t ms);
  10. bool (*ServeMonitor)();
  11. uint32_t (*GetVoltage)();
  12. void (*DeInit)();
  13. }
  14. sVBat_Handle_t;
  15. extern const sVBat_Handle_t VBatHandle;
  16. #define VBAT_MONITOR_INTERVAL 10000 // [ms]
  17. #define VBAT_MONITOR_MEAS_TIMEOUT 5 // [ms], ADC is running is High-priority fast mode, 5ms is enough
  18. #define VBAT_INIT_FOR_MEASURE 1 // 0/1, initialize VBAT sensing circuit for single measure
  19. #define VBAT_AVERAGING_POINTS 3 // Number measurements for averaging the result, set to zero to disable
  20. #define VBAT_AVERAGING_INTERVAL 100 // interval in [ms] between measurements while averaging
  21. #define VBAT_VOLTAGE_MULTIPLIER 2
  22. #define VBAT_VOLTAGE_DIVIDER 1
  23. #endif