Advanced: Creating Customized OSIs : Customizing API Definitions : General API Definitions : Software Counter APIs

Software Counter APIs
 
Sample Definition
Code Generated
Defines the type of a variable that holds a Software Counter value.
This API is used when the type of a Software Counter is required.
For example, the Timeouts Dispatch Function requires the “Time" that was read from the counter. The value of the "Time" is passed to the function using a "Software Counter Value Type".
For an Activity defined to be a Task:
genTmEvent_T1(uint16 currentTickVar, cgDoubleBufferType_T1* buff, uint8 counterIndex)
Software Counter Max Value(nameid)
Defines the maximum allowed value for a Software Counter, after which it overflows.
The API is used when handling the overflow of counters, used with Timeouts.
In the Timeouts Dispatch Function, generated in the file glob_func.c, there is a code section that subtracts the max value of the software counter from the value stored in the Timeout's time variable.
For counter named: ms_counter
API Definition: (uint16) -1
void onms_counter_OVERFLOW(void)
tm_999999998_TIME -= (uint32) 1 + ((uint16)(uint16) -1);
Get Software Counter Value(nameid, value)
$<value> = $<nameid>;
Defines the code for retrieving the current value of a Software Counter.
This API is used when the value of a Software counter is needed.
For example, the Timeouts Dispatch Function requires the current "Time" of the "Software Counter" to test for the expired Timeouts.
This API is used to retrieve the "current value", just before calling the ""Timeouts Dispatch Function"", in a Task's ISR's or Generic Activity generated as Function, Code frame, in the file: <module>.c.
For an Activity defined to be a Task:
API's Parameters:
value = currentTick
API Definition: $<value> = $<nameid>;
currentTick = ms_counter;
genTmEvent_T1(currentTick, &/*Old*/cgDoubleBufferOld_T1, ms_counter_INDEX);
Declare Software Counter(nameid)
extern SW_COUNTER_H $<nameid>;
Defines the code for declaring a Software Counter (OS Object).
This API is used when generating the code for declaring a Software Counter
The code is generated in the file type_def.h
Name: ms_counter
API definition: DECLARE_S_COUNTER($nameid);
Generated Code: DECLARE_S_COUNTER(ms_counter);
Define Software Counter(nameid)
SW_COUNTER_H $<nameid>;
Defines the code for defining a Software Counter (OS Object).
This API is used when generating the code for defining a Software Counter.
This code is generated in the file glob_dat.c
Name: ms_counter
API definition: DEFINE_S_COUNTER($nameid);
Generated Code: DEFINE_S_COUNTER(ms_counter);
Create Software Counter(nameid)
Defines the code for creating a Software Counter (OS Object).
This API is used when generating the code for creating a Software Counter.
This code is generated in the file glob_dat.c, in the function on_startup_code.
The function on_startup_code is called at the startup of the generated application.
Name: ms_counter
API definition: CREATE_S_COUNTER($nameid);
Generated Code: CREATE_S_COUNTER(ms_counter);
Destroy Software Counter(nameid)
Defines the code for destroying a Software Counter (OS Object).
This API is used when generating the code for destroying a Software Counter.
This code is generated in the file glob_dat.c, in the function on_exit_code.
The function on_exit_code is called at the end of the generated application.
Name: ms_counter
API definition: DESTROY_S_COUNTER($nameid);
Generated Code: DESTROY_S_COUNTER(ms_counter);