AM62Ax 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:103
status
uint32_t status
Definition: tisci_lpm.h:1
TaskP_loadGetTotalCpuLoad
uint32_t TaskP_loadGetTotalCpuLoad()
Get total CPU load including all task and ISR execution time.
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:92
TaskP_Params::args
void * args
Definition: TaskP.h:109
DebugP_log
#define DebugP_log(format,...)
Function to log a string to the enabled console.
Definition: DebugP.h:227
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:105
TaskP_Params::taskMain
TaskP_FxnMain taskMain
Definition: TaskP.h:110
value
uint32_t value
Definition: tisci_otp_revision.h:2
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:106
TaskP.h
TaskP_Load::cpuLoad
uint32_t cpuLoad
Definition: TaskP.h:81
__attribute__
void __attribute__((__noreturn__))(*Bootloader_SelfCoreJump)(void)
Function pointer to jump a self core to specific code location in AM62x SOC.
Definition: bootloader_soc.h:67
TaskP_Params::priority
uint32_t priority
Definition: TaskP.h:108
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:175
TaskP_Params::stack
uint8_t * stack
Definition: TaskP.h:107
TaskP_Params_init
void TaskP_Params_init(TaskP_Params *params)
Set default values to TaskP_Params.