ESP8266_RTOS_SDK v1.4.0

- Main Page
- Modules
- Data Structures
- Files

- File List

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 {
43 REASON_DEFAULT_RST = 0,
44 REASON_WDT_RST,
45 REASON_EXCEPTION_RST,
46 REASON_SOFT_WDT_RST,
47 REASON_SOFT_RESTART,
48 REASON_DEEP_SLEEP_AWAKE,
49 REASON_EXT_SYS_RST
50 } rst_reason;
51
52 struct rst_info {
53 rst_reason reason;
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
443 uint8 system_upgrade_flag_check();
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 {
527 FLASH_SIZE_4M_MAP_256_256 = 0,
528 FLASH_SIZE_2M,
529 FLASH_SIZE_8M_MAP_512_512,
530 FLASH_SIZE_16M_MAP_512_512,
531 FLASH_SIZE_32M_MAP_512_512,
532 FLASH_SIZE_16M_MAP_1024_1024,
533 FLASH_SIZE_32M_MAP_1024_1024
534 } flash_size_map;
535
546 flash_size_map system_get_flash_size_map(void);
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
system_get_vdd33
uint16 system_get_vdd33(void)
Measure the power voltage of VDD3P3 pin 3 and 4, unit : 1/1024 V.
system_get_chip_id
uint32 system_get_chip_id(void)
Get the chip ID.
system_uart_swap
void system_uart_swap(void)
UART0 swap.
system_get_rst_info
struct rst_info * system_get_rst_info(void)
Get the reason of restart.
REASON_SOFT_WDT_RST
Definition: esp_system.h:46
system_phy_set_rfoption
void system_phy_set_rfoption(uint8 option)
Enable RF or not when wakeup from deep-sleep.
system_print_meminfo
void system_print_meminfo(void)
Print the system memory distribution, including data/rodata/bss/heap.
FLASH_SIZE_2M
Definition: esp_system.h:528
REASON_EXT_SYS_RST
Definition: esp_system.h:49
REASON_SOFT_RESTART
Definition: esp_system.h:47
FLASH_SIZE_16M_MAP_512_512
Definition: esp_system.h:530
system_upgrade_flag_set
void system_upgrade_flag_set(uint8 flag)
Set the upgrade status flag.
FLASH_SIZE_32M_MAP_1024_1024
Definition: esp_system.h:533
system_restore
void system_restore(void)
Reset to default settings.
REASON_DEEP_SLEEP_AWAKE
Definition: esp_system.h:48
system_get_cpu_freq
uint8 system_get_cpu_freq(void)
Get CPU frequency.
system_get_boot_mode
uint8 system_get_boot_mode(void)
Get the boot mode.
system_upgrade_flag_check
uint8 system_upgrade_flag_check()
Check the upgrade status flag.
rst_info
Definition: esp_system.h:52
system_get_free_heap_size
uint32 system_get_free_heap_size(void)
Get the size of available heap.
REASON_WDT_RST
Definition: esp_system.h:44
system_param_save_with_protect
bool system_param_save_with_protect(uint16 start_sec, void *param, uint16 len)
Write data into flash with protection.
FLASH_SIZE_8M_MAP_512_512
Definition: esp_system.h:529
system_phy_set_tpw_via_vdd33
void system_phy_set_tpw_via_vdd33(uint16 vdd33)
Adjust the RF TX Power according to VDD33, unit : 1/1024 V.
FLASH_SIZE_16M_MAP_1024_1024
Definition: esp_system.h:532
system_adc_read
uint16 system_adc_read(void)
Measure the input voltage of TOUT pin 6, unit : 1/1024 V.
system_get_userbin_addr
uint32 system_get_userbin_addr(void)
Get the address of the current running user bin (user1.bin or user2.bin).
flash_size_map
flash_size_map
Definition: esp_system.h:526
system_restart
void system_restart(void)
Restart system.
system_deep_sleep
void system_deep_sleep(uint32 time_in_us)
Set the chip to deep-sleep mode.
rst_info::reason
rst_reason reason
Definition: esp_system.h:53
system_param_load
bool system_param_load(uint16 start_sec, uint16 offset, void *param, uint16 len)
Read the data saved into flash with the read/write protection.
system_restart_enhance
bool system_restart_enhance(uint8 bin_type, uint32 bin_addr)
Restarts the system, and enters the enhanced boot mode.
system_get_rtc_time
uint32 system_get_rtc_time(void)
Get RTC time, unit: RTC clock cycle.
system_deep_sleep_set_option
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...
system_get_time
uint32 system_get_time(void)
Get system time, unit: microsecond.
system_rtc_mem_write
bool system_rtc_mem_write(uint8 dst, const void *src, uint16 n)
Write user data to the RTC memory.
system_update_cpu_freq
bool system_update_cpu_freq(uint8 freq)
Set CPU frequency. Default is 80MHz.
REASON_DEFAULT_RST
Definition: esp_system.h:43
rst_reason
rst_reason
Definition: esp_system.h:42
FLASH_SIZE_32M_MAP_512_512
Definition: esp_system.h:531
FLASH_SIZE_4M_MAP_256_256
Definition: esp_system.h:527
system_upgrade_reboot
void system_upgrade_reboot(void)
Reboot system to use the new software.
system_rtc_mem_read
bool system_rtc_mem_read(uint8 src, void *dst, uint16 n)
Read user data from the RTC memory.
system_phy_set_max_tpw
void system_phy_set_max_tpw(uint8 max_tpw)
Set the maximum value of RF TX Power, unit : 0.25dBm.
system_get_flash_size_map
flash_size_map system_get_flash_size_map(void)
Get the current Flash size and Flash map.
REASON_EXCEPTION_RST
Definition: esp_system.h:45
system_get_sdk_version
const char * system_get_sdk_version(void)
Get information of the SDK version.
system_rtc_clock_cali_proc
uint32 system_rtc_clock_cali_proc(void)
Get the RTC clock cycle.
system_upgrade_userbin_check
uint8 system_upgrade_userbin_check(void)
Check the user bin.
system_uart_de_swap
void system_uart_de_swap(void)
Disable UART0 swap.