Espressif ESP32-S2 Programming Manual page 880

Table of Contents

Advertisement

Chapter 2. API Reference
BaseType_t
xTaskCallApplicationTaskHook(TaskHandle_t
Calls the hook function associated with xTask. Passing xTask as NULL has the effect of calling the Running
tasks (the calling task) hook function.
Parameters
• xTask: Handle of the task to call the hook for.
• pvParameter: Parameter passed to the hook function for the task to interpret as it wants. The
return value is the value returned by the task hook function registered by the user.
TaskHandle_t
xTaskGetIdleTaskHandle(void)
xTaskGetIdleTaskHandle() is only available if INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeR-
TOSConfig.h.
Simply returns the handle of the idle task. It is not valid to call xTaskGetIdleTaskHandle() before the scheduler
has been started.
UBaseType_t uxTaskGetSystemState(TaskStatus_t *const pxTaskStatusArray, const UBase-
configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for uxTaskGetSystemState() to
be available.
uxTaskGetSystemState() populates an TaskStatus_t structure for each task in the system. TaskStatus_t struc-
tures contain, among other things, members for the task handle, task name, task priority, task state, and total
amount of run time consumed by the task. See the TaskStatus_t structure definition in this file for the full
member list.
NOTE: This function is intended for debugging use only as its use results in the scheduler remaining suspended
for an extended period.
Example usage:
// This example demonstrates how a human readable table of run time stats
// information is generated from raw data provided by uxTaskGetSystemState().
// The human readable table is written to pcWriteBuffer
void vTaskGetRunTimeStats( char *pcWriteBuffer )
{
TaskStatus_t *pxTaskStatusArray;
volatile UBaseType_t uxArraySize, x;
uint32_t ulTotalRunTime, ulStatsAsPercentage;
// Make sure the write buffer does not contain a string.
*pcWriteBuffer = 0x00;
// Take a snapshot of the number of tasks in case it changes while this
// function is executing.
uxArraySize = uxTaskGetNumberOfTasks();
// Allocate a TaskStatus_t structure for each task.
// allocated statically at compile time.
pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
if( pxTaskStatusArray != NULL )
{
// Generate raw status information about each task.
uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &
ulTotalRunTime );
// For percentage calculations.
ulTotalRunTime /= 100UL;
// Avoid divide by zero errors.
if( ulTotalRunTime > 0 )
{
// For each populated position in the pxTaskStatusArray array,
Espressif Systems
Type_t uxArraySize, uint32_t *const pulTotalRunTime)
869
Submit Document Feedback
xTask, void *pvParameter)
An array could be
(continues on next page)
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF