怎么控制某一个GPIO管脚开关中断

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

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

cross mob
jawu_4351971
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

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

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 点赞
1 解答
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Disable 之后重新使用CyU3PGpioSetSimpleConfig

在原帖中查看解决方案

0 点赞
5 回复数
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

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

0 点赞
jawu_4351971
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

我使用的这个管脚是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 点赞
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

尝试CyU3PGpioDisable之后再重新打开GPIO

0 点赞
jawu_4351971
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

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

0 点赞
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Disable 之后重新使用CyU3PGpioSetSimpleConfig

0 点赞