COTmrDelete

COTmrDelete

Description

This function deletes the defined action and removes the timer, if this was the last action for this timer event.

Prototype

CPU_INT16S COTmrDelete(CO_TMR      *tmr,
                       CPU_INT16S   actId);

ParameterDescription
tmrPointer to timer structure
actIdaction identifier, returned by COTmrCreate()

Returned Value

=0     successful operation

<0     an error is detected

Example

The following calls a critical function AppCritFunc() and installs a function AppEmcyFunc() to the CANopen node AppNode to guarantee a maximum runtime of 150ms. The timed function will be called after 150ms and perform emergency handling with the parameter 0xdead. If the AppCritFunc() is finished before 150ms, the timed emergency function call will be removed.


    CPU_INT16S  aid;
    :
    aid = COTmrCreate(&(AppNode.Tmr), 150, 0, AppEmcyFunc, 0xdead);
    if (aid >= 0) {
        <code>AppCritFunc()</code>;
        err = COTmrDelete(&(AppNode.Tmr), aid);
        if (err < 0) {
            /* error during deleting the timed action */
        }
    } else {
        /* error during creation of timed action */
    }
    :


Note: The example assumes, that the application callback function AppEmcyFunc() 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.