Syntax
VM_TIMER_ID_HISR vm_timer_create_hisr(
    VMINT8* timer_name
);
ContentsIndex
PreviousUpNext
vm_timer_create_hisr
Example
Syntax
VM_TIMER_ID_HISR vm_timer_create_hisr(
    VMINT8* timer_name
);
Description

Creates a HISR timer. Once the timer is created, it will fire repeatedly at the interval until the timer is deleted. The thread priority of a HISR timer is higher than the main thread. The callback of a HISR timer is invoked in the interrupt context. Therefore, the callback of a HISR timer should not be used to access any LinkIt SDK APIs. The callback should not use signal, mutex or thread API. But it can call the DCL API. It should only be used to perform fast operations, such as value updates.

Parameters
Parameters 
Description 
VMINT8* timer_name 
[IN] The timer name. It is used for debugging purpose. The length of the name cannot be more than 8 characters. Otherwise, it will be truncated. 
Returns

A timer handle. If the timer handle is a positive integer, it means the 

timer is created successfully. Otherwise, a negative integer is returned. 

Refer to VM_TIMER_RESULT for error code.

Example
VM_TIMER_ID_HISR hisr_id = NULL;
static VMINT num_flag = 0;
static void cuatomer_hisr_timer_proc(void* para)
{
    num_flag++;
   //cant use LinkIT API
}
static void customer_delete_timer_proc(VM_TIMER_ID_PRECISE tid, void* user_data)
{
    vm_log_debug("customer_delete_timer_proc delete timer num_flag = %d", num_flag);
    if(num_flag > 5)
    {
        vm_log_debug("customer_delete_timer_proc cancel timer");
        vm_timer_delete_hisr(hisr_id);
        vm_timer_delete_precise(tid);
     }
}

void customer_run_hisr_timer(void)
{
    hisr_id = vm_timer_create_hisr("HISR_TIMER");
    if(hisr_id != NULL)
    {
        vm_timer_set_hisr(hisr_id, cuatomer_hisr_timer_proc, 0, 1000, 1000);
        if(vm_timer_create_precise(1000, (vm_timer_precise_callback)customer_delete_timer_proc)<0)
        {
            vm_log_debug("create precise timer fail");
        }
    }
    else
    {
         vm_log_debug("create hisr timer fail");
     }
}
File

vmtimer.h

Group
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at support@toolsfactory.com.