Main function – Echelon FTXL User Manual

Page 215

Advertising
background image

FTXL User’s Guide

203

SNVT_volt_mil type. Any attempt to change the NV to an unsupported type

causes the device to reject the change and to revert the nciNvType CPNV to its
last-known good value.
The design of the example application is relatively simple. It includes a single C

source file (main.c), along with the FTXL LonTalk API files generated by the
LonTalk Interface Developer utility and a version of FtxlHandlers.c that has

been customized for this example application.

The following sections describe the application’s main() function, the application

task (appTask()) function, event handler functions, callback handler functions,

application-specific utility functions, and model file.

Main Function

The main() function is in the main.c file. The main() function initializes the

status for the application’s functional blocks, and then initializes the circuit map

for the logical circuit defined for tracking the device’s aggregated current usage.

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 initializes some global variables,

* creates the application task, and then starts

* multi-tasking.

*/

int main(void) {

unsigned fbIndex;

/* Initialize the FbStatus array. */
memset(FbStatus, 0, sizeof(FbStatus));
for (fbIndex = 0; fbIndex < FBIDX_count; fbIndex++) {

Advertising