Skip to content

File lt_device.h

FileList > api > lt_device.h

Go to the source code of this file.

  • #include <libretiny.h>

Public Types

Type Name
enum lt_debug_mode_t
Debugging mode enumeration.
enum lt_reboot_reason_t
Reset reason enumeration.

Public Functions

Type Name
const char * lt_get_board_code ()
Get board code.
void lt_get_device_mac (uint8_t * mac)
Read device's default MAC address into 'mac' array. This can be used even without Wi-Fi enabled, and will ignore user-changed Wi-Fi MAC (if changing is possible).
const char * lt_get_device_name ()
Get device friendly name in format "LT-<chip model>-<MAC ID>". Can be used as hostname.
lt_reboot_reason_t lt_get_reboot_reason ()
Get the reason of last chip reboot.
const char * lt_get_reboot_reason_name (lt_reboot_reason_t reason)
Get a textual representation of a reboot reason.
const char * lt_get_version ()
Get LibreTiny version string.
void lt_gpio_recover ()
Reconfigure GPIO pins used for debugging (SWD/JTAG), so that they can be used as normal I/O.
void lt_reboot ()
Reboot the CPU.
bool lt_reboot_download_mode ()
Reboot the CPU and stay in download mode (if possible).
bool lt_reboot_wdt ()
Reboot the CPU with a watchdog timeout (if possible).
bool lt_set_debug_mode (lt_debug_mode_t mode)
Set debugger mode (JTAG, SWD or OFF).

Macros

Type Name
define REBOOT_REASON_SLEEP REBOOT_REASON_SLEEP_GPIO
define RESET_REASON_BROWNOUT REBOOT_REASON_BROWNOUT
define RESET_REASON_CRASH REBOOT_REASON_CRASH
define RESET_REASON_HARDWARE REBOOT_REASON_HARDWARE
define RESET_REASON_MAX REBOOT_REASON_MAX
define RESET_REASON_POWER REBOOT_REASON_POWER
define RESET_REASON_SLEEP REBOOT_REASON_SLEEP_GPIO
define RESET_REASON_SLEEP_GPIO REBOOT_REASON_SLEEP_GPIO
define RESET_REASON_SLEEP_RTC REBOOT_REASON_SLEEP_RTC
define RESET_REASON_SLEEP_USB REBOOT_REASON_SLEEP_USB
define RESET_REASON_SOFTWARE REBOOT_REASON_SOFTWARE
define RESET_REASON_UNKNOWN REBOOT_REASON_UNKNOWN
define RESET_REASON_WATCHDOG REBOOT_REASON_WATCHDOG

Public Types Documentation

enum lt_debug_mode_t

enum lt_debug_mode_t {
    DEBUG_MODE_OFF = 0,
    DEBUG_MODE_JTAG = 1,
    DEBUG_MODE_SWD = 2
};

enum lt_reboot_reason_t

enum lt_reboot_reason_t {
    REBOOT_REASON_UNKNOWN = 1,
    REBOOT_REASON_POWER = 2,
    REBOOT_REASON_BROWNOUT = 3,
    REBOOT_REASON_HARDWARE = 4,
    REBOOT_REASON_SOFTWARE = 5,
    REBOOT_REASON_WATCHDOG = 6,
    REBOOT_REASON_CRASH = 7,
    REBOOT_REASON_SLEEP_GPIO = 8,
    REBOOT_REASON_SLEEP_RTC = 9,
    REBOOT_REASON_SLEEP_USB = 10,
    REBOOT_REASON_DEBUGGER = 11,
    REBOOT_REASON_MAX = 12
};

Public Functions Documentation

function lt_get_board_code

const char * lt_get_board_code () 

function lt_get_device_mac

void lt_get_device_mac (
    uint8_t * mac
) 

function lt_get_device_name

const char * lt_get_device_name () 

function lt_get_reboot_reason

lt_reboot_reason_t lt_get_reboot_reason () 

function lt_get_reboot_reason_name

Get a textual representation of a reboot reason.

const char * lt_get_reboot_reason_name (
    lt_reboot_reason_t reason
) 

Parameters:

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

function lt_get_version

const char * lt_get_version () 

function lt_gpio_recover

void lt_gpio_recover () 

function lt_reboot

void lt_reboot () 

function lt_reboot_download_mode

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

bool lt_reboot_download_mode () 

Returns:

whether download-mode reboot is possible

function lt_reboot_wdt

Reboot the CPU with a watchdog timeout (if possible).

bool lt_reboot_wdt () 

Returns:

whether WDT reboot is possible

function lt_set_debug_mode

Set debugger mode (JTAG, SWD or OFF).

bool lt_set_debug_mode (
    lt_debug_mode_t mode
) 

Returns:

whether the mode is supported, and setting it was successful

Macro Definition Documentation

define REBOOT_REASON_SLEEP

#define REBOOT_REASON_SLEEP REBOOT_REASON_SLEEP_GPIO

define RESET_REASON_BROWNOUT

#define RESET_REASON_BROWNOUT REBOOT_REASON_BROWNOUT

define RESET_REASON_CRASH

#define RESET_REASON_CRASH REBOOT_REASON_CRASH

define RESET_REASON_HARDWARE

#define RESET_REASON_HARDWARE REBOOT_REASON_HARDWARE

define RESET_REASON_MAX

#define RESET_REASON_MAX REBOOT_REASON_MAX

define RESET_REASON_POWER

#define RESET_REASON_POWER REBOOT_REASON_POWER

define RESET_REASON_SLEEP

#define RESET_REASON_SLEEP REBOOT_REASON_SLEEP_GPIO

define RESET_REASON_SLEEP_GPIO

#define RESET_REASON_SLEEP_GPIO REBOOT_REASON_SLEEP_GPIO

define RESET_REASON_SLEEP_RTC

#define RESET_REASON_SLEEP_RTC REBOOT_REASON_SLEEP_RTC

define RESET_REASON_SLEEP_USB

#define RESET_REASON_SLEEP_USB REBOOT_REASON_SLEEP_USB

define RESET_REASON_SOFTWARE

#define RESET_REASON_SOFTWARE REBOOT_REASON_SOFTWARE

define RESET_REASON_UNKNOWN

#define RESET_REASON_UNKNOWN REBOOT_REASON_UNKNOWN

define RESET_REASON_WATCHDOG

#define RESET_REASON_WATCHDOG REBOOT_REASON_WATCHDOG

The documentation for this class was generated from the following file cores/common/base/api/lt_device.h