Example #1
0
int vtimer_sleep(timex_t time)
{
    /**
     * Use spin lock for short periods.
     * Assumes that hardware timer ticks are shorter than a second.
     */
    if (time.seconds == 0) {
        unsigned long ticks = HWTIMER_TICKS(time.microseconds);
        if (ticks <= HWTIMER_SPIN_BARRIER) {
            hwtimer_spin(ticks);
            return 0;
        }
    }

    int ret;
    vtimer_t t;
    mutex_t mutex = MUTEX_INIT;
    mutex_lock(&mutex);

    t.action = vtimer_callback_unlock;
    t.arg = &mutex;
    t.absolute = time;

    ret = vtimer_set(&t);
    mutex_lock(&mutex);
    return ret;
}
Example #2
0
int vtimer_set_wakeup(vtimer_t *t, timex_t interval, kernel_pid_t pid)
{
    t->action = vtimer_callback_wakeup;
    t->arg = NULL;
    t->absolute = interval;
    t->pid = pid;
    return vtimer_set(t);
}
Example #3
0
int vtimer_set_msg(vtimer_t *t, timex_t interval, unsigned int pid, void *ptr){
    t->action = (void* ) msg_send_int;
    t->arg = ptr;
    t->absolute = interval;
    t->pid = pid; 
    vtimer_set(t);
    return 0;
}
Example #4
0
void vtimer_set_msg(vtimer_t *t, timex_t interval, kernel_pid_t pid, uint16_t type, void *ptr)
{
    t->action = vtimer_callback_msg;
    t->type = type;
    t->arg = ptr;
    t->absolute = interval;
    t->pid = pid;
    vtimer_set(t);
}
Example #5
0
int vtimer_set_msg(vtimer_t *t, timex_t interval, kernel_pid_t pid, void *ptr)
{
    t->action = vtimer_callback_msg;
    t->arg = ptr;
    t->absolute = interval;
    t->pid = pid;
    vtimer_set(t);
    return 0;
}
Example #6
0
int vtimer_set_wakeup(vtimer_t *t, timex_t interval, int pid) {
    int ret;
    t->action = (void*) thread_wakeup;
    t->arg = (void*) pid;
    t->absolute = interval;
    t->pid = 0;
    ret = vtimer_set(t);
    return ret;
}
Example #7
0
void display_set(uint8 channel,float value)
{
    static float ch1,ch2,ch3;
    switch(channel)
    {
        case DISP_THURST:
             ch1 =  value/98.1/3.3*65535;
             break;
        case DISP_PRESSURE:
             ch2 =  value/3.3*65535;
             break;
        case DISP_TEMP:
             ch3 =  value/100/3.3*65535;
             break;
    }     
    if(!vtimer_ovf(decim)) return;
    PWM_set(1,(uint16)ch1);
    PWM_set(2,(uint16)ch2);
    PWM_set(3,(uint16)ch3);
    vtimer_set(decim,REFRESH_DELAY);
}
Example #8
0
void display_init(void)
{
    decim = vtimer_alloc();
    PWM_init();   
    vtimer_set(decim,0);
}