void doDmaRxTransfer(unsigned short usbDevInst, unsigned int length, unsigned char *buff, unsigned int endPoint) { hostPacketDesc *current_bd = 0; usbInstance *usbInstance; usbInstance = &(cppiInfo.usbInst[usbDevInst]); current_bd = getFreeBd(); endPoint = USB_EP_TO_INDEX(endPoint); /* Process the BD */ Cppi41DmaProcessBD(usbDevInst, current_bd, CPDMA_DIR_RX, buff, length, endPoint); /* Clean the cache */ CacheWB((unsigned int)current_bd,sizeof(hostPacketDesc)); /*Submit the BD */ pushToSubmitQ(usbDevInst, usbInstance->rxEndPoint[endPoint].submitq, current_bd); }
void doDmaTxTransfer(unsigned short usbDevInst, unsigned char *buff, unsigned int length, unsigned int endPoint) { hostPacketDesc *current_bd = 0; unsigned int numOfBlocks =0; unsigned int residue; unsigned int i; usbInstance *usbInstance; usbInstance = &(cppiInfo.usbInst[usbDevInst]); endPoint = USB_EP_TO_INDEX(endPoint); /*This code segment will take care of the transparent mode transaction */ if(CPDMA_MODE_SET_TRANSPARENT == usbInstance->txEndPoint[endPoint].mode) { /* If the data length is less than the USB packet size */ if(length < USB_PACKET_LENGTH) { /*get a free db from the BD pool */ current_bd = getFreeBd(); /*Clean the cache so that buffer will have proper data */ CacheWB((unsigned int)buff, length); /*This API will initialize the BD fields */ Cppi41DmaProcessBD(usbDevInst, current_bd, CPDMA_DIR_TX, buff, length, endPoint); current_bd->packetId = EOP; /*Clean the cache so that bd will have proper data */ CacheWB((unsigned int)current_bd,sizeof(hostPacketDesc)); /*Submit the BD to the queue for transaction */ pushToSubmitQ(usbDevInst, usbInstance->txEndPoint[endPoint] .submitq, current_bd); } /*If the length is more than packet size, then packetize it */ else { numOfBlocks = length / USB_PACKET_LENGTH; residue = length - (numOfBlocks * USB_PACKET_LENGTH); for(i=0; i < numOfBlocks; i++) { /*get a free db from the BD pool */ current_bd = getFreeBd(); CacheWB((unsigned int)&buff[i*USB_PACKET_LENGTH], USB_PACKET_LENGTH); /*This API will initialize the BD fields */ Cppi41DmaProcessBD(usbDevInst, current_bd, CPDMA_DIR_TX, &buff[i*USB_PACKET_LENGTH], USB_PACKET_LENGTH, endPoint); /*Set the packet id to identify the packet position */ if(numOfBlocks == 1) current_bd->packetId = EOP; else if(i==0) current_bd->packetId = SOP; else if((numOfBlocks != 1) && (i < (numOfBlocks -1))) current_bd->packetId = MOP; else if(i == (numOfBlocks -1) && residue == 0) current_bd->packetId = EOP; else current_bd->packetId = MOP; CacheWB((unsigned int)current_bd,sizeof(hostPacketDesc)); /*Submit the BD to the queue for transaction */ pushToSubmitQ(usbDevInst, usbInstance->txEndPoint[endPoint] .submitq, current_bd); } /*If there are some remaining data then send it also */ if(residue) { /*get a free db from the BD pool */ current_bd = getFreeBd(); CacheWB((unsigned int)&buff[i*USB_PACKET_LENGTH], residue); /*This API will initialize the BD fields */ Cppi41DmaProcessBD(usbDevInst, current_bd, CPDMA_DIR_TX, &buff[i*USB_PACKET_LENGTH], residue, endPoint); current_bd->packetId = EOP; /*This API will initialize the BD fields */ CacheWB((unsigned int)current_bd,sizeof(hostPacketDesc)); /*Submit the BD to the queue for transaction */ pushToSubmitQ(usbDevInst, usbInstance->txEndPoint[endPoint] .submitq, current_bd); } } } /*This segment of the code will take care of GRNIS mode of transaction */ else if(usbInstance->txEndPoint[endPoint].mode == CPDMA_MODE_SET_GRNDIS) { /*get a free db from the BD pool */ current_bd = getFreeBd(); CacheWB((unsigned int)buff, length); /*This API will initialize the BD fields */ Cppi41DmaProcessBD(usbDevInst, current_bd, CPDMA_DIR_TX, buff, length, endPoint); current_bd->packetId = EOP; CacheWB((unsigned int)current_bd,sizeof(hostPacketDesc)); /*Submit the BD to the queue for transaction */ pushToSubmitQ(usbDevInst, usbInstance->txEndPoint[endPoint] .submitq, current_bd); } }
void CleanDSPCache_LCD (void) { CacheWB((unsigned int)g_pucBuffer0, sizeof(g_pucBuffer0)); CacheWB((unsigned int)g_pucBuffer1, sizeof(g_pucBuffer1)); }