how to get DMA out descriptor or DMA out buffer pointer in Callback(CY_U3P_DMA_CB_PROD_EVENT) during runtime | Cypress Semiconductor
how to get DMA out descriptor or DMA out buffer pointer in Callback(CY_U3P_DMA_CB_PROD_EVENT) during runtime
My requirements(programming workflow) are quite simple in the following
1. upload 256KB data thru Out End point from host to device in runtime.
1-1 In my DMA In callback function
For any incoming data, I copied data from DMA in buffer to global heap memory (around 270 KB) readjusted by cyfxtx and fx3.ld;
1-2 Keep tracking number of bytes for incoming data. Once it reaches 256KB, no accept any more.
2. When a host application trigger event( request data), device application sends data back to IN-End point thru callback function of DMA Out Channel
2-1 In My DMA Out callback function
I get a buffer of DMA out and copy data from heap memory and to DMA out buffer. then commit the buffer.
Overall, I can send data from device to host as I wish. The speed is very slow(around 20 MB/sec) since the copy operation is quite expensive in DMA Out callback function during continuous events from host. When I comment out the copy operation, it reaches at around 245MB/sec.
However, I have noticed that "bulksrcsink" example preload all buffers in the MANUAL_OUT pipe; I belive that this is done when device application is loaded by "USB Control Center". So I am trying to figure it out how to preload all DMA out buffers in DMA IN Channel callback function.
I wrote a test code to get active handle of DMA out channel in DMA IN callback function
CyU3PDmaSocketId_t sckId = CY_FX_EP_CONSUMER_SOCKET ;
status = CyU3PDmaChannelGetBuffer(chHandle, &buf_p, CYU3P_NO_WAIT ); //==> 69
CyU3PDmaChannel *chHandleSrc = CyU3PDmaChannelGetHandle(sckId);
status1 = CyU3PDmaChannelGetBuffer(chHandleSrc, &buf_dmaout, CYU3P_NO_WAIT ); //==> 71
But this does not allow me to get its handle during runtime. Is there a way I can preload all DMA out buffer in DMA IN callback function during runtime ?