Skip to content

Class EspClass

ClassList > EspClass

ESP Arduino Core compatibility class. More...

  • #include <ESP.h>

Public Functions

Type Name
bool flashEraseSector (uint32_t sector)
Erase a single block of flash (usually 4 KiB).
bool flashRead (uint32_t address, uint8_t * data, size_t size)
Read data from the flash.
bool flashWrite (uint32_t address, const uint8_t * data, size_t size)
Write data to the flash.
uint8_t getBootMode ()
uint8_t getBootVersion ()
uint32_t getChipId ()
Get CPU ID based on the last three octets of MAC address. Note: the number is 24-bit (with the MSB being zero). The 3rd-to-last octet is least-significant, the last octet is most-significant.
String getCoreVersion ()
uint8_t getCpuFreqMHz ()
Get CPU frequency in MHz.
uint32_t getCycleCount ()
Get CPU cycle count.
uint32_t getFlashChipId ()
Flash chip ID structure.
uint32_t getFlashChipMode ()
uint32_t getFlashChipRealSize ()
Get flash chip total size.
uint32_t getFlashChipSize ()
Get flash chip total size.
uint32_t getFlashChipSizeByChipId ()
Get flash chip total size.
uint8_t getFlashChipVendorId ()
Flash chip ID structure.
uint32_t getFreeHeap ()
Get free heap size.
String getFullVersion ()
uint16_t getMaxFreeBlockSize ()
Get largest block of heap that can be allocated at once.
String getResetInfo ()
Get a textual representation of a reboot reason.
String getResetReason ()
Get a textual representation of a reboot reason.
const char * getSdkVersion ()
uint16_t getVcc ()
uint8_t * random (uint8_t * resultArray, const size_t outputSizeBytes)
Generate random bytes using rand().
uint32_t random ()
Generate random bytes using rand().
void rebootIntoUartDownloadMode ()
Reboot the CPU and stay in download mode (if possible).
void reset ()
Reboot the CPU.
void restart ()
Reboot the CPU.
void wdtDisable ()
Disable the hardware watchdog.
void wdtEnable (uint32_t timeout_ms=0)
Enable the hardware watchdog.
void wdtFeed ()
Feed/reset the hardware watchdog timer.

Detailed Description

This class only consists of inline functions, which wrap the LibreTiny C API (lt_api.h). Refer to the docs of the C API for more information.

The class is accessible using the ESP global object.

Public Functions Documentation

function flashEraseSector

Erase a single block of flash (usually 4 KiB).

inline bool EspClass::flashEraseSector (
    uint32_t sector
) 

Parameters:

  • offset offset of the block (in bytes); must be multiple of the flash chip's block size

Returns:

whether erasing was successful

function flashRead

Read data from the flash.

inline bool EspClass::flashRead (
    uint32_t address,
    uint8_t * data,
    size_t size
) 

Parameters:

  • offset starting offset (in bytes)
  • data pointer to where to store the data
  • length length of data to read

Returns:

length of data successfully read (should equal 'length')

function flashWrite

Write data to the flash.

inline bool EspClass::flashWrite (
    uint32_t address,
    const uint8_t * data,
    size_t size
) 

Parameters:

  • offset starting offset (in bytes)
  • data pointer to data to write
  • length length of data to write

Returns:

length of data successfully written (should equal 'length')

function getBootMode

inline uint8_t EspClass::getBootMode () 

function getBootVersion

inline uint8_t EspClass::getBootVersion () 

function getChipId

inline uint32_t EspClass::getChipId () 

function getCoreVersion

inline String EspClass::getCoreVersion () 

function getCpuFreqMHz

inline uint8_t EspClass::getCpuFreqMHz () 

function getCycleCount

inline uint32_t EspClass::getCycleCount () 

function getFlashChipId

inline uint32_t EspClass::getFlashChipId () 

function getFlashChipMode

inline uint32_t EspClass::getFlashChipMode () 

function getFlashChipRealSize

Get flash chip total size.

inline uint32_t EspClass::getFlashChipRealSize () 

The default implementation uses the least significant byte of the chip ID to determine the size.

function getFlashChipSize

Get flash chip total size.

inline uint32_t EspClass::getFlashChipSize () 

The default implementation uses the least significant byte of the chip ID to determine the size.

function getFlashChipSizeByChipId

Get flash chip total size.

inline uint32_t EspClass::getFlashChipSizeByChipId () 

The default implementation uses the least significant byte of the chip ID to determine the size.

function getFlashChipVendorId

inline uint8_t EspClass::getFlashChipVendorId () 

function getFreeHeap

inline uint32_t EspClass::getFreeHeap () 

function getFullVersion

inline String EspClass::getFullVersion () 

function getMaxFreeBlockSize

inline uint16_t EspClass::getMaxFreeBlockSize () 

function getResetInfo

Get a textual representation of a reboot reason.

inline String EspClass::getResetInfo () 

Parameters:

  • reason value to convert to text, pass 0 to read from lt_reboot_get_reason()

function getResetReason

Get a textual representation of a reboot reason.

inline String EspClass::getResetReason () 

Parameters:

  • reason value to convert to text, pass 0 to read from lt_reboot_get_reason()

function getSdkVersion

inline const char * EspClass::getSdkVersion () 

function getVcc

inline uint16_t EspClass::getVcc () 

function random [1/2]

Generate random bytes using rand().

inline uint8_t * EspClass::random (
    uint8_t * resultArray,
    const size_t outputSizeBytes
) 

Parameters:

  • buf destination pointer
  • len how many bytes to generate

function random [2/2]

Generate random bytes using rand().

inline uint32_t EspClass::random () 

Parameters:

  • buf destination pointer
  • len how many bytes to generate

function rebootIntoUartDownloadMode

Reboot the CPU and stay in download mode (if possible).

inline void EspClass::rebootIntoUartDownloadMode () 

Returns:

whether download-mode reboot is possible

function reset

inline void EspClass::reset () 

function restart

inline void EspClass::restart () 

function wdtDisable

inline void EspClass::wdtDisable () 

function wdtEnable

Enable the hardware watchdog.

inline void EspClass::wdtEnable (
    uint32_t timeout_ms=0
) 

Parameters:

  • timeout watchdog timeout, milliseconds

Returns:

whether the chip has a hardware watchdog

function wdtFeed

inline void EspClass::wdtFeed () 

The documentation for this class was generated from the following file cores/common/arduino/libraries/inline/ESP/ESP.h