ESP8266_RTOS_SDK  v1.4.0
esp_system.h
1 /*
2  * ESPRSSIF MIT License
3  *
4  * Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5  *
6  * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
7  * it is free of charge, to any person obtaining a copy of this software and associated
8  * documentation files (the "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11  * to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or
14  * substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef __ESP_SYSTEM_H__
26 #define __ESP_SYSTEM_H__
27 
28 #include "c_types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
42 typedef enum {
50 } rst_reason;
51 
52 struct rst_info {
54  uint32 exccause;
55  uint32 epc1;
56  uint32 epc2;
57  uint32 epc3;
58  uint32 excvaddr;
59  uint32 depc;
60  uint32 rtn_addr;
61 };
62 
70 struct rst_info *system_get_rst_info(void);
71 
79 const char *system_get_sdk_version(void);
80 
92 void system_restore(void);
93 
101 void system_restart(void);
102 
119 void system_deep_sleep(uint32 time_in_us);
120 
141 bool system_deep_sleep_set_option(uint8 option);
142 
150 uint32 system_get_time(void);
151 
159 void system_print_meminfo(void);
160 
168 uint32 system_get_free_heap_size(void);
169 
177 uint32 system_get_chip_id(void);
178 
190 uint32 system_rtc_clock_cali_proc(void);
191 
213 uint32 system_get_rtc_time(void);
214 
234 bool system_rtc_mem_read(uint8 src, void *dst, uint16 n);
235 
257 bool system_rtc_mem_write(uint8 dst, const void *src, uint16 n);
258 
269 void system_uart_swap(void);
270 
280 void system_uart_de_swap(void);
281 
298 uint16 system_adc_read(void);
299 
313 uint16 system_get_vdd33(void);
314 
336 bool system_param_save_with_protect(uint16 start_sec, void *param, uint16 len);
337 
361 bool system_param_load(uint16 start_sec, uint16 offset, void *param, uint16 len);
362 
372 void system_phy_set_max_tpw(uint8 max_tpw);
373 
385 void system_phy_set_tpw_via_vdd33(uint16 vdd33);
386 
409 void system_phy_set_rfoption(uint8 option);
410 
423 uint8 system_upgrade_userbin_check(void);
424 
432 void system_upgrade_reboot(void);
433 
444 
459 void system_upgrade_flag_set(uint8 flag);
460 
473 #define SYS_BOOT_ENHANCE_MODE 0
474 #define SYS_BOOT_NORMAL_MODE 1
476 #define SYS_BOOT_NORMAL_BIN 0
477 #define SYS_BOOT_TEST_BIN 1
489 uint8 system_get_boot_version(void);
490 
498 uint32 system_get_userbin_addr(void);
499 
508 uint8 system_get_boot_mode(void);
509 
524 bool system_restart_enhance(uint8 bin_type, uint32 bin_addr);
525 
526 typedef enum {
535 
547 
548 #define SYS_CPU_80MHZ 80
549 #define SYS_CPU_160MHZ 160
550 
563 bool system_update_cpu_freq(uint8 freq);
564 
572 uint8 system_get_cpu_freq(void);
573 
582 #ifdef __cplusplus
583 }
584 #endif
585 
586 #endif
uint16 system_get_vdd33(void)
Measure the power voltage of VDD3P3 pin 3 and 4, unit : 1/1024 V.
uint32 system_get_chip_id(void)
Get the chip ID.
void system_uart_swap(void)
UART0 swap.
struct rst_info * system_get_rst_info(void)
Get the reason of restart.
Definition: esp_system.h:46
void system_phy_set_rfoption(uint8 option)
Enable RF or not when wakeup from deep-sleep.
void system_print_meminfo(void)
Print the system memory distribution, including data/rodata/bss/heap.
Definition: esp_system.h:528
Definition: esp_system.h:49
Definition: esp_system.h:47
Definition: esp_system.h:530
void system_upgrade_flag_set(uint8 flag)
Set the upgrade status flag.
Definition: esp_system.h:533
void system_restore(void)
Reset to default settings.
Definition: esp_system.h:48
uint8 system_get_cpu_freq(void)
Get CPU frequency.
uint8 system_get_boot_mode(void)
Get the boot mode.
uint8 system_upgrade_flag_check()
Check the upgrade status flag.
Definition: esp_system.h:52
uint32 system_get_free_heap_size(void)
Get the size of available heap.
Definition: esp_system.h:44
bool system_param_save_with_protect(uint16 start_sec, void *param, uint16 len)
Write data into flash with protection.
Definition: esp_system.h:529
void system_phy_set_tpw_via_vdd33(uint16 vdd33)
Adjust the RF TX Power according to VDD33, unit : 1/1024 V.
Definition: esp_system.h:532
uint16 system_adc_read(void)
Measure the input voltage of TOUT pin 6, unit : 1/1024 V.
uint32 system_get_userbin_addr(void)
Get the address of the current running user bin (user1.bin or user2.bin).
flash_size_map
Definition: esp_system.h:526
void system_restart(void)
Restart system.
void system_deep_sleep(uint32 time_in_us)
Set the chip to deep-sleep mode.
rst_reason reason
Definition: esp_system.h:53
bool system_param_load(uint16 start_sec, uint16 offset, void *param, uint16 len)
Read the data saved into flash with the read/write protection.
bool system_restart_enhance(uint8 bin_type, uint32 bin_addr)
Restarts the system, and enters the enhanced boot mode.
uint32 system_get_rtc_time(void)
Get RTC time, unit: RTC clock cycle.
bool system_deep_sleep_set_option(uint8 option)
Call this API before system_deep_sleep to set the activity after the next deep-sleep wakeup...
uint32 system_get_time(void)
Get system time, unit: microsecond.
bool system_rtc_mem_write(uint8 dst, const void *src, uint16 n)
Write user data to the RTC memory.
bool system_update_cpu_freq(uint8 freq)
Set CPU frequency. Default is 80MHz.
Definition: esp_system.h:43
rst_reason
Definition: esp_system.h:42
Definition: esp_system.h:531
Definition: esp_system.h:527
void system_upgrade_reboot(void)
Reboot system to use the new software.
bool system_rtc_mem_read(uint8 src, void *dst, uint16 n)
Read user data from the RTC memory.
void system_phy_set_max_tpw(uint8 max_tpw)
Set the maximum value of RF TX Power, unit : 0.25dBm.
flash_size_map system_get_flash_size_map(void)
Get the current Flash size and Flash map.
Definition: esp_system.h:45
const char * system_get_sdk_version(void)
Get information of the SDK version.
uint32 system_rtc_clock_cali_proc(void)
Get the RTC clock cycle.
uint8 system_upgrade_userbin_check(void)
Check the user bin.
void system_uart_de_swap(void)
Disable UART0 swap.