2015-04-30 04:00:03 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 -2014 Espressif System
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ESP_SYSTEM_H__
|
|
|
|
#define __ESP_SYSTEM_H__
|
|
|
|
|
2015-07-30 17:34:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
enum sdk_rst_reason {
|
2015-04-30 04:00:03 +00:00
|
|
|
DEFAULT_RST = 0,
|
|
|
|
WDT_RST = 1,
|
|
|
|
EXCEPTION_RST = 2,
|
|
|
|
SOFT_RST = 3
|
|
|
|
};
|
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
struct sdk_rst_info{
|
2015-04-30 04:00:03 +00:00
|
|
|
uint32_t reason;
|
|
|
|
uint32_t exccause;
|
|
|
|
uint32_t epc1;
|
|
|
|
uint32_t epc2;
|
|
|
|
uint32_t epc3;
|
|
|
|
uint32_t excvaddr;
|
|
|
|
uint32_t depc;
|
|
|
|
uint32_t rtn_addr;
|
|
|
|
};
|
|
|
|
|
2015-08-06 06:35:20 +00:00
|
|
|
struct sdk_rst_info* sdk_system_get_rst_info(void);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
const char* sdk_system_get_sdk_version(void);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-08-03 02:50:57 +00:00
|
|
|
enum sdk_sleep_type {
|
|
|
|
WIFI_SLEEP_NONE = 0,
|
|
|
|
WIFI_SLEEP_LIGHT = 1,
|
|
|
|
WIFI_SLEEP_MODEM = 2,
|
|
|
|
};
|
|
|
|
void sdk_wifi_set_sleep_type(enum sdk_sleep_type);
|
|
|
|
enum sdk_sleep_type sdk_wifi_get_sleep_type(enum sdk_sleep_type);
|
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
void sdk_system_restore(void);
|
|
|
|
void sdk_system_restart(void);
|
2016-02-28 20:55:51 +00:00
|
|
|
bool sdk_system_deep_sleep_set_option(uint8_t option);
|
2015-05-30 09:11:04 +00:00
|
|
|
void sdk_system_deep_sleep(uint32_t time_in_us);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
uint32_t sdk_system_get_time(void);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
void sdk_system_print_meminfo(void);
|
|
|
|
uint32_t sdk_system_get_free_heap_size(void);
|
|
|
|
uint32_t sdk_system_get_chip_id(void);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
uint32_t sdk_system_rtc_clock_cali_proc(void);
|
|
|
|
uint32_t sdk_system_get_rtc_time(void);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
bool sdk_system_rtc_mem_read(uint8_t src, void *dst, uint16_t n);
|
|
|
|
bool sdk_system_rtc_mem_write(uint8_t dst, const void *src, uint16_t n);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
void sdk_system_uart_swap(void);
|
2016-02-28 20:55:51 +00:00
|
|
|
void sdk_system_uart_de_swap(void);
|
|
|
|
|
|
|
|
#define SYS_CPU_80MHZ 80
|
|
|
|
#define SYS_CPU_160MHZ 160
|
|
|
|
/*
|
|
|
|
Set CPU frequency in MHz. All peripheral devices are clocked by independent
|
|
|
|
system bus, and CPU frequency change will not affect them.
|
|
|
|
*/
|
|
|
|
bool sdk_system_update_cpu_freq(uint8_t freq);
|
|
|
|
uint8_t sdk_system_get_cpu_freq(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Measure voltage on the TOUT pin, 1V max. Returns 10 bits ADC value (1/1024V).
|
|
|
|
Voltage range 0 .. 1.0V. RF must be enabled.
|
|
|
|
Example:
|
2016-02-29 07:58:45 +00:00
|
|
|
printf ("ADC voltage is %.3f", 1.0 / 1024 * sdk_system_adc_read());
|
2016-02-28 20:55:51 +00:00
|
|
|
*/
|
|
|
|
uint16_t sdk_system_adc_read(void);
|
|
|
|
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2015-07-30 17:34:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-30 04:00:03 +00:00
|
|
|
#endif
|