Skip to content

API functions guide

The LibreTiny C API functions are split between three types: common, weak and family.

  • Common functions are implemented in the base, common core and are the same between all families.
  • Weak functions are provided in the common core, but can (and sometimes should) be overridden by family cores. They sometimes provide usable default implementations (which can be overriden to provide e.g. a better way to do something), otherwise they're empty (e.g. if a family doesn't support such a feature).
  • Family functions are not provided in the common core and have to be implemented in the family core.

A quick outline of all available functions and their types:

Type Function Common Weak Family
const char * lt_cpu_get_core_type() ✔️
void lt_deep_sleep_config_timer() ✔️
void lt_deep_sleep_enter() ✔️
void lt_deep_sleep_unset_gpio() ✔️
lt_flash_id_t lt_flash_get_id() ✔️
uint32_t lt_flash_get_size() ✔️
void lt_get_device_mac() ✔️
void lt_init_arduino() ✔️
void lt_init_family() ✔️
void lt_init_variant() ✔️
uint8_t lt_ota_dual_get_current() ✔️
uint8_t lt_ota_dual_get_stored() ✔️
lt_ota_type_t lt_ota_get_type() ✔️
bool lt_ota_is_valid() ✔️
bool lt_ota_switch() ✔️
uint32_t lt_ram_get_size() ✔️
uint8_t lt_cpu_get_core_count() ✔️
uint32_t lt_cpu_get_cycle_count() ✔️
uint32_t lt_cpu_get_freq() ✔️
uint32_t lt_cpu_get_mac_id() ✔️
lt_cpu_model_t lt_cpu_get_model() ✔️
uint32_t lt_cpu_get_unique_id() ✔️
void lt_deep_sleep_config_gpio() ✔️
lt_reboot_reason_t lt_get_reboot_reason() ✔️
void lt_gpio_recover() ✔️
uint32_t lt_heap_get_free() ✔️
uint32_t lt_heap_get_max_alloc() ✔️
uint32_t lt_heap_get_min_free() ✔️
uint32_t lt_heap_get_size() ✔️
void lt_ota_set_write_protect() ✔️
void lt_reboot() ✔️
bool lt_reboot_download_mode() ✔️
bool lt_reboot_wdt() ✔️
bool lt_set_debug_mode() ✔️
void lt_wdt_disable() ✔️
bool lt_wdt_enable() ✔️
void lt_wdt_feed() ✔️
void hexdump() ✔️
char * lt_btox() ✔️
lt_cpu_family_t lt_cpu_get_family() ✔️
const char * lt_cpu_get_family_name() ✔️
uint32_t lt_cpu_get_freq_mhz() ✔️
const char * lt_cpu_get_model_code() ✔️
const char * lt_cpu_get_model_name() ✔️
bool lt_flash_erase() ✔️
bool lt_flash_erase_block() ✔️
uint32_t lt_flash_read() ✔️
uint32_t lt_flash_write() ✔️
const char * lt_get_board_code() ✔️
const char * lt_get_device_name() ✔️
const char * lt_get_reboot_reason_name() ✔️
const char * lt_get_version() ✔️
void lt_ota_begin() ✔️
bool lt_ota_can_rollback() ✔️
bool lt_ota_end() ✔️
uf2_ota_scheme_t lt_ota_get_uf2_scheme() ✔️
size_t lt_ota_write() ✔️
bool lt_ota_write_block() ✔️
void lt_rand_bytes() ✔️
uint8_t * lt_xtob() ✔️