LPCUSB, USBCDC; A reply to thread-16477

A reply to thread-16477

http://www.keil.com/forum/docs/thread16477.asp

I tried to post something on thread-16477, but somehow failed, and lost my original writing. After that, it seems thread-16477 has been touched, and updated with nothing.

Parents
  • ==> \LPCUSB\target\examples\main_serial.c

    /**
            Local function to handle incoming bulk data
    
            @param [in] bEP
            @param [in] bEPStatus
     */
    static void BulkOut(U8 bEP, U8 bEPStatus)
    {
            int i, iLen;
    
            if (fifo_free(&rxfifo) < MAX_PACKET_SIZE) {
                    // may not fit into fifo
                    return;    // Here!!!
            }
    
            // get data from USB into intermediate buffer
            iLen = USBHwEPRead(bEP, abBulkBuf, sizeof(abBulkBuf));
            for (i = 0; i < iLen; i++) {
                    // put into FIFO
                    if (!fifo_put(&rxfifo, abBulkBuf[i])) {
                            // overflow... :(
                            ASSERT(FALSE);
                            break;
                    }
            }
    }
    

    If there is not enough space in the rxfifo (rxdata), the ISR function BulkOut() returns.

    In such a case, the EP_SLOW bit in USBDevIntClr Register had already been set (interrupt cleared) by the major ISR function USBHwISR(). But the bEP is still full with data, so the Host application will not be able to write anything into this bEP (OUT-NAK), then, the ISR function BulkOut() will no longer be triggered.

    The data in bEP will never be processed. This is a dead-end.

Reply
  • ==> \LPCUSB\target\examples\main_serial.c

    /**
            Local function to handle incoming bulk data
    
            @param [in] bEP
            @param [in] bEPStatus
     */
    static void BulkOut(U8 bEP, U8 bEPStatus)
    {
            int i, iLen;
    
            if (fifo_free(&rxfifo) < MAX_PACKET_SIZE) {
                    // may not fit into fifo
                    return;    // Here!!!
            }
    
            // get data from USB into intermediate buffer
            iLen = USBHwEPRead(bEP, abBulkBuf, sizeof(abBulkBuf));
            for (i = 0; i < iLen; i++) {
                    // put into FIFO
                    if (!fifo_put(&rxfifo, abBulkBuf[i])) {
                            // overflow... :(
                            ASSERT(FALSE);
                            break;
                    }
            }
    }
    

    If there is not enough space in the rxfifo (rxdata), the ISR function BulkOut() returns.

    In such a case, the EP_SLOW bit in USBDevIntClr Register had already been set (interrupt cleared) by the major ISR function USBHwISR(). But the bEP is still full with data, so the Host application will not be able to write anything into this bEP (OUT-NAK), then, the ISR function BulkOut() will no longer be triggered.

    The data in bEP will never be processed. This is a dead-end.

Children
More questions in this forum