This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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
  • What I tried to post is something very similar to the above post, "Found a dead-end in main_serial.c".

    (Still struggle with my USB I/O Board.)

  • Found another thing in the LPCUSB Library:

    /* USB Controller */
    #define USB_BASE_ADDR      0xFFE0C000
    
    /* USBPortSel only available on the LPC2378 */
    #define USBPortSel         (*(volatile unsigned int *)(USB_BASE_ADDR + 0x110))
    
    /* USB Clock Control Registers */
    #define USBClkCtrl         (*(volatile unsigned int *)(USB_BASE_ADDR + 0xFF4))
    #define USBClkSt           (*(volatile unsigned int *)(USB_BASE_ADDR + 0xFF8))
    
    /* USB Device Interrupt Registers */
    #define USBIntSt           (*(volatile unsigned int *)(USB_BASE_ADDR + 0x1C0))
    #define USBDevIntSt        (*(volatile unsigned int *)(USB_BASE_ADDR + 0x200))
    

    The Address of USB Device Interrupt Registers (USBIntSt) is incorrect.

    But it seems that LPCUSB does not use this Register actually.

    wiki.sikken.nl/index.php
    The above Wiki of LPCUSB has been emptied. Don't know how to contact the maintainers of LPCUSB.