esp_system.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_SYSTEM_H__
  14. #define __ESP_SYSTEM_H__
  15. #include <stdint.h>
  16. #include "esp_err.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /** \defgroup System_APIs System APIs
  21. * @brief System APIs
  22. */
  23. /** @addtogroup System_APIs
  24. * @{
  25. */
  26. /**
  27. * @brief Get information of the SDK version.
  28. *
  29. * @param null
  30. *
  31. * @return Information of the SDK version.
  32. */
  33. const char *system_get_sdk_version(void);
  34. /**
  35. * @brief Reset to default settings.
  36. *
  37. * Reset to default settings of the following APIs : wifi_station_set_auto_connect,
  38. * wifi_set_phy_mode, wifi_softap_set_config related, wifi_station_set_config
  39. * related, and wifi_set_opmode.
  40. *
  41. * @param null
  42. *
  43. * @return null
  44. */
  45. void system_restore(void);
  46. /**
  47. * @brief Restart system.
  48. *
  49. * @param null
  50. *
  51. * @return null
  52. */
  53. void system_restart(void);
  54. /**
  55. * @brief Set the chip to deep-sleep mode.
  56. *
  57. * The device will automatically wake up after the deep-sleep time set
  58. * by the users. Upon waking up, the device boots up from user_init.
  59. *
  60. * @attention The parameter time_in_us to be "uint64" is for further development.
  61. * Only the low 32 bits of parameter time_in_us are avalable now.
  62. *
  63. * @param uint64 time_in_us : deep-sleep time, only the low 32bits are avalable now. unit: microsecond
  64. *
  65. * @return null
  66. */
  67. void system_deep_sleep(uint64_t time_in_us);
  68. /**
  69. * @brief Get system time, unit: microsecond.
  70. *
  71. * @param null
  72. *
  73. * @return System time, unit: microsecond.
  74. */
  75. uint32_t system_get_time(void);
  76. /**
  77. * @brief Get the size of available heap.
  78. *
  79. * @param null
  80. *
  81. * @return Available heap size.
  82. */
  83. uint32_t system_get_free_heap_size(void);
  84. /**
  85. * @brief Get RTC time, unit: RTC clock cycle.
  86. *
  87. * @param null
  88. *
  89. * @return RTC time.
  90. */
  91. uint64_t system_get_rtc_time(void);
  92. /**
  93. * @brief Read user data from the RTC memory.
  94. *
  95. * The user data segment (1024 bytes, as shown below) is used to store user data.
  96. *
  97. * |<---- system data(512 bytes) ---->|<----------- user data(1024 bytes) --------->|
  98. *
  99. * @attention Read and write unit for data stored in the RTC memory is 4 bytes.
  100. * @attention src_addr is the block number (4 bytes per block). So when reading data
  101. * at the beginning of the user data segment, src_addr will be 512/4 = 128,
  102. * n will be data length.
  103. *
  104. * @param uint16 src : source address of rtc memory, src_addr >= 128
  105. * @param void *dst : data pointer
  106. * @param uint16 n : data length, unit: byte
  107. *
  108. * @return true : succeed
  109. * @return false : fail
  110. */
  111. bool system_rtc_mem_read(uint16_t src, void *dst, uint16_t n);
  112. /**
  113. * @brief Write user data to the RTC memory.
  114. *
  115. * During deep-sleep, only RTC is working. So users can store their data
  116. * in RTC memory if it is needed. The user data segment below (1024 bytes)
  117. * is used to store the user data.
  118. *
  119. * |<---- system data(512 bytes) ---->|<----------- user data(1024 bytes) --------->|
  120. *
  121. * @attention Read and write unit for data stored in the RTC memory is 4 bytes.
  122. * @attention src_addr is the block number (4 bytes per block). So when storing data
  123. * at the beginning of the user data segment, src_addr will be 512/4 = 128,
  124. * n will be data length.
  125. *
  126. * @param uint16 src : source address of rtc memory, src_addr >= 128
  127. * @param void *dst : data pointer
  128. * @param uint16 n : data length, unit: byte
  129. *
  130. * @return true : succeed
  131. * @return false : fail
  132. */
  133. bool system_rtc_mem_write(uint16_t dst, const void *src, uint16_t n);
  134. /** \defgroup System_boot_APIs Boot APIs
  135. * @brief boot APIs
  136. */
  137. /** @addtogroup System_boot_APIs
  138. * @{
  139. */
  140. /**
  141. * @}
  142. */
  143. /** \defgroup Hardware_MAC_APIs Hardware MAC APIs
  144. * @brief Hardware MAC address APIs
  145. *
  146. * In WiFi MAC, only ESP32 station MAC is the hardware MAC, ESP32 softAP MAC is a software MAC
  147. * calculated from ESP32 station MAC.
  148. * So users need to call wifi_get_macaddr to query the ESP32 softAP MAC if ESP32 station MAC changed.
  149. *
  150. */
  151. /** @addtogroup Hardware_MAC_APIs
  152. * @{
  153. */
  154. /**
  155. * @brief Read hardware MAC address.
  156. *
  157. * @param uint8 mac[6] : the hardware MAC address, length: 6 bytes.
  158. *
  159. * @return esp_err_t
  160. */
  161. esp_err_t system_efuse_read_mac(uint8_t mac[6]);
  162. void system_init(void);
  163. /**
  164. * @}
  165. */
  166. /**
  167. * @}
  168. */
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif /* __ESP_SYSTEM_H__ */