/*------------------------------------------- | Name:at91_poll_status | Description: | Parameters: | Return Type: | Comments: | See: ---------------------------------------------*/ static short at91_spi_poll_status (unsigned long bit, unsigned int delay) { spi_timeout = TIMEOUT_OK; OS_SetTimerPeriod (&dev_at91sam7s_spi_timer, delay); OS_StartTimer (&dev_at91sam7s_spi_timer); while (!(*AT91C_SPI_SR & bit) && (spi_timeout != TIMEOUT_KO )) ; OS_StopTimer(&dev_at91sam7s_spi_timer); return (spi_timeout); }
void GUI_X_WaitEventTimed(int Period) { static OS_TIMER Timer; static int Initialized; if (Period > 0) { if (Initialized != 0) { OS_DeleteTimer(&Timer); } Initialized = 1; OS_CreateTimer(&Timer, GUI_X_SignalEvent, Period); OS_StartTimer(&Timer); GUI_X_WaitEvent(); } }
/***************************************************************************** * FUNCTION * ResetOsTimer * DESCRIPTION * Resets the actual OS timer based on the shortest remaining * timer. * PARAMETERS * curTime [IN] * RETURNS * void *****************************************************************************/ static void ResetOsTimer(TimeT curTime) { EvmTimer *timer; ListEntry *node; TimeT timeElapsed; TimeT minWait = (TimeT) (-1); /* Look for timers scheduled in the future */ if (!IsListEmpty(&BTC(timerList))) { node = GetHeadList(&BTC(timerList)); while (node != &BTC(timerList)) { timer = (EvmTimer*) node; node = node->Flink; timeElapsed = curTime - timer->startTime; /* If the timer must elapse sooner than minWait, adjust minWait */ if (timeElapsed < timer->time) { minWait = min(minWait, timer->time - timeElapsed); } else { OS_Report("[TIMER] Timer(%x) timeout (%u, %u) when reset OS timer. Just Fire timer", timer, timeElapsed, timer->time); TimerFired(); return; } } } /* Are any timers in the future? */ if (minWait < (TimeT) (-1)) { OS_StartTimer(minWait, TimerFired); } else { OS_CancelTimer(); } }