ChaosDMX
Open-Source DMX-Interface
Loading...
Searching...
No Matches
system.h File Reference
#include "esp_err.h"
#include <stddef.h>
#include <stdint.h>
Include dependency graph for system.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sys_chip_info_t
 Structure to hold static chip configuration details. More...

Functions

esp_err_t system_init (void)
 Initializes the system monitoring component. Sets up the internal temperature sensor and tracks initial values.
float system_get_temperature (void)
 Gets the current internal CPU temperature.
float system_get_max_temperature (void)
 Gets the highest recorded CPU temperature since boot.
uint32_t system_get_free_heap (void)
 Gets the current available free heap size (RAM).
uint32_t system_get_min_free_heap (void)
 Gets the minimum ever free heap size since boot (watermark). This is crucial for detecting close-to-OOM (Out Of Memory) conditions.
uint8_t system_get_cpu_usage (void)
 Calculates the total real-time CPU utilization. Requires CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS to be enabled.
void system_get_tasks_list (char *buffer, size_t buffer_len)
 Formats raw FreeRTOS statistics into a human-readable task list. Requires CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS to be enabled. Writes a table containing task names, status, priority, and remaining stack space.
const char * system_get_version (void)
 Gets the active firmware build version. Matches the Git commit short hash (appends '-d' if local modifications exist).
int64_t system_get_uptime_ms (void)
 Gets the system uptime since boot.
int system_get_reset_reason (void)
 Gets the reason for the last system reset.
void system_get_chip_info (sys_chip_info_t *chip_info)
 Retrieves static chip hardware information.
void system_print_info (void)
 Prints a complete, formatted overview of all system statistics to the console. Internally uses ESP_LOGI or printf to output a comprehensive snapshot of the device status.

Function Documentation

◆ system_get_chip_info()

void system_get_chip_info ( sys_chip_info_t * chip_info)

Retrieves static chip hardware information.

Parameters
[out]chip_infoPointer to the structure to be filled with chip details.

Definition at line 124 of file system.c.

References sys_chip_info_t::cores, sys_chip_info_t::model_name, and sys_chip_info_t::revision.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_get_cpu_usage()

uint8_t system_get_cpu_usage ( void )

Calculates the total real-time CPU utilization. Requires CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS to be enabled.

Returns
Current CPU usage as a percentage (0 to 100).

Definition at line 75 of file system.c.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_get_free_heap()

uint32_t system_get_free_heap ( void )

Gets the current available free heap size (RAM).

Returns
Available heap size in bytes.

Definition at line 69 of file system.c.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_get_max_temperature()

float system_get_max_temperature ( void )

Gets the highest recorded CPU temperature since boot.

Returns
The maximum temperature in degrees Celsius.

Definition at line 64 of file system.c.

References max_measured_temp, and system_get_temperature().

Referenced by system_print_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ system_get_min_free_heap()

uint32_t system_get_min_free_heap ( void )

Gets the minimum ever free heap size since boot (watermark). This is crucial for detecting close-to-OOM (Out Of Memory) conditions.

Returns
Minimum free heap size in bytes.

Definition at line 71 of file system.c.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_get_reset_reason()

int system_get_reset_reason ( void )

Gets the reason for the last system reset.

Returns
The reset reason code (maps to esp_reset_reason_t).

Definition at line 122 of file system.c.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_get_tasks_list()

void system_get_tasks_list ( char * buffer,
size_t buffer_len )

Formats raw FreeRTOS statistics into a human-readable task list. Requires CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS to be enabled. Writes a table containing task names, status, priority, and remaining stack space.

Warning
vTaskList does not perform bounds checking. Ensure the buffer is large enough (at least 40 bytes per task).
Parameters
[out]bufferDestination character buffer to write the table string.
[in]buffer_lenSize of the destination buffer in bytes.

Definition at line 106 of file system.c.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_get_temperature()

float system_get_temperature ( void )

Gets the current internal CPU temperature.

Returns
The current temperature in degrees Celsius, or 0.0f if the sensor is uninitialized.

Definition at line 50 of file system.c.

References max_measured_temp, and temp_sensor.

Referenced by system_get_max_temperature(), and system_print_info().

Here is the caller graph for this function:

◆ system_get_uptime_ms()

int64_t system_get_uptime_ms ( void )

Gets the system uptime since boot.

Returns
Total uptime in milliseconds.

Definition at line 120 of file system.c.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_get_version()

const char * system_get_version ( void )

Gets the active firmware build version. Matches the Git commit short hash (appends '-d' if local modifications exist).

Returns
Pointer to a null-terminated string containing the version.

Definition at line 118 of file system.c.

Referenced by system_print_info().

Here is the caller graph for this function:

◆ system_init()

esp_err_t system_init ( void )

Initializes the system monitoring component. Sets up the internal temperature sensor and tracks initial values.

Returns
ESP_OK on success, or an appropriate error code on failure.

Definition at line 27 of file system.c.

References LOGE, LOGI, LOGW, max_measured_temp, and temp_sensor.

Referenced by app_main().

Here is the caller graph for this function:

◆ system_print_info()

void system_print_info ( void )

Prints a complete, formatted overview of all system statistics to the console. Internally uses ESP_LOGI or printf to output a comprehensive snapshot of the device status.

Definition at line 162 of file system.c.

References sys_chip_info_t::cores, LOGI, sys_chip_info_t::model_name, sys_chip_info_t::revision, system_get_chip_info(), system_get_cpu_usage(), system_get_free_heap(), system_get_max_temperature(), system_get_min_free_heap(), system_get_reset_reason(), system_get_tasks_list(), system_get_temperature(), system_get_uptime_ms(), and system_get_version().

Referenced by app_main().

Here is the call graph for this function:
Here is the caller graph for this function: