- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am working on SD_card write operation, we want to write data to SD card, the data which is considered by the 512bytes in firmware and the data is not copying to the buffer.
static void
CyFxBulkSrcSinkFillInBuffers (
void)
{
CyU3PReturnStatus_t stat;
CyU3PDmaBuffer_t buf_p;
uint16_t index = 0;
CyU3PDmaCbType_t type;
/* Now preload all buffers in the MANUAL_OUT pipe with the required data. */
for (index = 0; index <50; index++)
{
stat = CyU3PDmaChannelGetBuffer (&glChHandleBulkSrc, &buf_p, CYU3P_NO_WAIT);
for(i=0;i<=512;i++)
{
buf_p.buffer=READBUFFER;
}
if (type == CY_U3P_DMA_CB_XFER_CPLT)
{
if (stat != CY_U3P_SUCCESS)
{
stat= CyU3PSibReadWriteRequest(0, 0,
4, 2, 0, 0);
}
}
// CyU3PMemSet (buf_p.buffer, CY_FX_BULKSRCSINK_PATTERN, buf_p.size);
stat = CyU3PDmaChannelCommitBuffer (&glChHandleBulkSrc,512, 0);
}
Creating the DMA channel i.e CPU to Socket 0.
Please find the below attachment.
Regards,
Dhanuja
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Dhanuja,
0x40 means CY_U3P_ERROR_BAD_ARGUMENT.
Please check whether the arguments you have passed are correct.
I can see that the CyFxBulkSrcSinkFillInBuffers did not have any arguments. Since this is a callback function, this function address will be passed to the below function pointer
void (*CyU3PDmaMultiCallback_t) (
CyU3PDmaMultiChannel *handle, /**< Handle to the multi-socket DMA channel. */
CyU3PDmaCbType_t type, /**< The callback type. */
CyU3PDmaCBInput_t *input /**< Pointer to a union that contains the callback related data.
Will point to a valid CyU3PDmaBuffer_t variable if the callback
type is CY_U3P_DMA_CB_RECV_CPLT or CY_U3P_DMA_CB_PROD_EVENT. */
);
Hence, CyFxBulkSrcSinkFillInBuffers should have arguments in the function definition. You may refer DMA callback function in any example project.
Regards,
Sridhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dhanuja,
It looks like this is the duplicate thread of sd card write function
You need to call SIB APIs to read and write to SD card. You may refer FX3 API Guide, storage example provided in the SDK.
1. C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc\firmware
2. C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\storage_examples
Regards,
Sridhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This function is used for writing the data to sd card, please check it is correct or not.
Data from CPU to S0(only write operation).
static void
CyFxBulkSrcSinkFillInBuffers (
void)
{
CyU3PReturnStatus_t status;
CyU3PDmaBuffer_t buf_p;
uint16_t index = 0;
CyU3PDmaCbType_t type;
CyU3PDmaChannel *chHandle;
CyU3PDmaCBInput_t *input;
// memset(buf_p.buffer,0,512);
//CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
/* Now preload all buffers in the MANUAL_OUT pipe with the required data. */
for (index = 0; index <50; index++)
{
//for (index = 0; index <50; index++)
status = CyU3PDmaChannelGetBuffer (&glChHandleBulkSrc, &buf_p, CYU3P_NO_WAIT);
for(i=0;i<=512;i++)
{
buf_p.buffer=i;
}
}
status = CyU3PDmaChannelSetXfer (&glChHandleBulkSrc, (2 *CY_FX_SIB_MAX_BLOCK_SIZE));
if (status == CY_U3P_SUCCESS)
{
status = CyU3PSibReadWriteRequest (0, 0,
4, 2, &buf_p.buffer, 0);
}
if (type == CY_U3P_DMA_CB_PROD_EVENT)
{
status = CyU3PDmaChannelCommitBuffer (chHandle, 512, 0);
glDMARxCount++;
}
}
DMA channel creation:
dmaCfg.size = 512;//DMA_BUF_SIZE* size;
dmaCfg.count = 2;//CY_FX_SLFIFO_DMA_BUF_COUNT_U_2_P;
dmaCfg.prodSckId =CY_U3P_CPU_SOCKET_PROD;// CY_FX_PRODUCER_CPU_SOCKET1;//PIB producer socket 1
dmaCfg.consSckId = CY_U3P_SIB_SOCKET_0;
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BUFFER;//CY_U3P_DMA_MODE_BYTE;
/* Enabling the callback for produce event. */
dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT;// |CY_U3P_DMA_CB_RECV_CPLT ;
dmaCfg.cb = CyFxBulkSrcSinkFillInBuffers;//CyFxSlFifoPtoSDmaCallback;
dmaCfg.prodHeader = 0;
dmaCfg.prodFooter = 0;
dmaCfg.consHeader = 0;
dmaCfg.prodAvailCount=0;
apiRetStatus = CyU3PDmaChannelCreate (&glChHandleBulkSrc,
CY_U3P_DMA_TYPE_MANUAL_OUT, &dmaCfg);
if (apiRetStatus != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "CyU3PDmaChannelCreate failed, Error code = %d\n", apiRetStatus);
CyFxAppErrorHandler(apiRetStatus);
}
In DMA channel creation, we are getting the 64 error(0x40).
Regards,
Dhanuja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Dhanuja,
0x40 means CY_U3P_ERROR_BAD_ARGUMENT.
Please check whether the arguments you have passed are correct.
I can see that the CyFxBulkSrcSinkFillInBuffers did not have any arguments. Since this is a callback function, this function address will be passed to the below function pointer
void (*CyU3PDmaMultiCallback_t) (
CyU3PDmaMultiChannel *handle, /**< Handle to the multi-socket DMA channel. */
CyU3PDmaCbType_t type, /**< The callback type. */
CyU3PDmaCBInput_t *input /**< Pointer to a union that contains the callback related data.
Will point to a valid CyU3PDmaBuffer_t variable if the callback
type is CY_U3P_DMA_CB_RECV_CPLT or CY_U3P_DMA_CB_PROD_EVENT. */
);
Hence, CyFxBulkSrcSinkFillInBuffers should have arguments in the function definition. You may refer DMA callback function in any example project.
Regards,
Sridhar