esp_system.h 4.7 KB

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