sys_manager.h 4.4 KB

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