AM261x MCU+ SDK: APIs for Task

| AM261x MCU+ SDK 26.00.00 |

Data Structures | Functions | Typedefs | Macros
APIs for Task
APIs for Driver Porting Layer

## Introduction

For more details and example usage, see Task

## Data Structures
struct | TaskP_Load
| Task load statistics. More...
struct | TaskP_Params
| Opaque task object used with the task APIs. More...

## Functions
void | TaskP_Params_init (TaskP_Params *params)
| Set default values to TaskP_Params. More...
int32_t | TaskP_construct (TaskP_Object *obj, const TaskP_Params *params)
| Create a task object. More...
void | TaskP_destruct (TaskP_Object *obj)
| Cleanup, delete, destruct a task object. More...
void * | TaskP_getHndl (TaskP_Object *obj)
| Return OS defined task handle. More...
void | TaskP_yield (void)
| Yield current task. More...
void | TaskP_exit (void)
| Exit current task. More...
void | TaskP_loadGet (TaskP_Object *obj, TaskP_Load *taskLoad)
| Get task load. More...
void | TaskP_loadUpdateAll (void)
| Updated task load statistics. More...
void | TaskP_loadResetAll (void)
| Reset task load statistics. More...
uint32_t | TaskP_loadGetTotalCpuLoad (void)
| Get total CPU load including all task and ISR execution time. More...

## Typedefs
typedef void(* | TaskP_FxnMain) (void *args)
| Entry point to the task. More...

## Macros
#define | TaskP_PRIORITY_LOWEST (0u)
| Value to be used for lowest priority task. More...
#define | TaskP_PRIORITY_HIGHEST (31u)
| Value to be used for highest priority task. More...
#define | TaskP_LOAD_UPDATE_WINDOW_MSEC (500u)
| The update rate at which TaskP_loadUpdateAll() is called. More...

## Macro Definition Documentation

## ◆ TaskP_PRIORITY_LOWEST

#define TaskP_PRIORITY_LOWEST (0u)

Value to be used for lowest priority task.

## ◆ TaskP_PRIORITY_HIGHEST

#define TaskP_PRIORITY_HIGHEST (31u)

Value to be used for highest priority task.

## ◆ TaskP_LOAD_UPDATE_WINDOW_MSEC

#define TaskP_LOAD_UPDATE_WINDOW_MSEC (500u)

The update rate at which TaskP_loadUpdateAll() is called.

## Typedef Documentation

## ◆ TaskP_FxnMain

typedef void(* TaskP_FxnMain) (void *args)

Entry point to the task.

## Function Documentation

## ◆ TaskP_Params_init()

void TaskP_Params_init | ( | TaskP_Params * | params | ) |

Set default values to TaskP_Params.

Strongly recommended to be called before seting values in TaskP_Params

Parameters

  params | [out] parameter structure to set to default

## ◆ TaskP_construct()

int32_t TaskP_construct | ( | TaskP_Object * | obj,
|  | const TaskP_Params * | params
| ) |  |

Create a task object.

Note
  With FreeRTOS MPU port, only privileged tasks can be created with this API. To create un-privileged tasks use `TaskP_constructRestricted`

Parameters

  obj | [out] Created object
  params | [in] Task create parameters

Returns
  SystemP_SUCCESS on success, SystemP_FAILURE on error

## ◆ TaskP_destruct()

void TaskP_destruct | ( | TaskP_Object * | obj | ) |

Cleanup, delete, destruct a task object.

Parameters

  obj | [in] task object

## ◆ TaskP_getHndl()

void* TaskP_getHndl | ( | TaskP_Object * | obj | ) |

Return OS defined task handle.

Parameters

  obj | [in] task object

Returns
  OS specific task handle

## ◆ TaskP_yield()

void TaskP_yield | ( | void |  | ) |

Yield current task.

## ◆ TaskP_exit()

void TaskP_exit | ( | void |  | ) |

Exit current task.

In FreeRTOS, task cannot simply return from a function. It needs to call vTaskDelete(NULL) instead. To keep the task exit portable, call this function when a task wants to terminate itself.

Note
  With FreeRTOS MPU port, an unprivileged task can't delete itself. Instead a privileged task should delete the same using TaskP_destruct. Hence this API will suspend the current task.

## ◆ TaskP_loadGet()

void TaskP_loadGet | ( | TaskP_Object * | obj,
|  | TaskP_Load * | taskLoad
| ) |  |

Get task load.

Parameters

  obj | [out] Created object
  taskLoad | [out] Task load statistics

## ◆ TaskP_loadUpdateAll()

void TaskP_loadUpdateAll | ( | void |  | ) |

Updated task load statistics.

This updates task load statistics for all tasks created with TaskP_construct(). This also updates idle task load.

This function is called, every TaskP_LOAD_UPDATE_WINDOW_MSEC msecs within the IDLE task. It is important that idle task get to run atleast once every TaskP_LOAD_UPDATE_WINDOW_MSEC msecs for the load statistics to be correct

## ◆ TaskP_loadResetAll()

void TaskP_loadResetAll | ( | void |  | ) |

Reset task load statistics.

Until load statistics is reset the load statistics keep getting accumulated

## ◆ TaskP_loadGetTotalCpuLoad()

uint32_t TaskP_loadGetTotalCpuLoad | ( | void |  | ) |

Get total CPU load including all task and ISR execution time.

Returns
  CPU load in units of percentage with 2 decimal point precision, i.e 1234 means 12.34%