To answer that the declaration of
input->buffer_p[.count]
must be known and how many bytes should be copied from where to where. Note that I have put the
.count
into brackets because the name indicates that it is a count/size value and not a buffer.
Okay, I searched for it and found it at
https://github.com/nickdademo/cypress-fx3-sdk-linux/blob/master/firmware/u3p_firmware/inc/cyu3dma.h[
^]:
typedef struct CyU3PDmaBuffer_t
{
uint8_t *buffer;
uint16_t count;
uint16_t size;
uint16_t status;
} CyU3PDmaBuffer_t;
typedef union CyU3PDmaCBInput_t
{
CyU3PDmaBuffer_t buffer_p;
} CyU3PDmaCBInput_t;
According to that you can copy the data to your buffer with
memcpy(buffer, input->buffer_p.buffer, input->buffer_p.count);
provided that your buffer is large enough (size >=
input->buffer_p.count
).
To copy data to the
input->buffer_p
, copy in the reverse direction and set the other structure members accordingly (
count
,
status
) after checking for sufficient size.
[EDIT: Example]
uint16_t bufSize = sizeof(buffer); if (bufSize <= input->buffer_p.size)
{
input->buffer_p.count = bufSize;
input->buffer_p.status = theStatus; memcpy(input->buffer_p.buffer, buffer, bufSize);
}
But you have to comply with the specifications of the SDK
[/EDIT]
I'm not sure for which direction the callback is issued here. But you should know when doing such low level stuff.