Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
void  OSTaskRegSet (OS_TCB     *p_tcb,
                    OS_REG_ID   id,
                    OS_REG      value,
                    OS_ERR     *p_err)

File

Called from

Code enabled by

os_task.c

Task only

OS_CFG_TASK_REG_TBL_SIZE > 0

Description

µC/OS-III allows the user to store task-specific values in task registers. Task registers are different than CPU registers and are used to save such information as “errno,” which are common in software components. Task registers can also store task-related data to be associated with the task at run time such as I/O register settings, configuration values, etc. A task may have as many as as OS_CFG_TASK_REG_TBL_SIZE registers registers, and all registers have a data type of of OS_REG. However, OS_REG can  can be declared at compile time to be nearly anything (8-, 16-, 32-, 64-bit signed or unsigned integer, or floating-point).

As shown below, a task register is changed by calling calling OSTaskRegSet(), and read by calling calling OSTaskRegGet(). The desired task register is specified as an argument to these functions and can take a value between between 0 and  and OS_CFG_TASK_REG_TBL_SIZE-1.

Image Added

Files

os.h/os_task.Image Removedc

Prototype

Code Block
void  OSTaskRegSet (OS_TCB     *p_tcb,
                    OS_REG_ID   id,
                    OS_REG      value,
                    OS_ERR     *p_err)

Arguments

p_tcb

is a pointer to the TCB of the task you are setting. A NULL pointer indicates that the user wants to set the value of a task register of the calling task.

...

If OS_CFG_ARG_CHK_EN is set to 1 in DEF_ENABLED in os_cfg.h: if a valid task register identifier is not specified.

Returned Value

None

Required Configuration

OS_CFG_TASK_REG_TBL_SIZE must be greater than 0 in os_cfg.h. Refer to µC-OS-III Configuration Manual.

Callers

Application.

Notes/Warnings

None

Example Usage

Code Block
titleOSTaskRegSet() example usage
          OS_TCB  MyTaskTCB;
           
           
          void TaskX (void *p_arg)
          {
              OS_ERR  err;
              
           
              while (DEF_ON) {
                  :
                  OSTaskRegSet(&MyTaskTCB,
                                      5,
                                     23,
                                     &err);
                  /* Check "err" */
                  :
                  :
              }
          }