3 Replies Latest reply on Oct 9, 2020 12:37 AM by HemanthR_06

    How do I free MANUAL or MANUAL_IN related buffers?

    maVa_1182686

      One of the interfaces on my firmware has a BULK_out endpoint to transfer data from the host to the FX3.

      The problem is that I can only transfer the amount of data that fits into the allocated buffers. They don't seem to be reused.

      When I allocate 16 buffers (1024 bytes) and send a 16kByte file, it works. 17kByte gives an error.

      If I do 1byte messages, I can send 16 of them, the 17th will fail.

      This leads me to believe I fail to reuse and empty the buffers.

       

      I have it setup either in MANUAL or MANUAL_IN

           dmaCfg.size  = DMA_BUF_SIZE* size;

           dmaCfg.count = CY_FX_SLFIFO_DMA_BUF_COUNT_U_2_P;

           dmaCfg.prodSckId = CY_FX_PRODUCER_USB_SOCKET;

           //dmaCfg.consSckId = CY_FX_CONSUMER_PPORT_SOCKET;

           dmaCfg.consSckId = CY_U3P_CPU_SOCKET_CONS; //TEST MANUAL_IN instead of MANUAL

           dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;

           /* Enabling the callback for produce event. */

           dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT;

           dmaCfg.cb = CyFxSlFifoUtoPDmaCallback;

           dmaCfg.prodHeader = 0;

           dmaCfg.prodFooter = 0;

           dmaCfg.consHeader = 0;

           dmaCfg.prodAvailCount = 0;

       

        apiRetStatus = CyU3PDmaChannelCreate (&glChHandleSlFifoUtoP,

                CY_U3P_DMA_TYPE_MANUAL_IN, &dmaCfg);

       

      with a callback

      void

      CyFxSlFifoUtoPDmaCallback (

              CyU3PDmaChannel   *chHandle,

              CyU3PDmaCbType_t  type,

              CyU3PDmaCBInput_t *input

              )

      {

      uint16_t index;

          CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

          CyU3PDebugPrint (4, "_____DATA RECEIVED_____");

          if (type == CY_U3P_DMA_CB_PROD_EVENT)

          {

              /* This is a produce event notification to the CPU. This notification is

               * received upon reception of every buffer. The buffer will not be sent

               * out unless it is explicitly committed. The call shall fail if there

               * is a bus reset / usb disconnect or if there is any application error. */

              status = CyU3PDmaChannelCommitBuffer (chHandle, input->buffer_p.count, 0);

       

       

              switch (input->buffer_p.buffer[0]){

       

       

       

       

              case 0xFF: //Message for FPGA...copy message into ConfigBuffer

              //CyU3PDebugPrint (4,"COPY TO CONFIGBUFFER REQUESTED");

              for ( index = 0; index < input->buffer_p.count; index++){

              ConfigBuffer[index] = input->buffer_p.buffer[index];

              }

              Broadcast_to_fpga_flag = 1;

              break;

       

       

              case 0x00: //Command for FX3 Request RESET TODO

              CyU3PDebugPrint (4, "reset request");

              Reset_to_fpga_flag = 1;

              break;

       

       

              case 0x01: //Request FPGA start measurement TODO

              CyU3PDebugPrint (4, "FPGA start measurement request");

                  break;

       

       

              case 0x02: //Request FPGA start measurement TODO

              CyU3PDebugPrint (4, "FPGA stop measurement request");

                  break;

       

       

              //case...... All the request implemented here

       

       

              }

       

       

       

       

              glDMARxCount++;

          }

      }

       

       

      Where should I expect the BUFFER to be cleared again?

      I assumed the commit does that?

       

      Thanks!