static void vcomBulkOut(uint8_t EP, uint8_t EPStatus) { int i, n; if (fifoFree(&rxfifo) < MAX_PACKET_SIZE) return; /* may not fit, we drop the data */ n = usbRead(EP, _vcom_buffer, sizeof(_vcom_buffer)); for (i = 0; i < n; i++) fifoPut(&rxfifo, _vcom_buffer[i]); }
void fifoPut(fifo_t * fifo, int fd) { /* FIXME: mutex around struct data.. */ int cnt=0; sys_sem_wait( fifo->sem ); /* enter critical */ LWIP_DEBUGF( SIO_FIFO_DEBUG,("fifoput: len%d dat%d empt%d --> ", fifo->len, fifo->dataslot, fifo->emptyslot ) ); if ( fifo->emptyslot < fifo->dataslot ) { cnt = read( fd, &fifo->data[fifo->emptyslot], fifo->dataslot - fifo->emptyslot ); } else { cnt = read( fd, &fifo->data[fifo->emptyslot], FIFOSIZE-fifo->emptyslot ); } fifo->emptyslot += cnt; fifo->len += cnt; LWIP_DEBUGF( SIO_FIFO_DEBUG,("len%d dat%d empt%d\n", fifo->len, fifo->dataslot, fifo->emptyslot ) ); if ( fifo->len > FIFOSIZE ) { printf( "ERROR: fifo overrun detected len=%d, flushing\n", fifo->len ); fifo->dataslot = 0; fifo->emptyslot = 0; fifo->len = 0; } if ( fifo->emptyslot == FIFOSIZE ) { fifo->emptyslot = 0; LWIP_DEBUGF( SIO_FIFO_DEBUG, ("(WRAP) ") ); sys_sem_signal( fifo->sem ); /* leave critical */ fifoPut( fifo, fd ); return; } if ( fifo->getWaiting ) { fifo->getWaiting = FALSE; sys_sem_signal( fifo->getSem ); } sys_sem_signal( fifo->sem ); /* leave critical */ return; }
/** * Signal handler for ttyXX1 to indicate bytes received * one per interface is needed since we cannot send a instance number / pointer as callback argument (?) */ static void signal_handler_IO_1( int status ) { LWIP_UNUSED_ARG(status); LWIP_DEBUGF(SIO_DEBUG, ("SigHand: rxSignal channel 1\n")); fifoPut( &statusar[1].myfifo, statusar[1].fd ); }
void vcomPutchar(int c) { vicDisable(INT_CHANNEL_USB); fifoPut(&txfifo, c); usbEnableNAKInterrupts(INACK_BI); vicEnable(INT_CHANNEL_USB); }