sys_manager.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*
  2. * Copyright (c) 2019 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file system manager interface
  8. */
  9. #ifndef _SYS_MANAGER_H
  10. #define _SYS_MANAGER_H
  11. #include <os_common_api.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. //#include <thread_timer.h>
  16. /**
  17. * @defgroup sys_manager_apis App system Manager APIs
  18. * @ingroup system_apis
  19. * @{
  20. */
  21. /**
  22. * @brief mark system ready
  23. *
  24. * @details This routine mark system ready
  25. * when system base service init finished, system app call this routine
  26. * mark system ready.
  27. *
  28. * @return N/A
  29. */
  30. void system_ready(void);
  31. /**
  32. * @brief check system is ready
  33. *
  34. * @details This routine check system is ready .
  35. *
  36. * @return false system is not ready
  37. * @return true system is ready
  38. */
  39. bool system_is_ready(void);
  40. /**
  41. * @brief system init
  42. *
  43. * @details this rontine make system init .
  44. * init system core manager and core service ,such as app_manager
  45. * srv manager and bt service .
  46. *
  47. * @param message message id want to send
  48. *
  49. * @return N/A
  50. */
  51. void system_init(void);
  52. /**
  53. * @brief system deinit
  54. *
  55. * @details this rontine make system deinit .
  56. * deinit system core manager and core service , system not ready
  57. * after call this functions.
  58. *
  59. * @return N/A
  60. */
  61. void system_deinit(void);
  62. /**
  63. * @brief restore factory config
  64. *
  65. * @details this rontine clear user property config
  66. * and used factory default config
  67. *
  68. * @return 0 success
  69. * @return others failed
  70. */
  71. int system_restore_factory_config(void);
  72. /**
  73. * @brief sys power off
  74. *
  75. * @details This routine make system power off .
  76. * first lock key and tts , exit all foreground app and background service
  77. * stop system monitor and make system power down
  78. *
  79. * @return N/A
  80. */
  81. void system_power_off(void);
  82. /**
  83. * @brief sys power reboot
  84. *
  85. * @details This routine make system power reboot .
  86. * first lock key and tts , exit all foreground app and background service
  87. * stop system monitor and make system power reboot
  88. *
  89. * @return N/A
  90. */
  91. /**
  92. * @cond INTERNAL_HIDDEN
  93. */
  94. /**
  95. * @brief return the duration after wakeup
  96. *
  97. * @details This routine get the duration atfer wake up
  98. *
  99. * @return time ms
  100. */
  101. uint32_t system_wakeup_time(void);
  102. /**
  103. * @brief return the duration after boot
  104. *
  105. * @details This routine get the duration atfer boot
  106. *
  107. * @return time ms
  108. */
  109. uint32_t system_boot_time(void);
  110. /** reboot type */
  111. enum{
  112. REBOOT_TYPE_WATCHDOG = 0x01,
  113. REBOOT_TYPE_HW_RESET = 0x02,
  114. REBOOT_TYPE_ONOFF_RESET = 0x03,
  115. REBOOT_TYPE_SF_RESET = 0x04,
  116. REBOOT_TYPE_ALARM = 0x05,
  117. };
  118. /** reboot reason */
  119. enum{
  120. REBOOT_REASON_NORMAL = 0x01,
  121. REBOOT_REASON_OTA_FINISHED = 0x02,
  122. REBOOT_REASON_FACTORY_RESTORE = 0x03,
  123. REBOOT_REASON_SYSTEM_EXCEPTION = 0x04,
  124. REBOOT_REASON_PRODUCT_FINISHED = 0x05,
  125. REBOOT_REASON_GOTO_BQB = 0x06, /* FCC -> BQB */
  126. REBOOT_REASON_GOTO_BQB_ATT = 0x07, /* ATT -> BQB */
  127. REBOOT_REASON_GOTO_PROD_CARD_ATT = 0x08, /* ATT -> CARD PRODUCT */
  128. REBOOT_REASON_CLEAR_TWS_INFO = 0x09,
  129. REBOOT_REASON_ENTER_PAIR_MODE = 0x0a,
  130. REBOOT_REASON_CHG_BOX_OPENED = 0x0b,
  131. REBOOT_REASON_PRODUCTION_TEST_CFO_ADJUST = 0xc,
  132. REBOOT_REASON_SUPER_BR_BQB = 0x0d,
  133. REBOOT_REASON_SUPER_LE_BQB = 0x0e,
  134. REBOOT_REASON_HCI_TIMEOUT = 0x0f,
  135. };
  136. /** hw reset reason */
  137. enum{
  138. HW_RESET_REASON_BAT = 0x00,
  139. HW_RESET_REASON_ONOFF_SHORT = 0x01,
  140. HW_RESET_REASON_ONOFF_LONG = 0x02,
  141. HW_RESET_REASON_WIO = 0x03,
  142. HW_RESET_REASON_REMOTE = 0x04,
  143. HW_RESET_REASON_DC5V = 0x05,
  144. };
  145. /**
  146. * @brief get reboot type and reason
  147. *
  148. * @details This routine get system reboot reason
  149. * @param reboot_type reboot type
  150. * @param reason reboot reason
  151. *
  152. * @return N/A
  153. */
  154. void system_power_get_reboot_reason(uint16_t *reboot_type, uint8_t *reason);
  155. /**
  156. * INTERNAL_HIDDEN @endcond
  157. */
  158. /**
  159. * @brief set system auto sleep timeout time
  160. *
  161. * @details This routine set system auto sleep timeout time
  162. * @param timeout timeout time, The unit is s
  163. *
  164. * @return N/A
  165. */
  166. void system_set_auto_sleep_time(uint32_t timeout);
  167. /**
  168. * @brief set system standby mode
  169. *
  170. * @details This routine set standby mode
  171. * @param sleep_mode sleep mode @see STANDBY_MODE_E
  172. *
  173. * @return N/A
  174. */
  175. void system_set_standby_mode(uint8_t sleep_mode);
  176. /**
  177. * @brief set system auto sleep timeout time
  178. *
  179. * @details This routine provide reboot system.
  180. * @param reason reason of reboot
  181. *
  182. * @return N/A
  183. */
  184. void system_power_reboot(int reason);
  185. /**
  186. * @brief system request fast to standby
  187. *
  188. * @details This routine request fast to standby
  189. *
  190. * @return N/A
  191. */
  192. void system_request_fast_standby(void);
  193. /**
  194. * @brief system clear fast to standby flag
  195. *
  196. * @details This routine clear fast to standby
  197. *
  198. * @return N/A
  199. */
  200. void system_clear_fast_standby(void);
  201. /**
  202. * @brief system check screen is on
  203. *
  204. * @details This routine return screen is on
  205. *
  206. * @return True screen on , false screen is off
  207. */
  208. bool system_is_screen_on(void);
  209. /**
  210. * @} end defgroup sys_manager_apis
  211. */
  212. #ifdef __cplusplus
  213. }
  214. #endif
  215. #endif