@@ -23,8 +23,7 @@ static const struct spi_dt_spec spi = SPI_DT_SPEC_INST_GET(0,
23
23
0 );
24
24
25
25
/* GPIO int line */
26
- #define IRQ_PIN DT_GPIO_PIN(NODE_ID, irq_gpios)
27
- static const struct device * int_ft8xx_dev ;
26
+ static const struct gpio_dt_spec irq_gpio = GPIO_DT_SPEC_INST_GET (0 , irq_gpios );
28
27
29
28
static struct gpio_callback irq_cb_data ;
30
29
@@ -64,25 +63,23 @@ int ft8xx_drv_init(void)
64
63
/* TODO: Verify if such entry in DTS is present.
65
64
* If not, use polling mode.
66
65
*/
67
- int_ft8xx_dev = device_get_binding ( DT_GPIO_LABEL ( NODE_ID , irq_gpios ));
68
- if (! int_ft8xx_dev ) {
66
+ if (! device_is_ready ( irq_gpio . port )) {
67
+ LOG_ERR ( "GPIO device %s is not ready" , irq_gpio . port -> name );
69
68
return - ENODEV ;
70
69
}
71
70
72
- ret = gpio_pin_configure (int_ft8xx_dev , IRQ_PIN ,
73
- GPIO_INPUT | DT_GPIO_FLAGS (NODE_ID , irq_gpios ));
71
+ ret = gpio_pin_configure_dt (& irq_gpio , GPIO_INPUT );
74
72
if (ret != 0 ) {
75
73
return ret ;
76
74
}
77
75
78
- ret = gpio_pin_interrupt_configure (int_ft8xx_dev , IRQ_PIN ,
79
- GPIO_INT_EDGE_TO_ACTIVE );
76
+ ret = gpio_pin_interrupt_configure_dt (& irq_gpio , GPIO_INT_EDGE_TO_ACTIVE );
80
77
if (ret != 0 ) {
81
78
return ret ;
82
79
}
83
80
84
- gpio_init_callback (& irq_cb_data , ft8xx_drv_irq_triggered , BIT (IRQ_PIN ));
85
- gpio_add_callback (int_ft8xx_dev , & irq_cb_data );
81
+ gpio_init_callback (& irq_cb_data , ft8xx_drv_irq_triggered , BIT (irq_gpio . pin ));
82
+ gpio_add_callback (irq_gpio . port , & irq_cb_data );
86
83
87
84
return 0 ;
88
85
}
0 commit comments