1 of 1 people found this helpful
There are a few ways to do this:
1. if your DMA channel is from GPIF to some other socket, then you can use the COMMIT action in GPIF designer to send the partially filled buffer (less than 4KB in your situation) to the PC
2. if the channel is from USB to some socket, then you should either send a zero byte packet in the last transfer or send a short packet. For example, if you want to only send 3KB, then send 3KB from PC and then send 0 bytes. This last packet will cause the 3KB to be wrapped up on the USB socket.
On the other hand, if you want to send 3.2KB (3276 bytes), then there is no need to send a 0 byte packet because the last packet sent by the PC will be 0.2KB (204 bytes) is a short packet. This short packet will cause the buffer to automatically wrap up
3. for other types of sockets, you need to use the CyU3PDmaChannelSetWrapUp API. This can be used for GPIF and USB sockets too but it is not mandatory as I just explained.
I have similar conditions for USB OUT endpoint (ingress/producer socket).
No one send zero packets on packet size boundary.
CyU3PDmaChannelSetWrapUp works fine by calling it periodically.
It would be a cleaner to call this function only when it necessary, when data received from host but not wrapped-out (released/committed).
Is there a way to detect condition of non-empty state of ingress socket ?