GPIO interrupt event cannot be received in CX3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
dawa_2529456
Level 4
Level 4
5 sign-ins 5 solutions authored First solution authored

Dear Sir,

I add a compositive hid device in my CX3 UVC application according toAdding HID interface to AN75779 project attached demo Memo_CX3_UVC_HID_ButtonTrigger.zip.

I am glad to  see this HID device in device management tree(win10), but GPIO interrupt event cannot be triggered. so char "x" is not sent to PC.

The flowing code is form CX3_UVC_HID_ButtonTrigger.zip. the comments by mady is reserved and no modification. e.g. I use GPIO21 instead of GPIO17. and event group is glCx3Event, not glTimerEvent

void CyFxGpioIntrCb (

            uint8_t gpioId /* Indicates the pin that triggered the interrupt */

            )

{

        CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

        cnt ++;

        apiRetStatus = CyU3PEventSet(&glCx3Event, INTERRUPT_TRIGGER,CYU3P_EVENT_OR);  //mady: This function is called when GPIO 17 is asserted or de-asserted

        //mady: We set the glTimerEvent flag that Key has been pressed

        if (apiRetStatus != CY_U3P_SUCCESS)

        {

        CyCx3UvcAppErrorHandler(apiRetStatus);

        }

}

CyFxGpioIntrCb() just set INTERRUPT_TRIGGER event, and then this event  will be dealed in CyCx3UvcAppThread_Entry() as well as other events. it is registered by CyU3PGpioInit() in CyCx3UvcAppInit().

CyCx3UvcAppInit(void)

{

// omitted

.....

.....

.....

.....

//

/* Init the GPIO module */

      gpioClock.fastClkDiv = 2;

      gpioClock.slowClkDiv = 0;

      gpioClock.simpleDiv = CY_U3P_GPIO_SIMPLE_DIV_BY_2;

      gpioClock.clkSrc = CY_U3P_SYS_CLK;

      gpioClock.halfDiv = 0;

      status = CyU3PGpioInit(&gpioClock, CyFxGpioIntrCb); //mady: specifying the callback function when the key (GPIO) is pressed

      if (status != 0)

      {

          /* Error Handling */

          CyU3PDebugPrint (4, "\n\rCyU3PGpioInit failed, error code = %x\n", status);

          CyU3PDebugPrint (4, "\n\rglIsGpioActive = %d\n", glIsGpioActive);

     //     esUVCAppErrorHandler(apiRetStatus);

      }

      status = CyU3PDeviceGpioOverride (21, CyTrue);  //mady : configuring GPIO 21 as Keyboard Key

      if (status != 0)

      {

          /* Error Handling */

          CyU3PDebugPrint (4, "CyU3PDeviceGpioOverride failed, error code = %d\n",

                  status);

          CyCx3UvcAppErrorHandler(status);

      }

     

     

       CyU3PGpioSimpleConfig_t gpioConfig;   

  

   gpioConfig.outValue = CyFalse;

    gpioConfig.driveLowEn = CyFalse;

    gpioConfig.driveHighEn = CyFalse;

    gpioConfig.inputEn = CyTrue;

    gpioConfig.intrMode = CY_U3P_GPIO_INTR_BOTH_EDGE;    //mady:COnfigure GPIO 21 for Interrupt. when it is asserted or de-asserted, it should send character 'x' to PC

    status = CyU3PGpioSetSimpleConfig(21, &gpioConfig);

    if (status != CY_U3P_SUCCESS)

    {

    /* Error handling */

       CyU3PDebugPrint (4, "CyU3PGpioSetSimpleConfig failed, error code = %d\n",status);

       CyCx3UvcAppErrorHandler(status);

    }

    else

    {

    CyU3PDebugPrint (1,"GPIO Cnfigured\n\r");

    }

}

So, How to make sure GPIO21 interrupt is working?  I cannot find error for  above gpio init procedure.

Does anyone give me some advice?

Thanks.

David

0 Likes
1 Solution

Please comment out MipiCsiInitializeGpio() APi as it internally calls GpioInit() function only.

View solution in original post

12 Replies