esp_system.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. #include "esp_deepsleep.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /** \defgroup System_APIs System APIs
  22. * @brief System APIs
  23. */
  24. /** @addtogroup System_APIs
  25. * @{
  26. */
  27. /**
  28. * @brief Get information of the SDK version.
  29. *
  30. * @param null
  31. *
  32. * @return Information of the SDK version.
  33. */
  34. const char *system_get_sdk_version(void);
  35. /**
  36. * @brief Reset to default settings.
  37. *
  38. * Reset to default settings of the following APIs : wifi_station_set_auto_connect,
  39. * wifi_set_phy_mode, wifi_softap_set_config related, wifi_station_set_config
  40. * related, and wifi_set_opmode.
  41. *
  42. * @param null
  43. *
  44. * @return null
  45. */
  46. void system_restore(void);
  47. /**
  48. * @brief Restart system.
  49. *
  50. * @param null
  51. *
  52. * @return null
  53. */
  54. void system_restart(void);
  55. /**
  56. * @brief Get system time, unit: microsecond.
  57. *
  58. * @param null
  59. *
  60. * @return System time, unit: microsecond.
  61. */
  62. uint32_t system_get_time(void);
  63. /**
  64. * @brief Get the size of available heap.
  65. *
  66. * @param null
  67. *
  68. * @return Available heap size.
  69. */
  70. uint32_t system_get_free_heap_size(void);
  71. /**
  72. * @brief Get RTC time, unit: RTC clock cycle.
  73. *
  74. * @param null
  75. *
  76. * @return RTC time.
  77. */
  78. uint64_t system_get_rtc_time(void);
  79. /**
  80. * @brief Read user data from the RTC memory.
  81. *
  82. * The user data segment (1024 bytes, as shown below) is used to store user data.
  83. *
  84. * |<---- system data(512 bytes) ---->|<----------- user data(1024 bytes) --------->|
  85. *
  86. * @attention Read and write unit for data stored in the RTC memory is 4 bytes.
  87. * @attention src_addr is the block number (4 bytes per block). So when reading data
  88. * at the beginning of the user data segment, src_addr will be 512/4 = 128,
  89. * n will be data length.
  90. *
  91. * @param uint16 src : source address of rtc memory, src_addr >= 128
  92. * @param void *dst : data pointer
  93. * @param uint16 n : data length, unit: byte
  94. *
  95. * @return true : succeed
  96. * @return false : fail
  97. */
  98. bool system_rtc_mem_read(uint16_t src, void *dst, uint16_t n);
  99. /**
  100. * @brief Write user data to the RTC memory.
  101. *
  102. * During deep-sleep, only RTC is working. So users can store their data
  103. * in RTC memory if it is needed. The user data segment below (1024 bytes)
  104. * is used to store the user data.
  105. *
  106. * |<---- system data(512 bytes) ---->|<----------- user data(1024 bytes) --------->|
  107. *
  108. * @attention Read and write unit for data stored in the RTC memory is 4 bytes.
  109. * @attention src_addr is the block number (4 bytes per block). So when storing data
  110. * at the beginning of the user data segment, src_addr will be 512/4 = 128,
  111. * n will be data length.
  112. *
  113. * @param uint16 src : source address of rtc memory, src_addr >= 128
  114. * @param void *dst : data pointer
  115. * @param uint16 n : data length, unit: byte
  116. *
  117. * @return true : succeed
  118. * @return false : fail
  119. */
  120. bool system_rtc_mem_write(uint16_t dst, const void *src, uint16_t n);
  121. /** \defgroup System_boot_APIs Boot APIs
  122. * @brief boot APIs
  123. */
  124. /** @addtogroup System_boot_APIs
  125. * @{
  126. */
  127. /**
  128. * @}
  129. */
  130. /** \defgroup Hardware_MAC_APIs Hardware MAC APIs
  131. * @brief Hardware MAC address APIs
  132. *
  133. * In WiFi MAC, only ESP32 station MAC is the hardware MAC, ESP32 softAP MAC is a software MAC
  134. * calculated from ESP32 station MAC.
  135. * So users need to call wifi_get_macaddr to query the ESP32 softAP MAC if ESP32 station MAC changed.
  136. *
  137. */
  138. /** @addtogroup Hardware_MAC_APIs
  139. * @{
  140. */
  141. /**
  142. * @brief Read hardware MAC address.
  143. *
  144. * @param uint8 mac[6] : the hardware MAC address, length: 6 bytes.
  145. *
  146. * @return esp_err_t
  147. */
  148. esp_err_t system_efuse_read_mac(uint8_t mac[6]);
  149. void system_init(void);
  150. /**
  151. * @}
  152. */
  153. /**
  154. * @}
  155. */
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif /* __ESP_SYSTEM_H__ */