void *update(void *ignored) { while(1) { /** await for a request to update the world **/ waitUpdate(); if(goFlag) return (void *)UPDATE_EXIT_CODE; //lprintf("updateThread: ping!"); /** request received; re-draw the world **/ mutex_lock(&worldLock); /* draw the target */ set_cursor_pos(GAMEBAR_ROW, oldTargetPos); print(1, GAMEBAR_BAR); set_cursor_pos(GAMEBAR_ROW, targetPos); print(1, GAME_TARGET); oldTargetPos=targetPos; /* draw the player */ set_cursor_pos(P1_ROW, oldP1Cursor); print(1, ERASE_CURSOR); set_cursor_pos(P1_ROW, p1Cursor); print(1, GAME_CURSOR); oldP1Cursor=p1Cursor; /* draw the score */ set_cursor_pos(22,0); printf("Score: %d\n",p1Score); /** unlock world **/ mutex_unlock(&worldLock); yield(-1); } }
void Sdr1kUsb::usbThread() { lock(); while (usbStatus >= 0) { waitUpdate(); if (usbStatus >= 0) { usbStatus = usbBulkWrite(outEP, outbuf, outcount); outcount = 0; if (usbStatus >= 0) { usbStatus = usbBulkRead(inEP, inbuf, 3); if (inbuf[0] != pstatus) { pstatus = inbuf[0]; signalInput(); } } } } signalInput(); unlock(); }