furi-hal-power.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /**
  2. * @file furi-hal-power.h
  3. * Power HAL API
  4. */
  5. #pragma once
  6. #include <stdint.h>
  7. #include <stdbool.h>
  8. #include <m-string.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /** Power IC type */
  13. typedef enum {
  14. FuriHalPowerICCharger,
  15. FuriHalPowerICFuelGauge,
  16. } FuriHalPowerIC;
  17. /** Initialize drivers
  18. */
  19. void furi_hal_power_init();
  20. /** Get current insomnia level
  21. *
  22. * @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count.
  23. */
  24. uint16_t furi_hal_power_insomnia_level();
  25. /** Enter insomnia mode Prevents device from going to sleep
  26. * @warning Internally increases insomnia level Must be paired with
  27. * furi_hal_power_insomnia_exit
  28. */
  29. void furi_hal_power_insomnia_enter();
  30. /** Exit insomnia mode Allow device to go to sleep
  31. * @warning Internally decreases insomnia level. Must be paired with
  32. * furi_hal_power_insomnia_enter
  33. */
  34. void furi_hal_power_insomnia_exit();
  35. /** Check if sleep availble
  36. *
  37. * @return true if available
  38. */
  39. bool furi_hal_power_sleep_available();
  40. /** Check if deep sleep availble
  41. *
  42. * @return true if available
  43. */
  44. bool furi_hal_power_deep_sleep_available();
  45. /** Go to sleep
  46. */
  47. void furi_hal_power_sleep();
  48. /** Get predicted remaining battery capacity in percents
  49. *
  50. * @return remaining battery capacity in percents
  51. */
  52. uint8_t furi_hal_power_get_pct();
  53. /** Get battery health state in percents
  54. *
  55. * @return health in percents
  56. */
  57. uint8_t furi_hal_power_get_bat_health_pct();
  58. /** Get charging status
  59. *
  60. * @return true if charging
  61. */
  62. bool furi_hal_power_is_charging();
  63. /** Poweroff device
  64. */
  65. void furi_hal_power_off();
  66. /** Reset device
  67. */
  68. void furi_hal_power_reset();
  69. /** OTG enable
  70. */
  71. void furi_hal_power_enable_otg();
  72. /** OTG disable
  73. */
  74. void furi_hal_power_disable_otg();
  75. /** Get OTG status
  76. *
  77. * @return true if enabled
  78. */
  79. bool furi_hal_power_is_otg_enabled();
  80. /** Get remaining battery battery capacity in mAh
  81. *
  82. * @return capacity in mAh
  83. */
  84. uint32_t furi_hal_power_get_battery_remaining_capacity();
  85. /** Get full charge battery capacity in mAh
  86. *
  87. * @return capacity in mAh
  88. */
  89. uint32_t furi_hal_power_get_battery_full_capacity();
  90. /** Get battery voltage in V
  91. *
  92. * @param ic FuriHalPowerIc to get measurment
  93. *
  94. * @return voltage in V
  95. */
  96. float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic);
  97. /** Get battery current in A
  98. *
  99. * @param ic FuriHalPowerIc to get measurment
  100. *
  101. * @return current in A
  102. */
  103. float furi_hal_power_get_battery_current(FuriHalPowerIC ic);
  104. /** Get temperature in C
  105. *
  106. * @param ic FuriHalPowerIc to get measurment
  107. *
  108. * @return temperature in C
  109. */
  110. float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic);
  111. /** Get System voltage in V
  112. *
  113. * @return voltage in V
  114. */
  115. float furi_hal_power_get_system_voltage();
  116. /** Get USB voltage in V
  117. *
  118. * @return voltage in V
  119. */
  120. float furi_hal_power_get_usb_voltage();
  121. /** Get power system component state
  122. */
  123. void furi_hal_power_dump_state();
  124. /** Enable 3.3v on external gpio and sd card
  125. */
  126. void furi_hal_power_enable_external_3_3v();
  127. /** Disable 3.3v on external gpio and sd card
  128. */
  129. void furi_hal_power_disable_external_3_3v();
  130. /** Enter supress charge mode.
  131. *
  132. * Use this function when your application need clean power supply.
  133. */
  134. void furi_hal_power_suppress_charge_enter();
  135. /** Exit supress charge mode
  136. */
  137. void furi_hal_power_suppress_charge_exit();
  138. #ifdef __cplusplus
  139. }
  140. #endif