大家好。
我想在 mcu3_0上的 Vision Apps 中使用 GPIO1_11作为输入 IO。
我想使用中断路由检测 GPIO1_11的下降沿。
我参考了一些 e2e。 我实现了以下代码。
void test_gpio_handler()
{
cnt++;
GPIO_clearInt(0);
}
static void SetRmIrqGPIO()
{
struct tisci_msg_rm_irq_set_req rmIrqReq;
struct tisci_msg_rm_irq_set_resp rmIrqResp;
memset(&rmIrqReq, 0x0, sizeof(rmIrqReq));
memset(&rmIrqResp, 0x0, sizeof(rmIrqResp));
rmIrqReq.valid_params = 0U;
rmIrqReq.global_event = 0U;
rmIrqReq.src_id = 0U;
rmIrqReq.src_index = 0U;
rmIrqReq.dst_id = 0U;
rmIrqReq.dst_host_irq = 0U;
rmIrqReq.ia_id = 0U;
rmIrqReq.vint = 0U;
rmIrqReq.vint_status_bit_index = 0U;
rmIrqReq.secondary_host = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST;
rmIrqReq.secondary_host = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST;
rmIrqReq.src_id = TISCI_DEV_GPIOMUX_INTRTR0;
rmIrqReq.src_index = 11; //Need to add 128 for GPIO1
/* Set the destination based on the core */
rmIrqReq.dst_id = TISCI_DEV_GPIOMUX_INTRTR0; //TISCI_DEV_R5FSS1_CORE0;
rmIrqReq.dst_host_irq = 16; //don't know how to set this
/* Set the destination interrupt */
rmIrqReq.valid_params |= TISCI_MSG_VALUE_RM_DST_ID_VALID;
rmIrqReq.valid_params |= TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID;
Sciclient_rmIrqSet(
(const struct tisci_msg_rm_irq_set_req *)&rmIrqReq,
&rmIrqResp,
SCICLIENT_SERVICE_WAIT_FOREVER);
}
static void GPIO_configIntRouter(uint32_t portNum, uint32_t pinNum, uint32_t gpioIntRtrOutIntNum, GPIO_v0_HwAttrs *cfg)
{
GPIO_IntCfg *intCfg;
uint32_t bankNum = 0U;
intCfg = cfg->intCfg;
cfg->baseAddr = 0x601000UL;
bankNum = pinNum/16; /* Each GPIO bank has 16 pins */
intCfg[pinNum].intNum = 176 + bankNum; //CSLR_R5FSS1_CORE0_INTR_GPIOMUX_INTRTR0_OUTP_16
intCfg[pinNum].intcMuxNum = INVALID_INTC_MUX_NUM;
intCfg[pinNum].intcMuxInEvent = 0;
intCfg[pinNum].intcMuxOutEvent = 0;
}
void gpio_ecap_init(void)
{
GPIO_v0_HwAttrs gpio_cfg;
Board_moduleClockEnable(TISCI_DEV_GPIO1);
GPIO_socGetInitCfg(0, &gpio_cfg); //
gpio_cfg.baseAddr = 0x601000UL;
GPIO_configIntRouter(1, 11, 0, &gpio_cfg);
CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + CSL_MAIN_CTRL_MMR_CFG0_PADCONFIG140, 0x0050007);
GPIO_socSetInitCfg(0, &gpio_cfg);
GPIO_setCallback(0, test_gpio_handler);
GPIO_init();
SetRmIrqGPIO();
GPIO_setCallback(0, test_gpio_handler);
GPIO_enableInt(0);
GPIO_clearInt(0);
}
完成 GPIO 设置后、我确认 GPIO 读取值在更改。
但 GPIO 中断处理程序不起作用。
DST_HOST_IRQ 是否正确?
如何处理 GPIO 处理程序?