Delay Polling ============= .. code-block:: c while(1) { CheckButtons(); OSDelay(50); } Delay Polling Task ================== .. code-block:: c void delay_polling_task() { while(1) { CheckEnv(); SetFlags(); OSDelay(1); } } Wait and Run ============ .. code-block:: c bool isRunning = true; while(1) { OSSemPend(GoSem); while(isRunning) { PlayMusic(); } } * Simple pattern for controlling a loop. * The pend makes the loop wait until its signaled. * The boolean isRunning breaks the loop. Loop goes back to waiting. * isRunning should be set to TRUE before signaling the semaphore.