AM263Px MCU+ SDK  10.01.00
Task

Attention
This module is not applicable for NO RTOS environment

Features Supported

  • APIs to create and destroy tasks
  • APIs to yeild a task
  • Ability to specify task priority, task entry function, stack pointer, stack size
  • Ability to get task and CPU load

Features NOT Supported

NA

Important Usage Guidelines

  • On R5F, and M4F, make sure memory provided as stack is 32b aligned and size is also multiple of 32b
  • Stack and stack size MUST be provided by application and is not allocated internally

Example Usage

Include the below file to access the APIs,

Example usage to define task objects and parameters

/* Task priority, stack, stack size and task objects, these MUST be global's */
#define MY_TASK_PRI (8U)
#define MY_TASK_STACK_SIZE (4*1024U)
uint8_t gMyTaskStack[MY_TASK_STACK_SIZE] __attribute__((aligned(32)));
TaskP_Object gMyTask;
/* Application specific task arguments */
typedef struct {
uint32_t value;
} MyTask_Args;
MyTask_Args gMyTask_args;

Example task main function

/* Task entry point or main function for this task */
void myTaskMain(void *args)
{
MyTask_Args *myArgs = (MyTask_Args*)args;
DebugP_assert(myArgs != NULL);
/* myArgs points to structure pointer passed during TaskP_construct */
/* do something in the task */
/* when done call below function, DO NOT 'return` from this function */
}

Example usage to create a task

int32_t status;
TaskP_Params myTaskParams; /* this need not be global variable */
TaskP_Params_init(&myTaskParams);
myTaskParams.name = "MY_TASK";
myTaskParams.stackSize = MY_TASK_STACK_SIZE;
myTaskParams.stack = gMyTaskStack;
myTaskParams.priority = MY_TASK_PRI;
myTaskParams.args = &gMyTask_args;
myTaskParams.taskMain = myTaskMain;
status = TaskP_construct(&gMyTask, &myTaskParams);

Example usage to get task and CPU load

TaskP_Load taskLoad;
uint32_t cpuLoad;
DebugP_log(" LOAD: CPU = %2d.%2d %%\r\n", cpuLoad/100, cpuLoad%100 );
TaskP_loadGet(&gMyTask, &taskLoad);
DebugP_log(" LOAD: %s = %2d.%2d %%\r\n", taskLoad.name, taskLoad.cpuLoad/100, taskLoad.cpuLoad%100 );

API

APIs for Task

TaskP_Params
Parameters passed during TaskP_construct.
Definition: TaskP.h:107
args
void * args
Definition: hsmclient_msg.h:4
TaskP_Load
Task load statistics.
Definition: TaskP.h:76
TaskP_Load::name
const char * name
Definition: TaskP.h:78
TaskP_Object
Opaque task object used with the task APIs.
Definition: TaskP.h:96
TaskP_Params::args
void * args
Definition: TaskP.h:113
DebugP_log
#define DebugP_log(format,...)
Function to log a string to the enabled console.
Definition: DebugP.h:225
TaskP_construct
int32_t TaskP_construct(TaskP_Object *obj, TaskP_Params *params)
Create a task object.
TaskP_Params::name
const char * name
Definition: TaskP.h:109
__attribute__
struct lld_sockaddr __attribute__
This is the SecureBoot Stream type which holds the data for a specific bootloader to HSM call....
TaskP_Params::taskMain
TaskP_FxnMain taskMain
Definition: TaskP.h:114
TaskP_exit
void TaskP_exit(void)
Exit current task.
SystemP_SUCCESS
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
TaskP_Params::stackSize
uint32_t stackSize
Definition: TaskP.h:110
TaskP.h
TaskP_Load::cpuLoad
uint32_t cpuLoad
Definition: TaskP.h:81
TaskP_Params::priority
uint32_t priority
Definition: TaskP.h:112
TaskP_loadGetTotalCpuLoad
uint32_t TaskP_loadGetTotalCpuLoad(void)
Get total CPU load including all task and ISR execution time.
TaskP_loadGet
void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad)
Get task load.
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:177
TaskP_Params::stack
uint8_t * stack
Definition: TaskP.h:111
TaskP_Params_init
void TaskP_Params_init(TaskP_Params *params)
Set default values to TaskP_Params.