api-hal-power.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 current insomnia level
  15. * @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count.
  16. */
  17. uint16_t api_hal_power_insomnia_level();
  18. /* Enter insomnia mode
  19. * Prevents device from going to sleep
  20. * @warning Internally increases insomnia level
  21. * Must be paired with api_hal_power_insomnia_exit
  22. */
  23. void api_hal_power_insomnia_enter();
  24. /* Exit insomnia mode
  25. * Allow device to go to sleep
  26. * @warning Internally decreases insomnia level.
  27. * Must be paired with api_hal_power_insomnia_enter
  28. */
  29. void api_hal_power_insomnia_exit();
  30. /* Check if deep sleep availble */
  31. bool api_hal_power_deep_available();
  32. /* Go to deep sleep */
  33. void api_hal_power_deep_sleep();
  34. /* Get predicted remaining battery capacity in percents */
  35. uint8_t api_hal_power_get_pct();
  36. /* Get battery health state in percents */
  37. uint8_t api_hal_power_get_bat_health_pct();
  38. /* Get charging status */
  39. bool api_hal_power_is_charging();
  40. /* Poweroff system */
  41. void api_hal_power_off();
  42. /* OTG enable */
  43. void api_hal_power_enable_otg();
  44. /* OTG disable */
  45. void api_hal_power_disable_otg();
  46. /* Get remaining battery battery capacity in mAh */
  47. uint32_t api_hal_power_get_battery_remaining_capacity();
  48. /* Get full charge battery capacity in mAh */
  49. uint32_t api_hal_power_get_battery_full_capacity();
  50. /* Get battery voltage in V */
  51. float api_hal_power_get_battery_voltage(ApiHalPowerIC ic);
  52. /* Get battery current in A */
  53. float api_hal_power_get_battery_current(ApiHalPowerIC ic);
  54. /* Get temperature in C */
  55. float api_hal_power_get_battery_temperature(ApiHalPowerIC ic);
  56. /* Get System voltage in V */
  57. float api_hal_power_get_system_voltage();
  58. /* Get USB voltage in V */
  59. float api_hal_power_get_usb_voltage();
  60. /* Get power system component state */
  61. void api_hal_power_dump_state(string_t buffer);
  62. #ifdef __cplusplus
  63. }
  64. #endif