void scheduler_test_scheduling(){
    void scheduler_test_switch_to_next_guest(void *pdata);
    timer_init(timer_sched);
    /* 100Mhz -> 1 count == 10ns at RTSM_VE_CA15, fast model*/
    timer_set_interval(timer_sched, 1000000);   
    timer_add_callback(timer_sched, &scheduler_test_switch_to_next_guest);
    timer_start(timer_sched);


    timer_add_callback(timer_sched, &extra_timer_callback);
}
Exemple #2
0
void _button_check_press(void *data) {
    long currenttime;
    button_t *button = (button_t *) data;

    currenttime = timer_get_uptime_millis();

    /* ignore everything for 20 ms after a state change for debouncing */
    if (currenttime - button->lastpressed > BUTTON_BOUNCE_IGNORE_TIME) {
        if (!(*(button->port) & button->bit)) {     /* button pressed */
            button->isdepressed = 1;
            button->lastpressed = currenttime;
        } else if (button->isdepressed) {           /* button released */
            button->isdepressed = 0;
            button->timespressed++;
            button->lastpressed = currenttime;

            if (button->timespressed == 1) {
                /* start timer for counting additional button presses */
                if (!timer_add_callback(_button_double_press_window_closed, button, BUTTON_DOUBLE_PRESS_WINDOW, 1)) {
                    /* couldn't register callback -> ignore presss */
                    button->timespressed = 0;
                }
            }
        }
    }
}
hvmm_status_t hvmm_tests_vgic(void)
{
    /* VGIC test 
     *  - Implementation Not Complete
     *  - TODO: specify guest to receive the virtual IRQ
     *  - Once the guest responds to the IRQ, Virtual Maintenance Interrupt service routine should be called
     *      -> ISR implementation is empty for the moment
     *      -> This should handle completion of deactivation and further injection if there is any pending virtual IRQ
     */
    timer_add_callback(timer_sched, &callback_timer);
    return HVMM_STATUS_SUCCESS;
}
Exemple #4
0
void button_init(button_t *button, unsigned char volatile near *portdd, unsigned char volatile near *port, int bit) {
    /* set data direction in */
    *portdd |= bit;

    button->port = port;
    button->bit = bit;
    button->single_press_callback = NULL;
    button->double_press_callback = NULL;
    button->isdepressed = 0;
    button->lastpressed = 0;
    button->timespressed = 0;

    timer_add_callback(_button_check_press, button, BUTTON_CHECK_INTERVAL, 0);
}
Exemple #5
0
static int LogStat(lua_State *L){
	if (lua_gettop(L) == 4 && lua_isstring(L, 1) && lua_isnumber(L, 2) && lua_isnumber(L, 3) && lua_isstring(L, 4)){
        strcpy(s_stat_file_name, (const char *)lua_tostring(L, 1));
        s_stat_file_max_linenum = (int)lua_tonumber(L, 2);
        int ms = (int)lua_tonumber(L, 3);
        strcpy(s_stat_file_dir, (const char *)lua_tostring(L, 4));
        timer_add_callback(log_stat_timer, ms, NULL);
        s_stat_file = fopen(s_stat_file_name, "w+");
        if(s_stat_file == NULL){
            LOG_ERROR("open file fail %s %s", s_stat_file_name, strerror(errno));
            lua_pushboolean(L, false);
            return 1;
        }else{
            lua_pushboolean(L, true);
            return 1;
        }
	}
    lua_pushboolean(L, false);
    return 1;
}