furi_hal_power.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. /** Check OTG status and disable it if falt happened
  76. */
  77. void furi_hal_power_check_otg_status();
  78. /** Get OTG status
  79. *
  80. * @return true if enabled
  81. */
  82. bool furi_hal_power_is_otg_enabled();
  83. /** Get remaining battery battery capacity in mAh
  84. *
  85. * @return capacity in mAh
  86. */
  87. uint32_t furi_hal_power_get_battery_remaining_capacity();
  88. /** Get full charge battery capacity in mAh
  89. *
  90. * @return capacity in mAh
  91. */
  92. uint32_t furi_hal_power_get_battery_full_capacity();
  93. /** Get battery voltage in V
  94. *
  95. * @param ic FuriHalPowerIc to get measurment
  96. *
  97. * @return voltage in V
  98. */
  99. float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic);
  100. /** Get battery current in A
  101. *
  102. * @param ic FuriHalPowerIc to get measurment
  103. *
  104. * @return current in A
  105. */
  106. float furi_hal_power_get_battery_current(FuriHalPowerIC ic);
  107. /** Get temperature in C
  108. *
  109. * @param ic FuriHalPowerIc to get measurment
  110. *
  111. * @return temperature in C
  112. */
  113. float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic);
  114. /** Get System voltage in V
  115. *
  116. * @return voltage in V
  117. */
  118. float furi_hal_power_get_system_voltage();
  119. /** Get USB voltage in V
  120. *
  121. * @return voltage in V
  122. */
  123. float furi_hal_power_get_usb_voltage();
  124. /** Get power system component state
  125. */
  126. void furi_hal_power_dump_state();
  127. /** Enable 3.3v on external gpio and sd card
  128. */
  129. void furi_hal_power_enable_external_3_3v();
  130. /** Disable 3.3v on external gpio and sd card
  131. */
  132. void furi_hal_power_disable_external_3_3v();
  133. /** Enter supress charge mode.
  134. *
  135. * Use this function when your application need clean power supply.
  136. */
  137. void furi_hal_power_suppress_charge_enter();
  138. /** Exit supress charge mode
  139. */
  140. void furi_hal_power_suppress_charge_exit();
  141. #ifdef __cplusplus
  142. }
  143. #endif