EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #863 background imageLoading...
Page #863 background image
Chapter 2. API Reference
Functions
BaseType_t xTaskCreatePinnedToCore(TaskFunction_t pvTaskCode, const char *const pc-
Name, const uint32_t usStackDepth, void *const pvPa-
rameters, UBaseType_t uxPriority, TaskHandle_t *const
pvCreatedTask, const BaseType_t xCoreID)
Create a new task with a specified affinity.
This function is similar to xTaskCreate, but allows setting task affinity in SMP system.
Return pdPASS if the task was successfully created and added to a ready list, otherwise an error code defined
in the file projdefs.h
Parameters
pvTaskCode: Pointer to the task entry function. Tasks must be implemented to never return (i.e.
continuous loop), or should be terminated using vTaskDelete function.
pcName: A descriptive name for the task. This is mainly used to facilitate debugging. Max length
defined by configMAX_TASK_NAME_LEN - default is 16.
usStackDepth: The size of the task stack specified as the number of bytes. Note that this differs
from vanilla FreeRTOS.
pvParameters: Pointer that will be used as the parameter for the task being created.
uxPriority: The priority at which the task should run. Systems that include MPU support can
optionally create tasks in a privileged (system) mode by setting bit portPRIVILEGE_BIT of the
priority parameter. For example, to create a privileged task at priority 2 the uxPriority parameter
should be set to ( 2 | portPRIVILEGE_BIT ).
pvCreatedTask: Used to pass back a handle by which the created task can be referenced.
xCoreID: If the value is tskNO_AFFINITY, the created task is not pinned to any CPU, and the
scheduler can run it on any core available. Values 0 or 1 indicate the index number of the CPU
which the task should be pinned to. Specifying values larger than (portNUM_PROCESSORS - 1)
will cause the function to fail.
static BaseType_t xTaskCreate(TaskFunction_t pvTaskCode, const char *const pcName, const
uint32_t usStackDepth, void *const pvParameters, UBaseType_t
uxPriority, TaskHandle_t *const pxCreatedTask)
Create a new task and add it to the list of tasks that are ready to run.
Internally, within the FreeRTOS implementation, tasks use two blocks of memory. The first block is used to
hold the tasks data structures. The second block is used by the task as its stack. If a task is created using
xTaskCreate() then both blocks of memory are automatically dynamically allocated inside the xTaskCreate()
function. (see https://www.FreeRTOS.org/a00111.html). If a task is created using xTaskCreateStatic() then
the application writer must provide the required memory. xTaskCreateStatic() therefore allows a task to be
created without using any dynamic memory allocation.
See xTaskCreateStatic() for a version that does not use any dynamic memory allocation.
xTaskCreate() can only be used to create a task that has unrestricted access to the entire microcontroller
memory map. Systems that include MPU support can alternatively create an MPU constrained task using
xTaskCreateRestricted().
Example usage:
// Task to be created.
void vTaskCode( void * pvParameters )
{
for( ;; )
{
// Task code goes here.
}
}
// Function that creates a task.
void vOtherFunction( void )
{
static uint8_t ucParameterToPass;
TaskHandle_t xHandle = NULL;
(continues on next page)
Espressif Systems 852
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish