A Basic REXIS Task

Writing a REXIS task is easy. The basic form is simply a C function running in an infinite loop:


void sample_task(unsigned arg0)


while (1)





A task function accepts one argument (named arg0 above) and must have the function return type of void. You may pass any value (cast as an unsigned int) as an argument to a task function when you create the task. For example, you may create a number of tasks based on the same C function, and use the argument to differentiate what the task may do:


// declared in rexis_api.h

/** \brief Create a new task. A task can be created in the initial main program, or in another task.


 * \param name              the name of the task. You can search for a task by its name. NOTE: REXIS

 *                          does not check for the uniqueness of the name. If there are multiple tasks

 *                          with the same name, the behavior is undefined.

 * \param func              name/address of the task function. Any C or asm function can be used.

 * \param prio              the task priority. Specify 0 for default priority (REXIS_PRIO_NORM).

 * \param stack_size        size of the stack for the task. NOTE: all REXIS allocated memory is from the

 *                          memory pool specified in the REXIS_SysInit() call. If you allocate too much

 *                          memory for a task, resource will be wasted. Specify 0 for default size

 *                          (REXIS_MIN_STACKSIZE).

 * \param arg0              initial argument to "func".

 * \return a "process ID" (or PID for short), which is an integer. Every task has a unique PID starting with "1".



int  REXIS_TaskCreate(char *name, void (*func)(unsigned), unsigned prio, unsigned stack_size, unsigned arg0);



// in your source file

REXIS_TaskCreate(“a task”, sample_task, 0, 0, 0);


The “Doxygen” style comment above describe the arguments to the REXIS_TaskCreate function. The single line in the sample code fragment is all that is needed to create a task in REXIS.