MANY_TO_ONE with FX3 ARM as consumer? | Cypress Semiconductor
MANY_TO_ONE with FX3 ARM as consumer?
I have an FX3 design with a 32-bit, 100MHz GPIF interface. In this particular application the GPIF interface is receiving data from an external FPGA (one direction, FPGA -> FX3 only). Before I work on the USB3 side of the design I would like to verify the GPIF interface data transfer. To do this I am trying to set up a multichannel DMA transfer to the CPU. The final product will be a multichannel DMA transfer from the GPIF interface to a USB IN endpoint.
I see that there is CY_U3P_DMA_TYPE_MANUAL_MANY_TO_ONE, but there is no multichannel MANUAL_IN variant which is the single-channel way of doing this. If I try to configure the consumer of the DMA data to the CPU (CY_U3P_CPU_SOCKET_CONS) CyU3PMultiDmaChannelCreate() returns error 64. To get around this I have set up the consumer socket ID to the first USB consumer socket (CY_U3P_UIB_SOCKET_CONS_0) and in the DMA handler callback, I just discard the DMA data instead of committing it.
My DMA setup is otherwise textbook:
size = 16384;
CyU3PMemSet((uint8_t *)&dmaCfg, 0, sizeof(dmaCfg));
dmaCfg.size = size;
dmaCfg.count = 4;
dmaCfg.prodSckId = CY_U3P_PIB_SOCKET_0;
dmaCfg.prodSckId = CY_U3P_PIB_SOCKET_1;
dmaCfg.consSckId = CY_U3P_UIB_SOCKET_CONS_0;
dmaCfg.validSckCount = 2;
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BUFFER;
dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_ERROR;
dmaCfg.cb = gpif_dma_cb;
apiRetStatus = CyU3PDmaMultiChannelCreate(&h_gpif_to_cpu, CY_U3P_DMA_TYPE_MANUAL_MANY_TO_ONE, &dmaCfg);
I then go and start an unlimited DMA transfer with the following calls (error checking removed for clarity):
apiRetStatus = CyU3PDmaMultiChannelReset(&h_gpif_to_cpu);
apiRetStatus = CyU3PDmaMultiChannelSetXfer(&h_gpif_to_cpu, 0, 0);
This appears to work fine. I get 8 DMA producer callbacks, and I immediately discard the data in the callback handler:
void gpif_dma_cb(CyU3PDmaMultiChannel *chHandle, CyU3PDmaCbType_t type, CyU3PDmaCBInput_t *input)
apiRetStatus = CyU3PDmaMultiChannelDiscardBuffer(chHandle);
/* ... remaining function code snipped for clarity ... */
What happens after this is that I do not get any further callbacks. It's like the DMA buffers are stuck in "used" state even though I'm discarding them. If I reset the DMA channel and restart it, it works for another 8 transfers before getting stuck again.
What is the correct way to perform multi channel DMA from the GPIF to the FX3 ARM? I'm sure I'm close.