cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

New Contributor II

我想程序运行的过程中开启/关闭管脚中断,通过以下方式没有成功,请问正确的方式是什么?

void CyCx3ImuIntEnable(void)

{

    CyU3PGpioSimpleConfig_t gpioConf;

    CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

    /* Configure CLOVER_IMU_INT pin*/

    gpioConf.outValue = CyFalse;

    gpioConf.driveLowEn = CyFalse;

    gpioConf.driveHighEn = CyFalse;

    gpioConf.inputEn = CyTrue;

    gpioConf.intrMode = CY_U3P_GPIO_INTR_POS_EDGE;

    status = CyU3PGpioSetSimpleConfig(CLOVER_IMU_INT, &gpioConf);

    if (status != CY_U3P_SUCCESS)

    {

        Cx3Err("[GPIO] imu interrupt pin enable failure %d\r\n", status);

        return;

    }

}

void CyCx3ImuIntDisable(void)

{

    CyU3PGpioSimpleConfig_t gpioConf;

    CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

    /* Configure CLOVER_IMU_INT pin*/

    gpioConf.outValue = CyFalse;

    gpioConf.driveLowEn = CyFalse;

    gpioConf.driveHighEn = CyFalse;

    gpioConf.inputEn = CyFalse;

    gpioConf.intrMode = CY_U3P_GPIO_NO_INTR;

    status = CyU3PGpioSetSimpleConfig(CLOVER_IMU_INT, &gpioConf);

    if (status != CY_U3P_SUCCESS)

    {

        Cx3Err("[GPIO] imu interrupt pin disable failure %d\r\n", status);

        return;

    }

}

CyU3PGpioSetSimpleConfig  返回值为0x44 CY_U3P_ERROR_NOT_CONFIGURED

0 Likes
Reply
1 Solution
Moderator
Moderator

Disable 之后重新使用CyU3PGpioSetSimpleConfig

View solution in original post

0 Likes
Reply
5 Replies
Moderator
Moderator

您好,请问您用CyU3PDeviceConfigureIOMatrix打开了相应的GPIO吗?

0 Likes
Reply
New Contributor II

我使用的这个管脚是17,这个是我GPIO初始化的代码

CyU3PDeviceGpioOverride(CLOVER_IMU_INT, CyFalse);

    gpioConf.outValue = CyFalse;

    gpioConf.driveLowEn = CyFalse;

    gpioConf.driveHighEn = CyFalse;

    gpioConf.inputEn = CyTrue;

    gpioConf.intrMode = CY_U3P_GPIO_INTR_POS_EDGE;

    status = CyU3PGpioSetSimpleConfig(CLOVER_IMU_INT, &gpioConf);

    if (status != CY_U3P_SUCCESS)

        return;

初始化之后可以正常进入中断,我现在是想增加在程序运行的过程中开关引脚中断,请问怎么实现?

0 Likes
Reply
Moderator
Moderator

尝试CyU3PGpioDisable之后再重新打开GPIO

0 Likes
Reply
New Contributor II

没有找到CyU3PGpioEnable,请问使用哪个接口函数?

0 Likes
Reply
Moderator
Moderator

Disable 之后重新使用CyU3PGpioSetSimpleConfig

View solution in original post

0 Likes
Reply