Skip to content

File LT.h

File List > arduino > libraries > inline > LT > LT.h

Go to the documentation of this file.

/* Copyright (c) Kuba Szczodrzyński 2022-06-06. */

#pragma once

#include <Arduino.h>
#include <ESP.h>
#include <OTA.h>
#include <WDT.h>

#ifdef __cplusplus

#define ChipFamily  lt_cpu_family_t
#define ChipType    lt_cpu_model_t
#define ResetReason lt_reboot_reason_t
#define FlashId     lt_flash_id_t

class LibreTiny {
  public: /* lt_cpu.h */
    inline ChipFamily getChipFamily() { return lt_cpu_get_family(); }

    inline const char *getChipFamilyName() { return lt_cpu_get_family_name(); }

    inline ChipType getChipType() { return lt_cpu_get_model(); }

    inline const char *getChipModel() { return lt_cpu_get_model_name(); }

    inline uint32_t getChipId() { return lt_cpu_get_mac_id(); }

    inline uint8_t getChipCores() { return lt_cpu_get_core_count(); }

    inline const char *getChipCoreType() { return lt_cpu_get_core_type(); }

    inline uint32_t getCpuFreq() { return lt_cpu_get_freq(); }

    inline uint32_t getCpuFreqMHz() { return lt_cpu_get_freq_mhz(); }

    inline uint32_t getCycleCount() { return lt_cpu_get_cycle_count(); }

  public: /* lt_device.h */
    inline const char *getVersion() { return lt_get_version(); }

    inline const char *getBoard() { return lt_get_board_code(); }

    inline const char *getDeviceName() { return lt_get_device_name(); }

    inline void restart() { lt_reboot(); }

    inline void restartDownloadMode() { lt_reboot_download_mode(); }

    inline ResetReason getResetReason() { return lt_get_reboot_reason(); }

    inline const char *getResetReasonName(ResetReason reason = lt_get_reboot_reason()) {
        return lt_get_reboot_reason_name(reason);
    }

    inline void gpioRecover() { lt_gpio_recover(); }

  public: /* lt_flash.h */
    inline FlashId getFlashChipId() { return lt_flash_get_id(); }

    inline uint32_t getFlashChipSize() { return lt_flash_get_size(); }

  public: /* lt_mem.h */
    inline uint32_t getRamSize() { return lt_ram_get_size(); }

    inline uint32_t getHeapSize() { return lt_heap_get_size(); }

    inline uint32_t getFreeHeap() { return lt_heap_get_free(); }

    inline uint32_t getMinFreeHeap() { return lt_heap_get_min_free(); }

    inline uint32_t getMaxAllocHeap() { return lt_heap_get_max_alloc(); }

    inline uint32_t getMaxFreeBlockSize() { return lt_heap_get_max_alloc(); }
};

extern LibreTiny LT;

#endif