Changing the State of a µTasker Task

void uTaskerStateChange(UTASK_TASK pcTaskName, unsigned char ucSetState);

pcTaskName is the µTasker task reference. For example, the watchdog task has the reference TASK_WATCHDOG.
ucSetState is the new task state. For example, UTASKER_STOP.

The possible task states are:
  • UTASKER_STOP {this will stop a polling task but still allow it to run due to period timers or any events. Often tasks start in this state}
  • UTASKER_GO {this will allow a task to run. A task using a period timer will however only run once, whereas task without a periodic timer will effectively be set to polling mode (they will run as often as they can)}
  • UTASKER_SUSPENDED {this will suspend a task, which means that it will no longer react to a periodic timer}
  • UTASKER_ACTIVATE {this will allow a task to run once and so is equivalent to a wake-up event}


  • uTaskerStateChange is called to change the state of a µTasker task. It is useful to change between polling and event driven mode, to start a task which has not yet run, or to control a periodic task from responding to its periodic timer.

    The function doesn't return a result. If it doesn't find the referenced task it simple doesn't change anything.

    Project options

    There are no project options relevant to this function.


    Examples

    uTaskerStateChange(TASK_DEBUG, UTASKER_ACTIVATE); // allows the task TASK_DEBUG to run once. This can be used to start other tasks only another task is completely ready.

    uTaskerStateChange(OWN_TASK, UTASKER_GO); // switch the present task to polling mode of operation.

    uTaskerStateChange(OWN_TASK, UTASKER_STOP); // switch the present task from polling mode back to event mode of operation.

    uTaskerStateChange(TASK_WATCHDOG, UTASKER_SUSPENDED); // stop a task from responding to its periodic timer. (Note that the periodic timer is still operating). This example would cause the watchdog to fire since it will no longer be triggered by the watchdog task!

    uTaskerStateChange(TASK_WATCHDOG, UTASKER_STOP); // allow the task to respond again to its periodic timer. (Note that the periodic timer was still operating and so is still synchronised to its original period and not this state change call).

    Related functions

    uTaskerMonoTimer();
    uTaskerStopTimer();


    For more details about the use of the µTasker tasks see the documents µTasker Operating System Basics and First Steps for New Users.



    Please use the µTasker forum to ask specific questions.