Beispiel #1
0
static void delay_t(int ticks)
{
    int32_t t;
    int tenTicks = ticks * 15;      //~~~

    t = _getticks() + tenTicks;
    while (_getticks() < t) ; /* NULL LOOP */
}
static void cfe_autostart(void)
{
    char *env;
    int noauto = 0;
    char ch = 0;
    uint64_t now;
    uint64_t timeout;
    int delay = 1;      /* 1s */

    env = env_getenv("STARTUP");
    if (!env) return;

    leds_on();

    xprintf("Auto boot\n");

    now = _getticks();
    timeout = now + delay *(cfe_cpu_speed/(CPUCFG_CYCLESPERCPUTICK));

    while(now < timeout)
    {
        while (console_status()) {
            console_read(&ch,1);
            if (ch == 3)
                noauto = TRUE;	/* Ctrl-C means no auto */
        }

        if (recovery_button_status())
        {
            noauto = TRUE;
        }

        if (noauto == TRUE)
            break;

        now = _getticks();
    }

    leds_off();

    if (noauto) {
	xprintf("Startup canceled\n");
	return;
	}

    ui_docommands(env);
}
Beispiel #3
0
void cfe_usleep(int usec)
{
    uint32_t newcount;
    uint32_t now;

    /* XXX fix the wrap problem */

    now = _getticks();
    newcount = now + usec*cfe_clocks_per_usec;

    if (newcount < now)  	/* wait for wraparound */
        while (_getticks() > now)
	    ;
    

    while (_getticks() < newcount)
	;
}
Beispiel #4
0
void cfe_timer_init(void)
{
    cfe_clocks_per_tick = CFE_CLOCKSPERTICK;
    cfe_clocks_per_usec = CFE_CLOCKSPERUSEC;
    if (cfe_clocks_per_usec == 0)
	cfe_clocks_per_usec = 1;    /* for the simulator */

    cfe_oldcount = _getticks();		/* get current COUNT register */
    cfe_ticks = 0;

    if (!cfe_timer_initflg) {
	cfe_bg_add(cfe_timer_task,NULL); /* add task for background polling */
	cfe_timer_initflg = 1;
	}
}
Beispiel #5
0
static void cfe_timer_task(void *arg)
{
    int32_t count;	
    int32_t deltaticks;
    int32_t clockspertick;

    clockspertick = CFE_CLOCKSPERTICK;

    count = _getticks();

    if (count >= cfe_oldcount) {
	deltaticks    = (count - cfe_oldcount) / clockspertick;
	cfe_remticks += (count - cfe_oldcount) % clockspertick;
	}
    else {
	deltaticks    = (cfe_oldcount - count) / clockspertick;
	cfe_remticks += (cfe_oldcount - count) % clockspertick;
	}

    cfe_ticks += deltaticks + (cfe_remticks / clockspertick);
    cfe_remticks %= clockspertick;
    cfe_oldcount = count;
}