Main function, Application task function – Echelon FTXL User Manual

Page 210

Advertising
background image

198

Example FTXL Applications

Main Function

The main() function is in the main.c file. The main() function creates an

operating system task by calling the OSTaskCreateExt() μC/OS-II operating
system function with the following arguments:

• Task entry point, which is a pointer to the appTask() function
• A NULL pointer for the arguments to the task
• A pointer to the top of the application stack
• The base priority of the task
• The ID of the task
• A pointer to the bottom of the application stack
• The size of the stack, in OS_STK units
• A NULL pointer for the extended task control block pointer

(OSTCBExtPtr)

• A value of 0 for the options

The main() function then calls the OSStart() μC/OS-II operating system function
to start the operating system. An application should not use the FTXL OSAL

functions for creating a task; if the application needs extra tasks, it should call

operating system functions directly. The OSAL functions for creating a task are
designed for creating FTXL LonTalk protocol stack tasks only.
The main() function is shown below.

/* The main function simply creates the application task
* and then starts multi-tasking

*/
int main(void) {

/* Create an application task to implement the main

control loop. */

OSTaskCreateExt(appTask,
NULL,

(void *)&appStack[APP_STACKSIZE],

OS_APPLICATION_PRIORITY_BASE,

OS_APPLICATION_PRIORITY_BASE,
appStack,

APP_STACKSIZE,

NULL,

0);

/* Start the operating system. The rest of the

* application executes under appTask.

*/

OSStart();

return 0;
}

Application Task Function

The application task function, appTask(), is in the main.c file. The appTask()

function performs the following tasks:

Advertising