COTmrCreate

COTmrCreate

Description

This function creates the defined action and links this action into the event timer list at the correct timing.

Prototype

CPU_INT16S COTmrCreate(CO_TMR      *tmr,
                       CPU_INT32U   startTime,
                       CPU_INT32U   cycleTime,
                       CO_TMR_FUNC  func,
                       void        *para);

ParameterDescription
tmrPointer to timer structure
startTimedelta time in ticks for the first timer event
cycleTimeif != 0, the delta time in ticks for the cyclic timer events
funcpointer to the action callback function
parapointer to the callback function parameter

Returned Value

>=0    the action identifier

<0     an error is detected

Example

The following example installs a cyclic called function AppCyclicFunc() to the CANopen node AppNode. The timed function will be called the first time after 10ms and then every 25ms with the parameter 0xcafe.


    CPU_INT16S  aid;
    :
    aid = COTmrCreate(&(AppNode.Tmr), 10, 25, AppCyclicFunc, 0xcafe);
    if (aid >= 0) {
        /* tid holds the timer identifier */
    } else {
        /* error during creation of timed action */
    }
    :


Note: The example assumes, that the application callback function AppCyclicFunc() is implemented with the correct prototype. The configuration setting CO_TMR_TICKS_PER.SEC is assumed to be 1000, e.g. 1 tick is equal to 1ms. See CANopen Config Manual for details.