void run () { int cnt; xprintf("receiver\n"); while(1) { bool ok = fifo.get(cnt); if (ok) { PRINTF("reading %d\n", cnt); } else { suspendCallerUntil(NOW() + 1*SECONDS); } } }
void print(PtrLen<const char> str) { SingleHook<Video::VideoConsole> hook(host); if( +hook ) { fifo.get(*hook); hook->print(str); } else { fifo.put(str); } }
void CAN_Ctrl::IRQHandler(){ CanMsg msg; uint64_t iflags= can_mb_int_flag(can); #define CHECK_IFLAG(n) ((iflags & ((uint64_t)1<<(n))) != 0) if(CHECK_IFLAG(TX_MAILBOX)){ if(txFifo.get(msg)){ putIntoTxMailbox(msg); }else{ txInProgrss=false; //This may call upCall multiple times for one hal, but it is simpleset solution for (int i=0;i<numFilters;i++){ filters[i].owner->upCallWriteFinished(); } } can_mb_int_ack(can,TX_MAILBOX); } while(CHECK_IFLAG(FIFO_FLAG_DATARDY)){ if(numFilters>0){ int32_t matchedFilter = REG_RD(REG_RXFIR(can->base)) & 0x1FF; if(matchedFilter >= numFilters){ matchedFilter =numFilters-1; } getFromRxFifo(msg); if(filters[matchedFilter].owner_context->RxFifo.put(msg)){ filters[matchedFilter].owner->upCallDataReady(); } //Silently ignore FIFO overflow } can_mb_int_ack(can,FIFO_FLAG_DATARDY); iflags= can_mb_int_flag(can); } }