2 Replies Latest reply on Sep 25, 2016 11:48 PM by 종대.이

    Problem on the Images capture by the camera device

    종대.이

      To whom may concern, 

         

      Hello, we are currently developing a camera using the CX3 (cyusb3065) chip.
      There are no problems to use image capture function with the viewer of the PC or smart phone.
      But, it is not easy to use  this function as we press the camera button on the camera device.
      We try to create a DMA channel and then, press the capture button to try to convey this message to the viewer's PC program but it is not working properly.
      Please  support if you have the solution on this problem.
       
      As below are some of the code being implemented.
      //
       
      in  CyCx3Appinit()
       
          /* Create a DMA MANUAL_IN channel for the producer socket. */
         dmaChConfig.size   = 32;
         dmaChConfig.count   = 2;  //CY_FX_BULKLP_DMA_BUF_COUNT;
         dmaChConfig.prodSckId   = CY_FX_EP_PRODUCER_SOCKET;
         dmaChConfig.consSckId   = CY_U3P_CPU_SOCKET_CONS;
         dmaChConfig.dmaMode   = CY_U3P_DMA_MODE_BYTE;
         /* No callback is required. */
         dmaChConfig.notification   = 0;
         dmaChConfig.cb    = NULL;
         dmaChConfig.prodHeader   = 0;
         dmaChConfig.prodFooter   = 0;
         dmaChConfig.consHeader   = 0;
         dmaChConfig.prodAvailCount  = 0;

         

         status = CyU3PDmaChannelCreate (&glChHandleStatusIn, CY_U3P_DMA_TYPE_MANUAL_IN, &dmaChConfig);
         if (status != CY_U3P_SUCCESS)
         {
          CyU3PDebugPrint (4, "\n\r>CyU3PDmaChannelCreate failed, Error code = %d", status);
       //   CyCx3AppErrorHandler(status);
         }

         

         /* Create a DMA MANUAL_OUT channel for the consumer socket. */
         dmaChConfig.prodSckId = (CyU3PDmaSocketId_t)CY_U3P_CPU_SOCKET_PROD; //CY_U3P_CPU_SOCKET_PROD;
         dmaChConfig.consSckId =  (CyU3PDmaSocketId_t)CY_FX_EP_CONSUMER_SOCKET; //CY_U3P_UIB_SOCKET_CONS_0;
         status = CyU3PDmaChannelCreate (&glChHandleStatusOut, CY_U3P_DMA_TYPE_MANUAL_OUT, &dmaChConfig);
         if (status != CY_U3P_SUCCESS)
         {
          CyU3PDebugPrint (4, "\n\r>CyU3PDmaChannelCreate failed, Error code = %d", status);
       //   CyCx3AppErrorHandler (status);
         }

         

         /* Set DMA Channel transfer size */
         status = CyU3PDmaChannelSetXfer (&glChHandleStatusIn, CY_FX_BULKLP_DMA_TX_SIZE);
         if (status != CY_U3P_SUCCESS)
         {
          CyU3PDebugPrint (4, "\n\r>CyU3PDmaChannelSetXfer  glChHandleStatusIn Failed, Error code = %d", status);
       //   CyCx3AppErrorHandler (status);
         }

         

         status = CyU3PDmaChannelSetXfer (&glChHandleStatusOut, CY_FX_BULKLP_DMA_TX_SIZE);
         if (status != CY_U3P_SUCCESS)
         {
          CyU3PDebugPrint (4, "\n\r>CyU3PDmaChannelSetXfer  glChHandleStatusOut Failed, Error code = %d", status);
       //   CyCx3AppErrorHandler (status);
         }

         

      After pressing Capture Button, Function call

         

      static void
      CaptureIrqCallback (CyBool_t isButtonPressed)
      {
       CyU3PDmaBuffer_t bufferToSend;
       CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

         

       CyU3PMemSet(glStatusPacket, 0x00, 16);

         

       glStatusPacket[0] = 0x02;          /* bStatusType = VideoStreaming interface */
       glStatusPacket[1] = 0x01;          /* bOriginator = ID of VideoStreaming interface */
       glStatusPacket[2] = 0x00;          /* bEvent       = Button press */
       glStatusPacket[3] = isButtonPressed ? 0x01 : 0x00; /* bValue   = Button press state */

         

       bufferToSend.buffer = glStatusPacket;
       bufferToSend.count = 4;
       bufferToSend.size = 16;
       bufferToSend.status = 0;

         

       //CyU3PDebugPrint (4, "\n\r>Before Button press send");
       status = CyU3PDmaChannelSetupSendBuffer (&glChHandleStatusOut, &bufferToSend);
       if (status != CY_U3P_SUCCESS)
        CyU3PDebugPrint (4, "\n\r>SendButtonPressToHost(%d): SetupSendBuffer failed with 0x%x\n", isButtonPressed, status);
       else
        CyU3PDebugPrint (4, "\n\r>Commmand DMA channel setup, wait for completion");

         

       status = CyU3PDmaChannelWaitForCompletion(&glChHandleStatusOut, CYU3P_WAIT_FOREVER);
       if (status != CY_U3P_SUCCESS)
       {
        CyU3PDebugPrint (4, "\n\r>SendButtonPressToHost(%d): WaitForCompletion failed with 0x%x\n", isButtonPressed, status);
        CyU3PDmaChannelDestroy (&glChHandleStatusOut);
       }
       CyU3PDebugPrint (4, "\n\r>Capture command sent to host\n");
      }

         

      The error occurs at this point at  CaptureIrqCallback ().

         

      status = CyU3PDmaChannelSetupSendBuffer (&glChHandleStatusOut, &bufferToSend);
       if (status != CY_U3P_SUCCESS)
        CyU3PDebugPrint (4, "\n\r>SendButtonPressToHost(%d): SetupSendBuffer failed with 0x%x\n", isButtonPressed, status);
       else
        CyU3PDebugPrint (4, "\n\r>Commmand DMA channel setup, wait for completion");

         

       status = CyU3PDmaChannelWaitForCompletion(&glChHandleStatusOut, CYU3P_WAIT_FOREVER);
       if (status != CY_U3P_SUCCESS)
       {
        CyU3PDebugPrint (4, "\n\r>SendButtonPressToHost(%d): WaitForCompletion failed with 0x%x\n", isButtonPressed, status);
        CyU3PDmaChannelDestroy (&glChHandleStatusOut);
       }

        • 1. Re: Problem on the Images capture by the camera device
          Madhu Lakshmipathy

          Hi,

             

          Is the function: CaptureIrqCallback () the actual GPIO Isr? It is not recommended to put complex functions like these inside an ISR. You just have to set a Flag inside the Gpio ISR and keep checking if the flag has been set in the for (;;) of the main thread and then call these functions.

             

          Please find the reason of the error using the return code of the APIs. Please try calling the CyU3PDmaChannelReset API before you call the SetupSendBuffer API. Also, make sure that your host application keeps pinging for the data on that endpoint for status. If the host did not request for data on its own, Cx3 has no way to send data to host. Host (PC Application) is the master and only it has to keep checking for data.

             

          Regards,

             

          - Madhu Sudhan

          • 2. Re: Problem on the Images capture by the camera device
            종대.이

            Hi, Madhu Sudhan

               

            CaptureIrqCallback () is not the actual GPIO Isr, but called  when the flag is set by pressing the capture  button of camera device. 

               

            The flag has been set in the for(;;) of  GpioInputThread_Entry, that is Gpio ISR Function  of the CyCx3AppThread_Entry.

               

            I did already as you said.

               

            And I using the eCAM PC Program which has  capture function (get still) and other function such as capture filter, pin etc,

               

            There is no problem in software capture image by host.

               

             But, I don't know the reason why the error occurred even though  I added  CyU3PDmaChannelReset   API.

               

            The error messages using the return code of the APIs follow:

               

            > SendButtonPressToHost(1): SetupSendBuffer failed with 0x40
            > SendButtonPressToHost(1): WaitForCompletion failed with 0x42

               

            Please reply to me why or solution.

               

            regards,

               

            - J.D. Lee