ESP32_RTOS_SDK V1.1.0

- Main Page
- Modules
- Data Structures
- Files

Modules | Enumerations | Functions
System APIs

System APIs. More...

## Modules

| Boot APIs
| boot APIs
| Hardware MAC APIs
| Hardware MAC address APIs.
| OTA APIs
| OTA APIs.

## Enumerations

enum | adc1_read_pad { ADC1_PAD_GPIO36 = 0, ADC1_PAD_GPIO37, ADC1_PAD_GPIO38, ADC1_PAD_GPIO39, ADC1_PAD_GPIO32, ADC1_PAD_GPIO33, ADC1_PAD_GPIO34, ADC1_PAD_GPIO35 }
enum | adc1_read_atten { ADC1_ATTEN_0DB = 0, ADC1_ATTEN_3DB, ADC1_ATTEN_6DB, ADC1_ATTEN_12DB }

## Functions

const char * | system_get_sdk_version (void)
| Get information of the SDK version. More...
void | system_restore (void)
| Reset to default settings. More...
void | system_restart (void)
| Restart system. More...
void | system_deep_sleep (uint64 time_in_us)
| Set the chip to deep-sleep mode. More...
uint32 | system_get_time (void)
| Get system time, unit: microsecond. More...
void | system_print_meminfo (void)
| Print the system memory distribution, including data/rodata/bss/heap. More...
uint32 | system_get_free_heap_size (void)
| Get the size of available heap. More...
bool | system_get_chip_id (uint8 *chip_id)
| Get the chip ID. More...
uint32 | system_get_rtc_time (void)
| Get RTC time, unit: RTC clock cycle. More...
bool | system_rtc_mem_read (uint16 src, void *dst, uint16 n)
| Read user data from the RTC memory. More...
bool | system_rtc_mem_write (uint16 dst, const void *src, uint16 n)
| Write user data to the RTC memory. More...
uint16 | system_adc1_read (adc1_read_pad pad, adc1_read_atten atten)
| Read ADC1. More...
uint16 | system_get_vdd33 (void)
| Measure the power voltage of VDD3P3 pin 3 and 4, unit : 1/1024 V. More...
bool | system_param_save_with_protect (uint16 start_sec, void *param, uint16 len)
| Write data into flash with protection. More...
bool | system_param_load (uint16 start_sec, uint16 offset, void *param, uint16 len)
| Read the data saved into flash with the read/write protection. More...

## Detailed Description

System APIs.

## Function Documentation

uint16 system_adc1_read | ( | adc1_read_pad | pad,
|  | adc1_read_atten | atten
| ) |  |

Read ADC1.

Parameters

  adc1_read_pad | pad : the corresponding GPIO
  adc1_read_atten | atten : value of attenuation

Returns
  range of the return value is [0, 4096].
  - If atten == 0, the range of voltage can be measured is [0, 1] V.
  - If atten == 1, the range of voltage can be measured is [0, 1.4] V.
  - If atten == 2, the range of voltage can be measured is [0, 2] V.
  - If atten == 3, the range of voltage can be measured is [0, 4] V.

void system_deep_sleep | ( | uint64 | time_in_us | ) |

Set the chip to deep-sleep mode.

The device will automatically wake up after the deep-sleep time set by the users. Upon waking up, the device boots up from user_init.

Attention
  The parameter time_in_us to be "uint64" is for further development. Only the low 32 bits of parameter time_in_us are avalable now.

Parameters

  uint64 | time_in_us : deep-sleep time, only the low 32bits are avalable now. unit: microsecond

Returns
  null

bool system_get_chip_id | ( | uint8 * | chip_id | ) |

Get the chip ID.

Example:

            uint8 chip_id[6];
            system_get_chip_id(chip_id);

Parameters

  uint8 | *chip_id : the chip ID

Returns
  true : succeed
  false : fail

uint32 system_get_free_heap_size | ( | void |  | ) |

Get the size of available heap.

Parameters

  null |

Returns
  Available heap size.

uint32 system_get_rtc_time | ( | void |  | ) |

Get RTC time, unit: RTC clock cycle.

Parameters

  null |

Returns
  RTC time.

const char* system_get_sdk_version | ( | void |  | ) |

Get information of the SDK version.

Parameters

  null |

Returns
  Information of the SDK version.

uint32 system_get_time | ( | void |  | ) |

Get system time, unit: microsecond.

Parameters

  null |

Returns
  System time, unit: microsecond.

uint16 system_get_vdd33 | ( | void |  | ) |

Measure the power voltage of VDD3P3 pin 3 and 4, unit : 1/1024 V.

Attention
  system_get_vdd33 depends on RF, please do not use it if RF is disabled.

Parameters

  null |

Returns
  Power voltage of VDD33, unit : 1/1024 V

bool system_param_load | ( | uint16 | start_sec,
|  | uint16 | offset,
|  | void * | param,
|  | uint16 | len
| ) |  |

Read the data saved into flash with the read/write protection.

Flash read/write has to be 4-bytes aligned.

Read/write protection of flash: use 3 sectors (4KB per sector) to save 4KB data with protect, sector 0 and sector 1 are data sectors, back up each other, save data alternately, sector 2 is flag sector, point out which sector is keeping the latest data, sector 0 or sector 1.

Parameters

  uint16 | start_sec : start sector (sector 0) of the 3 sectors used for flash read/write protection. It cannot be sector 1 or sector 2.
  - For example, in IOT_Demo, the 3 sectors (3 * 4KB) starting from flash 0x3D000 can be used for flash read/write protection. The parameter start_sec is 0x3D, and it cannot be 0x3E or 0x3F.
  uint16 | offset : offset of data saved in sector
  void | *param : data pointer
  uint16 | len : data length, offset + len =< 4 * 1024

Returns
  true : succeed
  false : fail

bool system_param_save_with_protect | ( | uint16 | start_sec,
|  | void * | param,
|  | uint16 | len
| ) |  |

Write data into flash with protection.

Flash read/write has to be 4-bytes aligned.

Protection of flash read/write : use 3 sectors (4KBytes per sector) to save 4KB data with protect, sector 0 and sector 1 are data sectors, back up each other, save data alternately, sector 2 is flag sector, point out which sector is keeping the latest data, sector 0 or sector 1.

Parameters

  uint16 | start_sec : start sector (sector 0) of the 3 sectors which are used for flash read/write protection.
  - For example, in IOT_Demo we can use the 3 sectors (3 * 4KB) starting from flash 0x3D000 for flash read/write protection, so the parameter start_sec should be 0x3D
  void | *param : pointer of the data to be written
  uint16 | len : data length, should be less than a sector, which is 4 * 1024

Returns
  true : succeed
  false : fail

void system_print_meminfo | ( | void |  | ) |

Print the system memory distribution, including data/rodata/bss/heap.

Parameters

  null |

Returns
  null

void system_restart | ( | void |  | ) |

Restart system.

Parameters

  null |

Returns
  null

void system_restore | ( | void |  | ) |

Reset to default settings.

Reset to default settings of the following APIs : wifi_station_set_auto_connect, wifi_set_phy_mode, wifi_softap_set_config related, wifi_station_set_config related, and wifi_set_opmode.

Parameters

  null |

Returns
  null

bool system_rtc_mem_read | ( | uint16 | src,
|  | void * | dst,
|  | uint16 | n
| ) |  |

Read user data from the RTC memory.

The user data segment (1024 bytes, as shown below) is used to store user data.

|<-— system data(512 bytes) -—>|<--------— user data(1024 bytes) ------—>|

Attention
  Read and write unit for data stored in the RTC memory is 4 bytes.
  src_addr is the block number (4 bytes per block). So when reading data at the beginning of the user data segment, src_addr will be 512/4 = 128, n will be data length.

Parameters

  uint16 | src : source address of rtc memory, src_addr >= 128
  void | *dst : data pointer
  uint16 | n : data length, unit: byte

Returns
  true : succeed
  false : fail

bool system_rtc_mem_write | ( | uint16 | dst,
|  | const void * | src,
|  | uint16 | n
| ) |  |

Write user data to the RTC memory.

During deep-sleep, only RTC is working. So users can store their data in RTC memory if it is needed. The user data segment below (1024 bytes) is used to store the user data.

|<-— system data(512 bytes) -—>|<--------— user data(1024 bytes) ------—>|

Attention
  Read and write unit for data stored in the RTC memory is 4 bytes.
  src_addr is the block number (4 bytes per block). So when storing data at the beginning of the user data segment, src_addr will be 512/4 = 128, n will be data length.

Parameters

  uint16 | src : source address of rtc memory, src_addr >= 128
  void | *dst : data pointer
  uint16 | n : data length, unit: byte

Returns
  true : succeed
  false : fail