api-hal-power.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <m-string.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef enum {
  9. ApiHalPowerICCharger,
  10. ApiHalPowerICFuelGauge,
  11. } ApiHalPowerIC;
  12. /* Initialize drivers */
  13. void api_hal_power_init();
  14. /* Get predicted remaining battery capacity in percents */
  15. uint8_t api_hal_power_get_pct();
  16. /* Get charging status */
  17. bool api_hal_power_is_charging();
  18. /* Poweroff system */
  19. void api_hal_power_off();
  20. /* OTG enable */
  21. void api_hal_power_enable_otg();
  22. /* OTG disable */
  23. void api_hal_power_disable_otg();
  24. /* Get remaining battery battery capacity in mAh */
  25. uint32_t api_hal_power_get_battery_remaining_capacity();
  26. /* Get full charge battery capacity in mAh */
  27. uint32_t api_hal_power_get_battery_full_capacity();
  28. /* Get battery voltage in V */
  29. float api_hal_power_get_battery_voltage(ApiHalPowerIC ic);
  30. /* Get battery current in A */
  31. float api_hal_power_get_battery_current(ApiHalPowerIC ic);
  32. /* Get temperature in C */
  33. float api_hal_power_get_battery_temperature(ApiHalPowerIC ic);
  34. /* Get System voltage in V */
  35. float api_hal_power_get_system_voltage();
  36. /* Get USB voltage in V */
  37. float api_hal_power_get_usb_voltage();
  38. /* Get power system component state */
  39. void api_hal_power_dump_state(string_t buffer);
  40. #ifdef __cplusplus
  41. }
  42. #endif