Пример #1
0
void main() {
  usb_init();
  usb_set_idle_handler(idler);

  while (1) {
    idler();
    usb_poll();
  }
}
Пример #2
0
TInt WaitForIdle()
	{// Wait for chunk to be destroyed and then for the chunk cleanup dfc to run.
	for (TUint i = 0; i < 2; i++)
		{
		NFastSemaphore s(0);
		TDfc idler(&signal_sem, &s, Kern::SvMsgQue(), 0);	// supervisor thread, priority 0, so will run after destroyed DFC
		NTimer timer(&signal_sem, &s);
		idler.QueueOnIdle();
		timer.OneShot(NKern::TimerTicks(5000), ETrue);	// runs in DFCThread1
		NKern::FSWait(&s);	// wait for either idle DFC or timer
		TBool timeout = idler.Cancel();	// cancel idler, return TRUE if it hadn't run
		TBool tmc = timer.Cancel();	// cancel timer, return TRUE if it hadn't expired
		if (!timeout && !tmc)
			NKern::FSWait(&s);	// both the DFC and the timer went off - wait for the second one
		if (timeout)
			return KErrTimedOut;
		}
	return KErrNone;
	}