Advanced: Creating Customized OSIs : Customizing API Definitions : General API Definitions : Timer APIs

Timer APIs
 
Sample Definition
Code Generated
Defines the type of a variable that holds a Timer value.
Timer Max Value(nameid)
Defines the maximum allowed value of a Timer, after which it overflows.
Get Timer Value(nameid, value, itstaskid)
Defines the code for retrieving the current value of a Timer.
Declare Timer(nameid, itstaskid)
?<begin>$<CK_defineThisAlarm> ?<==> yes ?<?>extern void tim_hndlr_$<nameid>();
Defines the code for declaring a Timer (OS Object).
This API is used when generating the code for declaring a Timer
The code is generated in the file type_def.h
Name: timer_10ms
API definition: DECLARE_TIMER($nameid);
Generated Code: DECLARE_TIMER(timer_10ms);
Define Timer(nameid, itstaskid)
"?<begin>$<CK_defineThisAlarm> ?<==> yes ?<?>void tim_hndlr_$<nameid> ()
GENERATE_EVENT($<nameid>);
Defines the code for defining a Timer (OS Object).
This API is used when generating the code for defining a Software Timer.
The code is generated in the file glob_dat.c
Name: timer_10ms
API definition: DEFINE_TIMER($nameid);
Generated Code: DEFINE_TIMER(timer_10ms);
Create Timer(nameid, itstaskid)
Defines the code for creating a Timer (OS Object).
This API is used when generating the code for creating a Software Timer.
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: timer_10ms
API definition: CREATE_TIMER($nameid);
Generated Code: CREATE_TIMER(timer_10ms);
Destroy Timer(nameid, itstaskid)
Defines the code for destroying a Timer (OS Object).
This API is used when generating the code for destroying a Software Timer.
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: timer_10ms
API definition: DESTROY_TIMER($nameid);
Generated Code: DESTROY_TIMER(timer_10ms);
Install Relative Timer(nameid, value, cycle, counter, itstaskid)
install_mainloop_timer((unsigned long int) ($<value>) + (?<begin>$<counter> ?<==> ?<?>ms_counter?<:>$<counter>?<end>), tim_hndlr_$<nameid>);
Defines the code for installing a Timer (OS Object) with a relative value.
This API is used when installing a Timer using relative time.
For example, when using a scheduling operation with an Event, that uses a Timer for this operation. The generated code will use the definition of this API to install the timer.
The code for this operation will be generated in the file <module>.c
For an Event defined to be a Task-Event.
API's Parameters:
counter = ms_counter
install_mainloop_rel_timer((unsigned long int) ($<value>) + (?<begin>$<counter> ?<==> ?<?>ms_counter?<:>$<counter>?<end>), tim_hndlr_$<nameid>);
install_mainloop_rel_timer((unsigned long int) (100) + (ms_counter), tim_hndlr_EV);
Install Absolute Timer(nameid, value, cycle, counter, itstaskid)
Defines the code for installing a Timer (OS Object) with an absolute value.
This API is used when installing a Timer using absolute time.
For example, when using a scheduling operation with an Event that uses a Timer for this operation. The generated code will use the definition of this API to install the timer.
The code for this operation will be generated in the file <module>.c
For an Event defined to be a Task-Event.
API's Parameters:
counter = ms_counter
install_mainloop_abs_timer((unsigned long int) ($<value>) + (?<begin>$<counter> ?<==> ?<?>ms_counter?<:>$<counter>?<end>), tim_hndlr_$<nameid>);
install_mainloop_abs_timer((unsigned long int) (100) + (ms_counter), tim_hndlr_EV);
Clear Timer(nameid, itstaskid)
Defines the code for clearing a Timer (OS Object).
This API is used in the code section that handles the Timer expiration.
If the Timer was tested to be expired, the Event related to this Timer is generated.
Just before generating the Event, the timer is cleared.
For an Event defined to be a Task-Event, using a Timer.
API's Parameters: nameid = EV
API definition: Clear_Timer(tim_hndlr_$nameid)
Clear_Timer(tim_hndlr_EV)
Test for Timer Expiration(nameid, itstaskid)
Defines the code for testing a Timer (OS Object) for expiration.
This API is used in the code section that handles the Timer expiration.
This API definition is used in order to find out if a timer has expired.
The code related to this API is generated in the file <module>.c
For an Event defined to be a Task-Event, using a Timer.
API's Parameters: nameid = EV
API definition: TEST_TIMER(tim_hndlr_$nameid)
Generated Code: TEST_TIMER(tim_hndlr_EV)
Cancel Timer(nameid, itstaskid)
Defines the code for canceling a Timer.
This API is used just before installing the Timer.
If the Event related to the timer has the Design-Attribute: "CK_cancelBeforeSet" with the value "yes", then the definition of this API is put before the timer installation code.
For an Event defined to be a Task-Event, using a Timer.
API's Parameters: nameid = EV
API definition: TEST_TIMER(tim_hndlr_$nameid)
Generated Code: TEST_TIMER(tim_hndlr_EV)