Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

usb cppidma problem

$
0
0

I use usb_dev_bulk which is in the C6748_StarterWare_1_20_04_01,it does not support CPPIDMA's functionality by default.

When I add CPPIDMA's functionality to usb_dev_bulk,I've had a  problem,In the host,I use usb_bulk_write() to send data,but when it sends a number of data, it will be blocked and no longer send data! My code is as follows:

static void
HandleEndpoints(void *pvInstance, unsigned int ulStatus, unsigned int ulIndex)
{
    const tUSBDBulkDevice *psBulkInst;
    tBulkInstance *psInst;

    ASSERT(pvInstance != 0);

    //
    // Determine if the serial device is in single or composite mode because
    // the meaning of ulIndex is different in both cases.
    //
    psBulkInst = (const tUSBDBulkDevice *)pvInstance;
    psInst = psBulkInst->psPrivateBulkData;


#ifdef DMA_MODE
    unsigned int pendReg=0;

    // Get the Starvation interrupt status
    CppiDmaGetINTD0Status(g_USBInstance[ulIndex].uiUSBInstance);

    // Get the DMA Interrupt status
    pendReg = CppiDmaGetPendStatus(g_USBInstance[ulIndex].uiUSBInstance);

#endif

    //
    // Handler for the bulk OUT data endpoint.
    //
    if(ulStatus & (0x10000 << USB_EP_TO_INDEX(psInst->ucOUTEndpoint)) ||
            (pendReg & CPDMA_RX_PENDING))
    {

#ifdef DMA_MODE
        ProcessDataFromHost_DMAMODE(pvInstance, ulStatus, ulIndex, pendReg);
#else
        ProcessDataFromHost(pvInstance, ulStatus, ulIndex);
#endif

    }

    //
    // Handler for the bulk IN data endpoint.
    //
    if(ulStatus & (1 << USB_EP_TO_INDEX(psInst->ucINEndpoint)) ||
            (pendReg & CPDMA_TX_PENDING))
    {

#ifndef DMA_MODE
        ProcessDataToHost_DMAMODE(pvInstance, ulStatus, ulIndex, pendReg);
#else
        ProcessDataToHost(pvInstance, ulStatus, ulIndex);
#endif
    }
}

static tBoolean
ProcessDataFromHost_DMAMODE(const tUSBDBulkDevice *psDevice, unsigned int ulStatus,
                                                            unsigned int ulIndex,unsigned int pendReg)
{
    unsigned int rxBuffer;
    unsigned int ulEPStatus;
    tBulkInstance *psInst;
    tUSBBuffer *psBuffer;

    // Get a pointer to our instance data.
    psInst = psDevice->psPrivateBulkData;
    psBuffer = (tUSBBuffer *)psDevice->pvRxCBData;

    // Get the endpoint status to see why we were called.
    ulEPStatus = USBEndpointStatus(g_USBInstance[ulIndex].uiBaseAddr, psInst->ucOUTEndpoint);

    //Clear the status bits.
    USBDevEndpointStatusClear(g_USBInstance[ulIndex].uiBaseAddr, psInst->ucOUTEndpoint, ulEPStatus);

    enableCoreRxDMA(g_USBInstance[ulIndex].uiUSBInstance, psInst->ucOUTEndpoint);

    //During receive operation, we need to wait in loop till we recive all data
    while(CppiDmaGetPendStatus(g_USBInstance[ulIndex].uiUSBInstance) & CPDMA_RX_PENDING)
    {
        rxBuffer = dmaRxCompletion(g_USBInstance[ulIndex].uiUSBInstance, psInst->ucOUTEndpoint);

        psBuffer->pfnCallback(psBuffer->pvCBData,USB_EVENT_RX_AVAILABLE,512,rxBuffer);

#if 0
        times++;
        UARTPuts("times:", -1);
        UARTPutHexNum(times);
        UARTPuts("\r\n", -1);

        *((char *)rxBuffer+20) = 0;

        UARTPuts("rxBuffer:", -1);
        UARTPuts((char *)rxBuffer+8, -1);
        UARTPuts("\r\n", -1);
#endif

        //
        //Load another BD to the receive queue
        //
        doDmaRxTransfer(g_USBInstance[ulIndex].uiUSBInstance, MAX_TRANSFER_SIZE,
            (unsigned char *)rxBuffer, psInst->ucOUTEndpoint);
    }

    USBDevEndpointDataAck(psInst->ulUSBBase, psInst->ucOUTEndpoint,true);

    return (true);
}

Can anyone help me? thanks.


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>