【已解决】关于CBU的IO中断方式支持问题
问题描述:
1.我的应用需要同一个IO口支持上升沿和下降沿中断触发,并且希望中断回调知道这次的上升沿中断还是下降沿中断,类似常用单片机支持的应用方式,目前使用的涂鸦SDK封装的接口有这个选项,但是使用并没有生效,我看到原厂的驱动代码显示并不支持同时两个边沿触发初始化设置,请帮忙确认下模组中的芯片是否只能支持两个边沿触发的设置,如果要满足我的应用,是否这样每次中断处理函数里面修改边沿触发规则配置是否可以,或者有其他办法可行,感谢!
2.问题资料
原厂BkDriverGpio.h结构体
/**
- GPIO interrupt trigger
/
typedef enum
{
IRQ_TRIGGER_LOW_LEVEL = 0x0, / Interrupt triggered at input signal's LOW LEVEL /
IRQ_TRIGGER_HGIH_LEVEL = 0x1, / Interrupt triggered at input signal's HIGH LEVEL /
IRQ_TRIGGER_RISING_EDGE = 0x2, / Interrupt triggered at input signal's rising edge /
IRQ_TRIGGER_FALLING_EDGE = 0x3 / Interrupt triggered at input signal's falling edge */
} platform_gpio_irq_trigger_t;
涂鸦芯片适配驱动代码tuya_drv_pin.h:
static int pin_dev_irq_config(tuya_pin_name_t pin, tuya_pin_irq_t *irq)
{
bk_gpio_irq_trigger_t trigger;
if (TUYA_PIN_IN_IRQ != (irq->mode & TUYA_PIN_INOUT_MASK)) {
return OPRT_OS_ADAPTER_INVALID_PARM;
}
switch (irq->mode & TUYA_PIN_IRQ_MASK) {
case TUYA_PIN_IRQ_RISE:
trigger = IRQ_TRIGGER_RISING_EDGE;
break;
case TUYA_PIN_IRQ_FALL:
trigger = IRQ_TRIGGER_FALLING_EDGE;
break;
case TUYA_PIN_IRQ_LOW:
trigger = IRQ_TRIGGER_LOW_LEVEL;
break;
case TUYA_PIN_IRQ_HIGH:
trigger = IRQ_TRIGGER_HGIH_LEVEL;
break;
default: return OPRT_OS_ADAPTER_NOT_SUPPORTED;
}
pinmap[pin].cb = irq->cb;
pinmap[pin].args = irq->arg;
BkGpioEnableIRQ(pinmap[pin].gpio, trigger, (bk_gpio_irq_handler_t)pinmap[pin].cb, pinmap[pin].args);
return OPRT_OS_ADAPTER_OK;
}