|
static hal_irqreturn_t gpio_irq_test(void *data)
{
printf("GPIO_PD18 IRQ \r\n");
return 0;
}
void User_Program_thread(void *param)
{
int i;
uint32_t irq;
int ret = 0;
gpio_pin_t pin = GPIO_PD18;
printf("pin: %d\r\n", pin);
ret = hal_gpio_to_irq(pin, &irq);
if (ret < 0)
printf("gpio to irq error, irq num:%d error num: %d \r\n", irq, ret);
else
printf("Test hal_gpio_to_irq API success!\r\n");
ret = hal_gpio_irq_request(irq, gpio_irq_test, IRQ_TYPE_EDGE_RISING, (void *)pin);
if (ret < 0) {
printf("request irq error, irq num:%d error num: %d \r\n", irq, ret);
} else {
printf("Test hal_gpio_irq_request API success! \r\n");
}
ret = hal_gpio_irq_enable(irq);
if (ret < 0) {
printf("request irq error, error num: %d \r\n", ret);
} else {
printf("Test hal_gpio_irq_enable API success! \r\n");}
ret = hal_gpio_to_irq(pin, &irq);
if (ret < 0) {
printf("gpio to irq error, irq num:%d error num: %d \r\n", irq, ret);
} else {
printf("Test hal_gpio_to_irq API success! \r\n");
}
运行后串口输出如下:
pin: 114
Test hal_gpio_to_irq API success!
irq282 not belong to this chip,hwirq 89, mask=0x0
request irq error, irq num:282 error num: -1
Test hal_gpio_irq_enable API success!
Test hal_gpio_to_irq API success!
调用函数 ret = hal_gpio_to_irq(pin, &irq); 引出如下错误
irq282 not belong to this chip,hwirq 89, mask=0x0
是设置问题吗?
sys_config.fex 加了
[gpio_irg]
GPIOD=1
GPIOE=1
GPIO 设置按要求改了
|
|