The INSTALL_TIMEOUT macro has three arguments:
This allows the code to reuse the same timeout variable with different counters. The first argument is concatenated to the INSTALL macro, as shown here. In the code, a call like the following will be used:
This call will set a timeout to expire 10 ticks from the current time of
SYS_TIMER
. The macro itself will be defined as follows:This call will assign to
tm_999999962_TIME
which is a variable of type Timeout Variable Type the current counter value, help in currentTick plus the requested delay time help in D. In addition, the bittm_999999962_TM_MASK
is set to flag that this timeout is pending.A test for timeout expiration is carried out in the function:
genTmEvent_<CTRL_CHART_NAME>(<Timeout Variable Type>
currentTickVar, <Buffer> * buff, uint8 counterIndex)The third parameter,
uint8 counterIndex
, holds the index of the counter that is referred to in the current call to this function. Before each call to this function, the correct counter would be read into thecurrentTick
global variable.For each Timeout Variable, there are three options for code generation inside the
genTmEvent_
… function:
2.if(counterIndex == <ITS_COUNTER_NAME>_INDEX &&
cgTimeoutsMask & tm_999999993_TM_MASK &&
currentTickVar >= tm_999999993_TIME) {
GEN_IN_BUFF(tm_999999993, buff);
cgTimeoutsMask &= ~tm_999999993_TM_MASK;
}
3. If there is more than one counter that the Timeout Variable can be installed for, then the code will include the following provisions:
a. In the file, glob_dat.c a uint8 variabletm_999999993_counter¡
is generated, holding the index of the current relevant counter.
b. In the file macro_def.h,
along with the previous code that was generated for theINSTALL_TIMEOUT
macro, there is one more statement that keeps theINDEX
of the counter for which the timeout was installed.The index that is passed to the function is compared with the index of the counter that was used when the timeout was installed. This enables the application to identify the counter on which the timeout is pending.