====== OSA : OS_Stimer_Alloc ======
**OS_Stimer_Alloc (var_stimer_id)**\\
=== ===
{{osa:ref:attr_call_not_int.png|Not allowed in interrupt}}{{osa:ref:attr_call_to.png|Service uses system timer}}
Allocate static timer for use. There should be at least one free static timer (check with [[en:osa:ref:allservices:OS_Stimer_Found|OS_Stimer_Found]] service)
##Number of static timers [[en:osa:ref:appendix:configuration#Timer control|OS_STIMERS]]## (1..32) must be specified in ##[[en:osa:ref:appendix:configuration|OSAcfg.h]]##. Size of static timers is set by ##[[en:osa:ref:appendix:configuration#Data types|OS_STIMER_SIZE]]## constant
Constant ##[[en:osa:ref:appendix:configuration#Timer control|OS_STIMERS_ENABLE_ALLOCATION]]## should be defined in ##[[en:osa:ref:appendix:configuration|OSAcfg.h]]##.
=== Call allowed: ===
Not in interrupt
=== Parameters: ===
{| class = "fpl"
|-
|//''var_stimer_id''//
|Variable of type ''unsigned char'' to store ID of allocated timer. When 0xFF - timer is not allocated
|}
=== Returns: ===
{| class = "fpl"
|-
|//''##[[en:osa:ref:allservices:OS_IsError|OS_IsError]]##()''//
|return ''true'' when no free timer to allocate
|}
=== Example: ===
void Task (void)
{
static unsigned char stimer_id;
for (;;) {
/*...*/
OS_Wait(OS_Stimer_Found()); // Wait for free static timer
OS_Stimer_Alloc(stimer_id); // Allocate it for use
OS_Stimer_Run(stimer_id, 100); // Now we use static timer through variable
do {
// ...
} while (!OS_Stimer_Check(stimer_id));
OS_Stimer_Free(stimer_id); // Make timer free
/*...*/
}
}
=== See also ===
* [[en:osa:ref:allservices:OS_Stimer_Alloc|OS_Stimer_Alloc]]
* [[en:osa:ref:allservices:OS_Stimer_Free|OS_Stimer_Free]]
* [[en:osa:ref:allservices:OS_Stimer_Found|OS_Stimer_Found]]
* [[en:osa:ref:allservices:OS_Stimer_Run|OS_Stimer_Run]]
* [[en:osa:ref:allservices:OS_Stimer_Break|OS_Stimer_Break]]
* [[en:osa:ref:allservices:OS_Stimer_Wait|OS_Stimer_Wait]]
* [[en:osa:ref:allservices:OS_Stimer_Delay|OS_Stimer_Delay]]
* [[en:osa:ref:allservices:OS_Stimer_Get|OS_Stimer_Get]]
* [[en:osa:ref:allservices:OS_Stimer_Check|OS_Stimer_Check]]
* [[en:osa:ref:allservices:OS_Stimer_IsRun|OS_Stimer_IsRun]]
* [[en:osa:ref:allservices:OS_Stimer_Pause|OS_Stimer_Pause]]
* [[en:osa:ref:allservices:OS_Stimer_Continue|OS_Stimer_Continue]]
----
* [[en:osa:ref:services:alphabetical|Alphabetical]]
* [[en:osa:ref:services:brieflist|All services]]
~~UP~~