...
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.
Code Block | ||
---|---|---|
| ||
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.
...