| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Licensed under the Apache License, Version 2.0 (the "License");
 | 
					
						
							|  |  |  | // you may not use this file except in compliance with the License.
 | 
					
						
							|  |  |  | // You may obtain a copy of the License at
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Unless required by applicable law or agreed to in writing, software
 | 
					
						
							|  |  |  | // distributed under the License is distributed on an "AS IS" BASIS,
 | 
					
						
							|  |  |  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					
						
							|  |  |  | // See the License for the specific language governing permissions and
 | 
					
						
							|  |  |  | // limitations under the License.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __ESP_SYSTEM_H__
 | 
					
						
							|  |  |  | #define __ESP_SYSTEM_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdint.h>
 | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | #include <stdbool.h>
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | #include "esp_err.h"
 | 
					
						
							| 
									
										
										
										
											2016-12-30 01:28:30 +02:00
										 |  |  | #include "esp_deep_sleep.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-13 17:23:44 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |   * @attention  application don't need to call this function anymore. It do nothing and will | 
					
						
							|  |  |  |   *             be removed in future version. | 
					
						
							|  |  |  |   */ | 
					
						
							|  |  |  | void system_init(void) __attribute__ ((deprecated)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @brief  Reset to default settings. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * Function has been deprecated, please use esp_wifi_restore instead. | 
					
						
							|  |  |  |   * This name will be removed in a future release. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | void system_restore(void) __attribute__ ((deprecated)); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @brief  Restart PRO and APP CPUs. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * This function can be called both from PRO and APP CPUs. | 
					
						
							|  |  |  |   * After successful restart, CPU reset reason will be SW_CPU_RESET. | 
					
						
							|  |  |  |   * Peripherals (except for WiFi, BT, UART0, SPI1, and legacy timers) are not reset. | 
					
						
							|  |  |  |   * This function does not return. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | void esp_restart(void) __attribute__ ((noreturn)); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |   * @brief  Restart system. | 
					
						
							|  |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * Function has been renamed to esp_restart. | 
					
						
							|  |  |  |   * This name will be removed in a future release. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | void system_restart(void) __attribute__ ((deprecated, noreturn)); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |   * @brief  Get system time, unit: microsecond. | 
					
						
							|  |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * This function is deprecated. Use 'gettimeofday' function for 64-bit precision. | 
					
						
							|  |  |  |   * This definition will be removed in a future release. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | uint32_t system_get_time(void)  __attribute__ ((deprecated)); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |   * @brief  Get the size of available heap. | 
					
						
							|  |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * Note that the returned value may be larger than the maximum contiguous block | 
					
						
							|  |  |  |   * which can be allocated. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @return Available heap size, in bytes. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | uint32_t esp_get_free_heap_size(void); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @brief  Get the size of available heap. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * Function has been renamed to esp_get_free_heap_size. | 
					
						
							|  |  |  |   * This name will be removed in a future release. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @return Available heap size, in bytes. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | uint32_t system_get_free_heap_size(void)  __attribute__ ((deprecated)); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |  * @brief  Get one random 32-bit word from hardware RNG | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @return random value between 0 and UINT32_MAX | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | uint32_t esp_random(void); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @brief  Read hardware MAC address. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							|  |  |  |   * In WiFi MAC, only ESP32 station MAC is the hardware MAC, ESP32 softAP MAC is a software MAC  | 
					
						
							|  |  |  |   * calculated from ESP32 station MAC.  | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * So users need to call esp_wifi_get_macaddr to query the ESP32 softAP MAC if ESP32 station MAC changed. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @param  mac  hardware MAC address, length: 6 bytes. | 
					
						
							|  |  |  |   * | 
					
						
							|  |  |  |   * @return ESP_OK on success | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | esp_err_t esp_efuse_read_mac(uint8_t* mac); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |   * @brief  Read hardware MAC address. | 
					
						
							|  |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * Function has been renamed to esp_efuse_read_mac. | 
					
						
							|  |  |  |   * This name will be removed in a future release. | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   * | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |   * @param  mac  hardware MAC address, length: 6 bytes. | 
					
						
							|  |  |  |   * @return ESP_OK on success | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  | esp_err_t system_efuse_read_mac(uint8_t mac[6]) __attribute__ ((deprecated)); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-11-28 01:11:36 +02:00
										 |  |  |  * Get SDK version | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This function is deprecated and will be removed in a future release. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @return constant string "master" | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | const char* system_get_sdk_version(void)  __attribute__ ((deprecated)); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* __ESP_SYSTEM_H__ */
 |