@@ -21,11 +21,12 @@ static void board_setup(void)
21
21
{
22
22
#if DT_NODE_HAS_STATUS (DT_INST (0 , test_gpio_basic_api ), okay )
23
23
/* PIN_IN and PIN_OUT must be on same controller. */
24
- if (strcmp (DT_GPIO_LABEL (DT_INST (0 , test_gpio_basic_api ), out_gpios ),
25
- DT_GPIO_LABEL (DT_INST (0 , test_gpio_basic_api ), in_gpios )) != 0 ) {
24
+ const struct device * in_dev = DEVICE_DT_GET (DEV_OUT );
25
+ const struct device * out_dev = DEVICE_DT_GET (DEV_IN );
26
+
27
+ if (in_dev != out_dev ) {
26
28
printk ("FATAL: output controller %s != input controller %s\n" ,
27
- DT_GPIO_LABEL (DT_INST (0 , test_gpio_basic_api ), out_gpios ),
28
- DT_GPIO_LABEL (DT_INST (0 , test_gpio_basic_api ), in_gpios ));
29
+ out_dev -> name , in_dev -> name );
29
30
k_panic ();
30
31
}
31
32
#endif
@@ -37,12 +38,6 @@ static void board_setup(void)
37
38
* selected as test pins in device tree.
38
39
*/
39
40
40
- if (strcmp (DEV_NAME , "GPIO_5" ) != 0 ) {
41
- printk ("FATAL: controller set in DTS %s != controller %s\n" ,
42
- DEV_NAME , "GPIO_5" );
43
- k_panic ();
44
- }
45
-
46
41
if (PIN_IN != 15 ) {
47
42
printk ("FATAL: input pin set in DTS %d != %d\n" , PIN_IN , 15 );
48
43
k_panic ();
@@ -87,16 +82,17 @@ static void board_setup(void)
87
82
IOMUXC_SW_PAD_CTL_PAD_SPEED (2 ) |
88
83
IOMUXC_SW_PAD_CTL_PAD_DSE (6 ));
89
84
#elif defined(CONFIG_BOARD_RV32M1_VEGA )
90
- const char * pmx_name = DT_LABEL (DT_NODELABEL (porta ));
91
- const struct device * pmx = device_get_binding (pmx_name );
85
+ const struct device * pmx = DEVICE_DT_GET (DT_NODELABEL (porta ));
86
+
87
+ zassert_true (device_is_ready (pmx ), "pinmux dev is not ready" );
92
88
93
89
pinmux_pin_set (pmx , PIN_OUT , PORT_PCR_MUX (kPORT_MuxAsGpio ));
94
90
pinmux_pin_set (pmx , PIN_IN , PORT_PCR_MUX (kPORT_MuxAsGpio ));
95
91
#elif defined(CONFIG_GPIO_EMUL )
96
92
extern struct gpio_callback gpio_emul_callback ;
97
- const struct device * dev = device_get_binding ( DEV_NAME );
98
- zassert_not_equal ( dev , NULL ,
99
- "Device not found " );
93
+ const struct device * dev = DEVICE_DT_GET ( DEV );
94
+
95
+ zassert_true ( device_is_ready ( dev ), "GPIO dev is not ready " );
100
96
int rc = gpio_add_callback (dev , & gpio_emul_callback );
101
97
__ASSERT (rc == 0 , "gpio_add_callback() failed: %d" , rc );
102
98
#endif
0 commit comments