diff --git a/samples/basic/blink_led/src/main.c b/samples/basic/blink_led/src/main.c index 7c51654533..5160041216 100644 --- a/samples/basic/blink_led/src/main.c +++ b/samples/basic/blink_led/src/main.c @@ -15,12 +15,13 @@ #include #include -#if defined(DT_ALIAS_PWM_LED0_PWMS_CONTROLLER) && defined(DT_ALIAS_PWM_LED0_PWMS_CHANNEL) +#if DT_NODE_HAS_PROP(DT_ALIAS(pwm_led0), pwms) && \ + DT_PHA_HAS_CELL(DT_ALIAS(pwm_led0), pwms, channel) /* get the defines from dt (based on alias 'pwm-led0') */ -#define PWM_DRIVER DT_ALIAS_PWM_LED0_PWMS_CONTROLLER -#define PWM_CHANNEL DT_ALIAS_PWM_LED0_PWMS_CHANNEL -#ifdef DT_ALIAS_PWM_LED0_PWMS_FLAGS -#define PWM_FLAGS DT_ALIAS_PWM_LED0_PWMS_FLAGS +#define PWM_DRIVER DT_PWMS_LABEL(DT_ALIAS(pwm_led0)) +#define PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led0)) +#if DT_PHA_HAS_CELL(DT_ALIAS(pwm_led0), pwms, flags) +#define PWM_FLAGS DT_PWMS_FLAGS(DT_ALIAS(pwm_led0)) #else #define PWM_FLAGS 0 #endif diff --git a/samples/basic/button/README.rst b/samples/basic/button/README.rst index bfb92a8e97..0353fb7a0b 100644 --- a/samples/basic/button/README.rst +++ b/samples/basic/button/README.rst @@ -18,8 +18,8 @@ have defined the SW0_* variables. To use this sample, you will require a board that defines the user switch in its header file. The :file:`board.h` must define the following variables: -- SW0_GPIO_NAME (or DT_ALIAS_SW0_GPIOS_CONTROLLER) -- DT_ALIAS_SW0_GPIOS_PIN +- SW0_GPIO_NAME (or DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)) +- DT_GPIO_PIN(DT_ALIAS(sw0), gpios) Alternatively, this could also be done by defining 'sw0' alias in the board devicetree description file. diff --git a/samples/basic/button/src/main.c b/samples/basic/button/src/main.c index 7c923fc42d..4d12526f4d 100644 --- a/samples/basic/button/src/main.c +++ b/samples/basic/button/src/main.c @@ -13,14 +13,14 @@ #define SLEEP_TIME_MS 1 -#ifdef DT_ALIAS_SW0_GPIOS_FLAGS -#define SW0_FLAGS DT_ALIAS_SW0_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, flags) +#define SW0_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) #else #define SW0_FLAGS 0 #endif -#ifdef DT_ALIAS_LED0_GPIOS_FLAGS -#define LED0_FLAGS DT_ALIAS_LED0_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(led0), gpios, flags) +#define LED0_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios) #else #define LED0_FLAGS 0 #endif @@ -38,59 +38,63 @@ void main(void) struct device *dev_button; int ret; - dev_button = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); + dev_button = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); if (dev_button == NULL) { printk("Error: didn't find %s device\n", - DT_ALIAS_SW0_GPIOS_CONTROLLER); + DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); return; } - ret = gpio_pin_configure(dev_button, DT_ALIAS_SW0_GPIOS_PIN, + ret = gpio_pin_configure(dev_button, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), SW0_FLAGS | GPIO_INPUT); if (ret != 0) { printk("Error %d: failed to configure pin %d '%s'\n", - ret, DT_ALIAS_SW0_GPIOS_PIN, DT_ALIAS_SW0_LABEL); + ret, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + DT_LABEL(DT_ALIAS(sw0))); return; } - ret = gpio_pin_interrupt_configure(dev_button, DT_ALIAS_SW0_GPIOS_PIN, + ret = gpio_pin_interrupt_configure(dev_button, + DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_TO_ACTIVE); if (ret != 0) { printk("Error %d: failed to configure interrupt on pin %d '%s'\n", - ret, DT_ALIAS_SW0_GPIOS_PIN, DT_ALIAS_SW0_LABEL); + ret, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + DT_LABEL(DT_ALIAS(sw0))); return; } gpio_init_callback(&button_cb_data, button_pressed, - BIT(DT_ALIAS_SW0_GPIOS_PIN)); + BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))); gpio_add_callback(dev_button, &button_cb_data); -#ifdef DT_ALIAS_LED0_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) struct device *dev_led; - dev_led = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); + dev_led = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); if (dev_led == NULL) { printk("Error: didn't find %s device\n", - DT_ALIAS_LED0_GPIOS_CONTROLLER); + DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); return; } - ret = gpio_pin_configure(dev_led, DT_ALIAS_LED0_GPIOS_PIN, + ret = gpio_pin_configure(dev_led, DT_GPIO_PIN(DT_ALIAS(led0), gpios), LED0_FLAGS | GPIO_OUTPUT); if (ret != 0) { printk("Error %d: failed to configure pin %d '%s'\n", - ret, DT_ALIAS_LED0_GPIOS_PIN, DT_ALIAS_LED0_LABEL); + ret, DT_GPIO_PIN(DT_ALIAS(led0), gpios), + DT_LABEL(DT_ALIAS(led0))); return; } #endif - printk("Press %s on the board\n", DT_ALIAS_SW0_LABEL); + printk("Press %s on the board\n", DT_LABEL(DT_ALIAS(sw0))); while (1) { -#ifdef DT_ALIAS_LED0_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) bool val; - val = gpio_pin_get(dev_button, DT_ALIAS_SW0_GPIOS_PIN); - gpio_pin_set(dev_led, DT_ALIAS_LED0_GPIOS_PIN, val); + val = gpio_pin_get(dev_button, DT_GPIO_PIN(DT_ALIAS(sw0), gpios)); + gpio_pin_set(dev_led, DT_GPIO_PIN(DT_ALIAS(led0), gpios), val); k_msleep(SLEEP_TIME_MS); #endif } diff --git a/samples/basic/fade_led/src/main.c b/samples/basic/fade_led/src/main.c index df14b624be..3d39055dfb 100644 --- a/samples/basic/fade_led/src/main.c +++ b/samples/basic/fade_led/src/main.c @@ -15,12 +15,13 @@ #include #include -#if defined(DT_ALIAS_PWM_LED0_PWMS_CONTROLLER) && defined(DT_ALIAS_PWM_LED0_PWMS_CHANNEL) +#if DT_NODE_HAS_PROP(DT_ALIAS(pwm_led0), pwms) && \ + DT_PHA_HAS_CELL(DT_ALIAS(pwm_led0), pwms, channel) /* get the defines from dt (based on alias 'pwm-led0') */ -#define PWM_DRIVER DT_ALIAS_PWM_LED0_PWMS_CONTROLLER -#define PWM_CHANNEL DT_ALIAS_PWM_LED0_PWMS_CHANNEL -#ifdef DT_ALIAS_PWM_LED0_PWMS_FLAGS -#define PWM_FLAGS DT_ALIAS_PWM_LED0_PWMS_FLAGS +#define PWM_DRIVER DT_PWMS_LABEL(DT_ALIAS(pwm_led0)) +#define PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led0)) +#if DT_PHA_HAS_CELL(DT_ALIAS(pwm_led0), pwms, flags) +#define PWM_FLAGS DT_PWMS_FLAGS(DT_ALIAS(pwm_led0)) #else #define PWM_FLAGS 0 #endif diff --git a/samples/basic/rgb_led/src/main.c b/samples/basic/rgb_led/src/main.c index 7b72a74d42..f42cabda94 100644 --- a/samples/basic/rgb_led/src/main.c +++ b/samples/basic/rgb_led/src/main.c @@ -15,33 +15,33 @@ #include #include -#if defined(DT_ALIAS_RED_PWM_LED_PWMS_CONTROLLER) && \ - defined(DT_ALIAS_RED_PWM_LED_PWMS_CHANNEL) && \ - defined(DT_ALIAS_GREEN_PWM_LED_PWMS_CONTROLLER) && \ - defined(DT_ALIAS_GREEN_PWM_LED_PWMS_CHANNEL) && \ - defined(DT_ALIAS_BLUE_PWM_LED_PWMS_CONTROLLER) && \ - defined(DT_ALIAS_BLUE_PWM_LED_PWMS_CHANNEL) +#if DT_NODE_HAS_PROP(DT_ALIAS(red_pwm_led), pwms) && \ + DT_PHA_HAS_CELL(DT_ALIAS(red_pwm_led), pwms, channel) && \ + DT_NODE_HAS_PROP(DT_ALIAS(green_pwm_led), pwms) && \ + DT_PHA_HAS_CELL(DT_ALIAS(green_pwm_led), pwms, channel) && \ + DT_NODE_HAS_PROP(DT_ALIAS(blue_pwm_led), pwms) && \ + DT_PHA_HAS_CELL(DT_ALIAS(blue_pwm_led), pwms, channel) /* Get the defines from dt (based on aliases 'red-pwm-led', 'green-pwm-led' & * 'blue-pwm-led') */ -#define PWM_DEV0 DT_ALIAS_RED_PWM_LED_PWMS_CONTROLLER -#define PWM_CH0 DT_ALIAS_RED_PWM_LED_PWMS_CHANNEL -#ifdef DT_ALIAS_RED_PWM_LED_PWMS_FLAGS -#define PWM_FLAGS0 DT_ALIAS_RED_PWM_LED_PWMS_FLAGS +#define PWM_DEV0 DT_PWMS_LABEL(DT_ALIAS(red_pwm_led)) +#define PWM_CH0 DT_PWMS_CHANNEL(DT_ALIAS(red_pwm_led)) +#if DT_PHA_HAS_CELL(DT_ALIAS(red_pwm_led), pwms, flags) +#define PWM_FLAGS0 DT_PWMS_FLAGS(DT_ALIAS(red_pwm_led)) #else #define PWM_FLAGS0 0 #endif -#define PWM_DEV1 DT_ALIAS_GREEN_PWM_LED_PWMS_CONTROLLER -#define PWM_CH1 DT_ALIAS_GREEN_PWM_LED_PWMS_CHANNEL -#ifdef DT_ALIAS_GREEN_PWM_LED_PWMS_FLAGS -#define PWM_FLAGS1 DT_ALIAS_GREEN_PWM_LED_PWMS_FLAGS +#define PWM_DEV1 DT_PWMS_LABEL(DT_ALIAS(green_pwm_led)) +#define PWM_CH1 DT_PWMS_CHANNEL(DT_ALIAS(green_pwm_led)) +#if DT_PHA_HAS_CELL(DT_ALIAS(green_pwm_led), pwms, flags) +#define PWM_FLAGS1 DT_PWMS_FLAGS(DT_ALIAS(green_pwm_led)) #else #define PWM_FLAGS1 0 #endif -#define PWM_DEV2 DT_ALIAS_BLUE_PWM_LED_PWMS_CONTROLLER -#define PWM_CH2 DT_ALIAS_BLUE_PWM_LED_PWMS_CHANNEL -#ifdef DT_ALIAS_BLUE_PWM_LED_PWMS_FLAGS -#define PWM_FLAGS2 DT_ALIAS_BLUE_PWM_LED_PWMS_FLAGS +#define PWM_DEV2 DT_PWMS_LABEL(DT_ALIAS(blue_pwm_led)) +#define PWM_CH2 DT_PWMS_CHANNEL(DT_ALIAS(blue_pwm_led)) +#if DT_PHA_HAS_CELL(DT_ALIAS(blue_pwm_led), pwms, flags) +#define PWM_FLAGS2 DT_PWMS_FLAGS(DT_ALIAS(blue_pwm_led)) #else #define PWM_FLAGS2 0 #endif diff --git a/samples/basic/servo_motor/src/main.c b/samples/basic/servo_motor/src/main.c index d36fb78b25..ad3915034a 100644 --- a/samples/basic/servo_motor/src/main.c +++ b/samples/basic/servo_motor/src/main.c @@ -15,7 +15,7 @@ #include #include -#ifndef DT_ALIAS_PWM_0_LABEL +#if !DT_HAS_NODE(DT_ALIAS(pwm_0)) #error "Choose supported board or add new board for the application" #endif @@ -38,7 +38,7 @@ void main(void) printk("PWM demo app-servo control\n"); - pwm_dev = device_get_binding(DT_ALIAS_PWM_0_LABEL); + pwm_dev = device_get_binding(DT_LABEL(DT_ALIAS(pwm_0))); if (!pwm_dev) { printk("Cannot find PWM device!\n"); return; diff --git a/samples/basic/threads/src/main.c b/samples/basic/threads/src/main.c index 8e0edd3937..190436e0b3 100644 --- a/samples/basic/threads/src/main.c +++ b/samples/basic/threads/src/main.c @@ -25,14 +25,14 @@ struct printk_data_t { K_FIFO_DEFINE(printk_fifo); -#ifdef DT_ALIAS_LED0_GPIOS_FLAGS -#define LED0_FLAGS DT_ALIAS_LED0_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(led0), gpios, flags) +#define LED0_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios) #else #define LED0_FLAGS 0 #endif -#ifdef DT_ALIAS_LED1_GPIOS_FLAGS -#define LED1_FLAGS DT_ALIAS_LED1_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(led1), gpios, flags) +#define LED1_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led1), gpios) #else #define LED1_FLAGS 0 #endif @@ -82,9 +82,9 @@ void blink(const struct led *led, u32_t sleep_ms, u32_t id) void blink1(void) { const struct led led1 = { - .gpio_dev_name = DT_ALIAS_LED0_GPIOS_CONTROLLER, - .gpio_pin_name = DT_ALIAS_LED0_LABEL, - .gpio_pin = DT_ALIAS_LED0_GPIOS_PIN, + .gpio_dev_name = DT_GPIO_LABEL(DT_ALIAS(led0), gpios), + .gpio_pin_name = DT_LABEL(DT_ALIAS(led0)), + .gpio_pin = DT_GPIO_PIN(DT_ALIAS(led0), gpios), .gpio_flags = GPIO_OUTPUT | LED0_FLAGS, }; @@ -94,9 +94,9 @@ void blink1(void) void blink2(void) { const struct led led2 = { - .gpio_dev_name = DT_ALIAS_LED1_GPIOS_CONTROLLER, - .gpio_pin_name = DT_ALIAS_LED1_LABEL, - .gpio_pin = DT_ALIAS_LED1_GPIOS_PIN, + .gpio_dev_name = DT_GPIO_LABEL(DT_ALIAS(led1), gpios), + .gpio_pin_name = DT_LABEL(DT_ALIAS(led1)), + .gpio_pin = DT_GPIO_PIN(DT_ALIAS(led1), gpios), .gpio_flags = GPIO_OUTPUT | LED1_FLAGS, }; diff --git a/samples/bluetooth/mesh/src/microbit.c b/samples/bluetooth/mesh/src/microbit.c index b0b288b45c..5ee14c7eff 100644 --- a/samples/bluetooth/mesh/src/microbit.c +++ b/samples/bluetooth/mesh/src/microbit.c @@ -30,14 +30,15 @@ static void configure_button(void) { static struct gpio_callback button_cb; - gpio = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); + gpio = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); - gpio_pin_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW0_GPIOS_FLAGS); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + GPIO_INPUT | DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios)); + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_TO_ACTIVE); - gpio_init_callback(&button_cb, button_pressed, BIT(DT_ALIAS_SW0_GPIOS_PIN)); + gpio_init_callback(&button_cb, button_pressed, + BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))); gpio_add_callback(gpio, &button_cb); } @@ -53,7 +54,7 @@ void board_output_number(bt_mesh_output_action_t action, u32_t number) oob_number = number; - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_TO_ACTIVE); mb_display_image(disp, MB_DISPLAY_MODE_DEFAULT, K_FOREVER, &arrow, 1); @@ -69,7 +70,7 @@ void board_prov_complete(void) { 0, 1, 1, 1, 0 }); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_DISABLE); mb_display_image(disp, MB_DISPLAY_MODE_DEFAULT, K_SECONDS(10), diff --git a/samples/bluetooth/mesh_demo/src/microbit.c b/samples/bluetooth/mesh_demo/src/microbit.c index 4f3a91741d..61e705420b 100644 --- a/samples/bluetooth/mesh_demo/src/microbit.c +++ b/samples/bluetooth/mesh_demo/src/microbit.c @@ -46,7 +46,7 @@ static void button_pressed(struct device *dev, struct gpio_callback *cb, { struct mb_display *disp = mb_display_get(); - if (pins & BIT(DT_ALIAS_SW0_GPIOS_PIN)) { + if (pins & BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))) { k_work_submit(&button_work); } else { u16_t target = board_set_target(); @@ -228,20 +228,21 @@ static void configure_button(void) k_work_init(&button_work, button_send_pressed); - gpio = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); + gpio = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); - gpio_pin_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW0_GPIOS_FLAGS); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + GPIO_INPUT | DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios)); + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_TO_ACTIVE); - gpio_pin_configure(gpio, DT_ALIAS_SW1_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW1_GPIOS_FLAGS); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW1_GPIOS_PIN, + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw1), gpios), + GPIO_INPUT | DT_GPIO_FLAGS(DT_ALIAS(sw1), gpios)); + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw1), gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb, button_pressed, - BIT(DT_ALIAS_SW0_GPIOS_PIN) | BIT(DT_ALIAS_SW1_GPIOS_PIN)); + BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) | + BIT(DT_GPIO_PIN(DT_ALIAS(sw1), gpios))); gpio_add_callback(gpio, &button_cb); } diff --git a/samples/bluetooth/st_ble_sensor/src/button_svc.c b/samples/bluetooth/st_ble_sensor/src/button_svc.c index c24ecb0493..7cd3f3ced7 100644 --- a/samples/bluetooth/st_ble_sensor/src/button_svc.c +++ b/samples/bluetooth/st_ble_sensor/src/button_svc.c @@ -27,8 +27,8 @@ LOG_MODULE_REGISTER(button_svc); -#define BUT_PORT DT_ALIAS_SW0_GPIOS_CONTROLLER -#define BUT_PIN DT_ALIAS_SW0_GPIOS_PIN +#define BUT_PORT DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) +#define BUT_PIN DT_GPIO_PIN(DT_ALIAS(sw0), gpios) extern struct bt_conn *conn; extern struct bt_gatt_service_static stsensor_svc[]; @@ -72,10 +72,11 @@ int button_init(void) } ret = gpio_pin_configure(button_dev, BUT_PIN, - DT_ALIAS_SW0_GPIOS_FLAGS | GPIO_INPUT); + DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) | + GPIO_INPUT); if (ret != 0) { LOG_ERR("Error %d: failed to configure pin %d '%s'\n", - ret, BUT_PIN, DT_ALIAS_SW0_LABEL); + ret, BUT_PIN, DT_LABEL(DT_ALIAS(sw0))); return ret; } @@ -87,7 +88,7 @@ int button_init(void) GPIO_INT_EDGE_TO_ACTIVE); if (ret != 0) { LOG_ERR("Error %d: failed to configure interrupt on pin " - "%d '%s'\n", ret, BUT_PIN, DT_ALIAS_SW0_LABEL); + "%d '%s'\n", ret, BUT_PIN, DT_LABEL(DT_ALIAS(sw0))); return ret; } but_val = 0; diff --git a/samples/bluetooth/st_ble_sensor/src/led_svc.c b/samples/bluetooth/st_ble_sensor/src/led_svc.c index bae1d9fe74..4df5ee8646 100644 --- a/samples/bluetooth/st_ble_sensor/src/led_svc.c +++ b/samples/bluetooth/st_ble_sensor/src/led_svc.c @@ -20,8 +20,8 @@ LOG_MODULE_REGISTER(led_svc); -#define LED_PORT DT_ALIAS_LED0_GPIOS_CONTROLLER -#define LED DT_ALIAS_LED0_GPIOS_PIN +#define LED_PORT DT_GPIO_LABEL(DT_ALIAS(led0), gpios) +#define LED DT_GPIO_PIN(DT_ALIAS(led0), gpios) struct device *led_dev; bool led_state; @@ -47,10 +47,10 @@ int led_init(void) ret = gpio_pin_configure(led_dev, LED, GPIO_OUTPUT_ACTIVE - | DT_ALIAS_LED0_GPIOS_FLAGS); + | DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); if (ret < 0) { LOG_ERR("Error %d: failed to configure pin %d '%s'\n", - ret, LED, DT_ALIAS_LED0_LABEL); + ret, LED, DT_LABEL(DT_ALIAS(led0))); return ret; } diff --git a/samples/boards/96b_argonkey/microphone/src/main.c b/samples/boards/96b_argonkey/microphone/src/main.c index 878740f173..b7fa2ec3c9 100644 --- a/samples/boards/96b_argonkey/microphone/src/main.c +++ b/samples/boards/96b_argonkey/microphone/src/main.c @@ -50,39 +50,45 @@ void signal_sampling_started(void) { static struct device *led0, *led1; - led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); - gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, - GPIO_OUTPUT_ACTIVE | DT_ALIAS_LED0_GPIOS_FLAGS); + led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); + gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), + GPIO_OUTPUT_ACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); - led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER); - gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, - GPIO_OUTPUT_INACTIVE | DT_ALIAS_LED1_GPIOS_FLAGS); + led1 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led1), gpios)); + gpio_pin_configure(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), + GPIO_OUTPUT_INACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led1), gpios)); } void signal_sampling_stopped(void) { static struct device *led0, *led1; - led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); - gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, - GPIO_OUTPUT_ACTIVE | DT_ALIAS_LED0_GPIOS_FLAGS); + led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); + gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), + GPIO_OUTPUT_ACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); - led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER); - gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, - GPIO_OUTPUT_ACTIVE | DT_ALIAS_LED1_GPIOS_FLAGS); + led1 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led1), gpios)); + gpio_pin_configure(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), + GPIO_OUTPUT_ACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led1), gpios)); } void signal_print_stopped(void) { static struct device *led0, *led1; - led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); - gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, - GPIO_OUTPUT_INACTIVE | DT_ALIAS_LED0_GPIOS_FLAGS); + led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); + gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), + GPIO_OUTPUT_INACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); - led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER); - gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, - GPIO_OUTPUT_ACTIVE | DT_ALIAS_LED1_GPIOS_FLAGS); + led1 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led1), gpios)); + gpio_pin_configure(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), + GPIO_OUTPUT_ACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led1), gpios)); } void *rx_block[NUM_MS]; diff --git a/samples/boards/96b_argonkey/sensors/src/main.c b/samples/boards/96b_argonkey/sensors/src/main.c index e1d1e9cf83..8e85b8fd7e 100644 --- a/samples/boards/96b_argonkey/sensors/src/main.c +++ b/samples/boards/96b_argonkey/sensors/src/main.c @@ -133,16 +133,18 @@ void main(void) } #endif - led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); - gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, - GPIO_OUTPUT_ACTIVE | DT_ALIAS_LED0_GPIOS_FLAGS); + led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); + gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), + GPIO_OUTPUT_ACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); - led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER); - gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, - GPIO_OUTPUT_INACTIVE | DT_ALIAS_LED1_GPIOS_FLAGS); + led1 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led1), gpios)); + gpio_pin_configure(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), + GPIO_OUTPUT_INACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led1), gpios)); for (i = 0; i < 5; i++) { - gpio_pin_set(led1, DT_ALIAS_LED1_GPIOS_PIN, on); + gpio_pin_set(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), on); k_sleep(K_MSEC(200)); on = (on == 1) ? 0 : 1; } diff --git a/samples/boards/bbc_microbit/line_follower_robot/src/main.c b/samples/boards/bbc_microbit/line_follower_robot/src/main.c index 74ae71054f..ea224edcf5 100644 --- a/samples/boards/bbc_microbit/line_follower_robot/src/main.c +++ b/samples/boards/bbc_microbit/line_follower_robot/src/main.c @@ -115,7 +115,7 @@ void main(void) { static struct gpio_callback line_sensors; - gpio = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); + gpio = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); i2c_dev = device_get_binding(I2C_DEV); /* Setup gpio to read data from digital line sensors of the robot */ gpio_pin_configure(gpio, EXT_P13_GPIO_PIN, GPIO_INPUT); diff --git a/samples/boards/bbc_microbit/pong/src/main.c b/samples/boards/bbc_microbit/pong/src/main.c index d2b78c82e5..eac562b2ef 100644 --- a/samples/boards/bbc_microbit/pong/src/main.c +++ b/samples/boards/bbc_microbit/pong/src/main.c @@ -394,7 +394,7 @@ static void button_pressed(struct device *dev, struct gpio_callback *cb, u32_t pins) { /* Filter out spurious presses */ - if (pins & BIT(DT_ALIAS_SW0_GPIOS_PIN)) { + if (pins & BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))) { printk("A pressed\n"); if (k_uptime_delta(&a_timestamp) < K_MSEC(100)) { printk("Too quick A presses\n"); @@ -422,7 +422,7 @@ static void button_pressed(struct device *dev, struct gpio_callback *cb, return; } - if (pins & BIT(DT_ALIAS_SW0_GPIOS_PIN)) { + if (pins & BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))) { if (select) { pong_select_change(); return; @@ -485,22 +485,22 @@ static void configure_buttons(void) static struct gpio_callback button_cb_data; struct device *gpio; - gpio = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); + gpio = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); - gpio_pin_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, - DT_ALIAS_SW0_GPIOS_FLAGS | GPIO_INPUT); - gpio_pin_configure(gpio, DT_ALIAS_SW1_GPIOS_PIN, - DT_ALIAS_SW1_GPIOS_FLAGS | GPIO_INPUT); + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) | GPIO_INPUT); + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw1), gpios), + DT_GPIO_FLAGS(DT_ALIAS(sw1), gpios) | GPIO_INPUT); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_TO_ACTIVE); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW1_GPIOS_PIN, + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw1), gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb_data, button_pressed, - BIT(DT_ALIAS_SW0_GPIOS_PIN) | - BIT(DT_ALIAS_SW1_GPIOS_PIN)); + BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) | + BIT(DT_GPIO_PIN(DT_ALIAS(sw1), gpios))); gpio_add_callback(gpio, &button_cb_data); } diff --git a/samples/boards/bbc_microbit/sound/src/main.c b/samples/boards/bbc_microbit/sound/src/main.c index 17c0df82c2..110a580826 100644 --- a/samples/boards/bbc_microbit/sound/src/main.c +++ b/samples/boards/bbc_microbit/sound/src/main.c @@ -57,7 +57,7 @@ static void button_pressed(struct device *dev, struct gpio_callback *cb, beep_active = true; - if (pins & BIT(DT_ALIAS_SW0_GPIOS_PIN)) { + if (pins & BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))) { printk("A pressed\n"); if (period < PERIOD_MAX) { period += 50U; @@ -82,22 +82,22 @@ void main(void) { static struct gpio_callback button_cb_data; - gpio = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); + gpio = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); - gpio_pin_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, - DT_ALIAS_SW0_GPIOS_FLAGS | GPIO_INPUT); - gpio_pin_configure(gpio, DT_ALIAS_SW1_GPIOS_PIN, - DT_ALIAS_SW1_GPIOS_FLAGS | GPIO_INPUT); + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) | GPIO_INPUT); + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw1), gpios), + DT_GPIO_FLAGS(DT_ALIAS(sw1), gpios) | GPIO_INPUT); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_TO_ACTIVE); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW1_GPIOS_PIN, + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw1), gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb_data, button_pressed, - BIT(DT_ALIAS_SW0_GPIOS_PIN) | - BIT(DT_ALIAS_SW1_GPIOS_PIN)); + BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) | + BIT(DT_GPIO_PIN(DT_ALIAS(sw1), gpios))); pwm = device_get_binding(DT_LABEL(DT_INST(0, nordic_nrf_sw_pwm))); diff --git a/samples/boards/nrf/mesh/onoff-app/src/main.c b/samples/boards/nrf/mesh/onoff-app/src/main.c index efc655cf3a..93d6f23753 100644 --- a/samples/boards/nrf/mesh/onoff-app/src/main.c +++ b/samples/boards/nrf/mesh/onoff-app/src/main.c @@ -179,10 +179,10 @@ struct onoff_state { */ static struct onoff_state onoff_state[] = { - { .led_gpio_pin = DT_ALIAS_LED0_GPIOS_PIN }, - { .led_gpio_pin = DT_ALIAS_LED1_GPIOS_PIN }, - { .led_gpio_pin = DT_ALIAS_LED2_GPIOS_PIN }, - { .led_gpio_pin = DT_ALIAS_LED3_GPIOS_PIN }, + { .led_gpio_pin = DT_GPIO_PIN(DT_ALIAS(led0), gpios) }, + { .led_gpio_pin = DT_GPIO_PIN(DT_ALIAS(led1), gpios) }, + { .led_gpio_pin = DT_GPIO_PIN(DT_ALIAS(led2), gpios) }, + { .led_gpio_pin = DT_GPIO_PIN(DT_ALIAS(led3), gpios) }, }; /* @@ -416,10 +416,10 @@ static u8_t dev_uuid[16] = { 0xdd, 0xdd }; static uint8_t pin_to_sw(uint32_t pin_pos) { switch (pin_pos) { - case BIT(DT_ALIAS_SW0_GPIOS_PIN): return 0; - case BIT(DT_ALIAS_SW1_GPIOS_PIN): return 1; - case BIT(DT_ALIAS_SW2_GPIOS_PIN): return 2; - case BIT(DT_ALIAS_SW3_GPIOS_PIN): return 3; + case BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios)): return 0; + case BIT(DT_GPIO_PIN(DT_ALIAS(sw1), gpios)): return 1; + case BIT(DT_GPIO_PIN(DT_ALIAS(sw2), gpios)): return 2; + case BIT(DT_GPIO_PIN(DT_ALIAS(sw3), gpios)): return 3; } printk("No match for GPIO pin 0x%08x\n", pin_pos); @@ -608,37 +608,51 @@ void main(void) /* Initialize button count timer */ k_timer_init(&sw.button_timer, button_cnt_timer, NULL); - sw_device = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); - gpio_pin_configure(sw_device, DT_ALIAS_SW0_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW0_GPIOS_FLAGS); - gpio_pin_configure(sw_device, DT_ALIAS_SW1_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW1_GPIOS_FLAGS); - gpio_pin_configure(sw_device, DT_ALIAS_SW2_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW2_GPIOS_FLAGS); - gpio_pin_configure(sw_device, DT_ALIAS_SW3_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW3_GPIOS_FLAGS); - gpio_pin_interrupt_configure(sw_device, DT_ALIAS_SW0_GPIOS_PIN, + sw_device = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); + gpio_pin_configure(sw_device, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + GPIO_INPUT | + DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios)); + gpio_pin_configure(sw_device, DT_GPIO_PIN(DT_ALIAS(sw1), gpios), + GPIO_INPUT | + DT_GPIO_FLAGS(DT_ALIAS(sw1), gpios)); + gpio_pin_configure(sw_device, DT_GPIO_PIN(DT_ALIAS(sw2), gpios), + GPIO_INPUT | + DT_GPIO_FLAGS(DT_ALIAS(sw2), gpios)); + gpio_pin_configure(sw_device, DT_GPIO_PIN(DT_ALIAS(sw3), gpios), + GPIO_INPUT | + DT_GPIO_FLAGS(DT_ALIAS(sw3), gpios)); + gpio_pin_interrupt_configure(sw_device, + DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_TO_ACTIVE); - gpio_pin_interrupt_configure(sw_device, DT_ALIAS_SW1_GPIOS_PIN, + gpio_pin_interrupt_configure(sw_device, + DT_GPIO_PIN(DT_ALIAS(sw1), gpios), GPIO_INT_EDGE_TO_ACTIVE); - gpio_pin_interrupt_configure(sw_device, DT_ALIAS_SW2_GPIOS_PIN, + gpio_pin_interrupt_configure(sw_device, + DT_GPIO_PIN(DT_ALIAS(sw2), gpios), GPIO_INT_EDGE_TO_ACTIVE); - gpio_pin_interrupt_configure(sw_device, DT_ALIAS_SW3_GPIOS_PIN, + gpio_pin_interrupt_configure(sw_device, + DT_GPIO_PIN(DT_ALIAS(sw3), gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb, button_pressed, - BIT(DT_ALIAS_SW0_GPIOS_PIN) | BIT(DT_ALIAS_SW1_GPIOS_PIN) | - BIT(DT_ALIAS_SW2_GPIOS_PIN) | BIT(DT_ALIAS_SW3_GPIOS_PIN)); + BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) | + BIT(DT_GPIO_PIN(DT_ALIAS(sw1), gpios)) | + BIT(DT_GPIO_PIN(DT_ALIAS(sw2), gpios)) | + BIT(DT_GPIO_PIN(DT_ALIAS(sw3), gpios))); gpio_add_callback(sw_device, &button_cb); /* Initialize LED's */ - init_led(0, DT_ALIAS_LED0_GPIOS_CONTROLLER, DT_ALIAS_LED0_GPIOS_PIN, - DT_ALIAS_LED0_GPIOS_FLAGS); - init_led(1, DT_ALIAS_LED1_GPIOS_CONTROLLER, DT_ALIAS_LED1_GPIOS_PIN, - DT_ALIAS_LED1_GPIOS_FLAGS); - init_led(2, DT_ALIAS_LED2_GPIOS_CONTROLLER, DT_ALIAS_LED2_GPIOS_PIN, - DT_ALIAS_LED2_GPIOS_FLAGS); - init_led(3, DT_ALIAS_LED3_GPIOS_CONTROLLER, DT_ALIAS_LED3_GPIOS_PIN, - DT_ALIAS_LED3_GPIOS_FLAGS); + init_led(0, DT_GPIO_LABEL(DT_ALIAS(led0), gpios), + DT_GPIO_PIN(DT_ALIAS(led0), gpios), + DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); + init_led(1, DT_GPIO_LABEL(DT_ALIAS(led1), gpios), + DT_GPIO_PIN(DT_ALIAS(led1), gpios), + DT_GPIO_FLAGS(DT_ALIAS(led1), gpios)); + init_led(2, DT_GPIO_LABEL(DT_ALIAS(led2), gpios), + DT_GPIO_PIN(DT_ALIAS(led2), gpios), + DT_GPIO_FLAGS(DT_ALIAS(led2), gpios)); + init_led(3, DT_GPIO_LABEL(DT_ALIAS(led3), gpios), + DT_GPIO_PIN(DT_ALIAS(led3), gpios), + DT_GPIO_FLAGS(DT_ALIAS(led3), gpios)); /* Initialize the Bluetooth Subsystem */ err = bt_enable(bt_ready); diff --git a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c index c5d614385c..2d993c4abe 100644 --- a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c +++ b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c @@ -21,72 +21,90 @@ static void button_pressed(struct device *dev, k_work_submit(&button_work); } +#define LED0_NODE DT_ALIAS(led0) +#define LED1_NODE DT_ALIAS(led1) +#define LED2_NODE DT_ALIAS(led2) +#define LED3_NODE DT_ALIAS(led3) + +#define SW0_NODE DT_ALIAS(sw0) +#define SW1_NODE DT_ALIAS(sw1) +#define SW2_NODE DT_ALIAS(sw2) +#define SW3_NODE DT_ALIAS(sw3) + void app_gpio_init(void) { static struct gpio_callback button_cb[4]; /* LEDs configuration & setting */ - led_device[0] = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); - gpio_pin_configure(led_device[0], DT_ALIAS_LED0_GPIOS_PIN, - DT_ALIAS_LED0_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE); + led_device[0] = device_get_binding(DT_GPIO_LABEL(LED0_NODE, gpios)); + gpio_pin_configure(led_device[0], DT_GPIO_PIN(LED0_NODE, gpios), + DT_GPIO_FLAGS(LED0_NODE, gpios) | + GPIO_OUTPUT_INACTIVE); #ifndef ONE_LED_ONE_BUTTON_BOARD - led_device[1] = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER); - gpio_pin_configure(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, - DT_ALIAS_LED1_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE); + led_device[1] = device_get_binding(DT_GPIO_LABEL(LED1_NODE, gpios)); + gpio_pin_configure(led_device[1], DT_GPIO_PIN(LED1_NODE, gpios), + DT_GPIO_FLAGS(LED1_NODE, gpios) | + GPIO_OUTPUT_INACTIVE); - led_device[2] = device_get_binding(DT_ALIAS_LED2_GPIOS_CONTROLLER); - gpio_pin_configure(led_device[2], DT_ALIAS_LED2_GPIOS_PIN, - DT_ALIAS_LED2_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE); + led_device[2] = device_get_binding(DT_GPIO_LABEL(LED2_NODE, gpios)); + gpio_pin_configure(led_device[2], DT_GPIO_PIN(LED2_NODE, gpios), + DT_GPIO_FLAGS(LED2_NODE, gpios) | + GPIO_OUTPUT_INACTIVE); - led_device[3] = device_get_binding(DT_ALIAS_LED3_GPIOS_CONTROLLER); - gpio_pin_configure(led_device[3], DT_ALIAS_LED3_GPIOS_PIN, - DT_ALIAS_LED3_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE); + led_device[3] = device_get_binding(DT_GPIO_LABEL(LED3_NODE, gpios)); + gpio_pin_configure(led_device[3], DT_GPIO_PIN(LED3_NODE, gpios), + DT_GPIO_FLAGS(LED3_NODE, gpios) | + GPIO_OUTPUT_INACTIVE); #endif /* Buttons configuration & setting */ k_work_init(&button_work, publish); - button_device[0] = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); - gpio_pin_configure(button_device[0], DT_ALIAS_SW0_GPIOS_PIN, + button_device[0] = device_get_binding(DT_GPIO_LABEL(SW0_NODE, gpios)); + gpio_pin_configure(button_device[0], DT_GPIO_PIN(SW0_NODE, gpios), GPIO_INPUT | GPIO_INT_DEBOUNCE | - DT_ALIAS_SW0_GPIOS_FLAGS); - gpio_pin_interrupt_configure(button_device[0], DT_ALIAS_SW0_GPIOS_PIN, + DT_GPIO_FLAGS(SW0_NODE, gpios)); + gpio_pin_interrupt_configure(button_device[0], + DT_GPIO_PIN(SW0_NODE, gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb[0], button_pressed, - BIT(DT_ALIAS_SW0_GPIOS_PIN)); + BIT(DT_GPIO_PIN(SW0_NODE, gpios))); gpio_add_callback(button_device[0], &button_cb[0]); #ifndef ONE_LED_ONE_BUTTON_BOARD - button_device[1] = device_get_binding(DT_ALIAS_SW1_GPIOS_CONTROLLER); - gpio_pin_configure(button_device[1], DT_ALIAS_SW1_GPIOS_PIN, + button_device[1] = device_get_binding(DT_GPIO_LABEL(SW1_NODE, gpios)); + gpio_pin_configure(button_device[1], DT_GPIO_PIN(SW1_NODE, gpios), GPIO_INPUT | GPIO_INT_DEBOUNCE | - DT_ALIAS_SW1_GPIOS_FLAGS); - gpio_pin_interrupt_configure(button_device[1], DT_ALIAS_SW1_GPIOS_PIN, + DT_GPIO_FLAGS(SW1_NODE, gpios)); + gpio_pin_interrupt_configure(button_device[1], + DT_GPIO_PIN(SW1_NODE, gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb[1], button_pressed, - BIT(DT_ALIAS_SW1_GPIOS_PIN)); + BIT(DT_GPIO_PIN(SW1_NODE, gpios))); gpio_add_callback(button_device[1], &button_cb[1]); - button_device[2] = device_get_binding(DT_ALIAS_SW2_GPIOS_CONTROLLER); - gpio_pin_configure(button_device[2], DT_ALIAS_SW2_GPIOS_PIN, + button_device[2] = device_get_binding(DT_GPIO_LABEL(SW2_NODE, gpios)); + gpio_pin_configure(button_device[2], DT_GPIO_PIN(SW2_NODE, gpios), GPIO_INPUT | GPIO_INT_DEBOUNCE | - DT_ALIAS_SW2_GPIOS_FLAGS); - gpio_pin_interrupt_configure(button_device[2], DT_ALIAS_SW2_GPIOS_PIN, + DT_GPIO_FLAGS(SW2_NODE, gpios)); + gpio_pin_interrupt_configure(button_device[2], + DT_GPIO_PIN(SW2_NODE, gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb[2], button_pressed, - BIT(DT_ALIAS_SW2_GPIOS_PIN)); + BIT(DT_GPIO_PIN(SW2_NODE, gpios))); gpio_add_callback(button_device[2], &button_cb[2]); - button_device[3] = device_get_binding(DT_ALIAS_SW3_GPIOS_CONTROLLER); - gpio_pin_configure(button_device[3], DT_ALIAS_SW3_GPIOS_PIN, + button_device[3] = device_get_binding(DT_GPIO_LABEL(SW3_NODE, gpios)); + gpio_pin_configure(button_device[3], DT_GPIO_PIN(SW3_NODE, gpios), GPIO_INPUT | GPIO_INT_DEBOUNCE | - DT_ALIAS_SW3_GPIOS_FLAGS); - gpio_pin_interrupt_configure(button_device[3], DT_ALIAS_SW3_GPIOS_PIN, + DT_GPIO_FLAGS(SW3_NODE, gpios)); + gpio_pin_interrupt_configure(button_device[3], + DT_GPIO_PIN(SW3_NODE, gpios), GPIO_INT_EDGE_TO_ACTIVE); gpio_init_callback(&button_cb[3], button_pressed, - BIT(DT_ALIAS_SW3_GPIOS_PIN)); + BIT(DT_GPIO_PIN(SW3_NODE, gpios))); gpio_add_callback(button_device[3], &button_cb[3]); #endif } diff --git a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/main.c b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/main.c index b7242824ee..cfbcec7690 100644 --- a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/main.c +++ b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/main.c @@ -94,7 +94,7 @@ static void light_default_status_init(void) void update_vnd_led_gpio(void) { #ifndef ONE_LED_ONE_BUTTON_BOARD - gpio_pin_set(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, + gpio_pin_set(led_device[1], DT_GPIO_PIN(DT_ALIAS(led1), gpios), vnd_user_data.current == STATE_ON); #endif } @@ -109,12 +109,13 @@ void update_led_gpio(void) printk("power-> %d, color-> %d\n", power, color); - gpio_pin_set(led_device[0], DT_ALIAS_LED0_GPIOS_PIN, + gpio_pin_set(led_device[0], DT_GPIO_PIN(DT_ALIAS(led0), gpios), ctl->light->current); #ifndef ONE_LED_ONE_BUTTON_BOARD - gpio_pin_set(led_device[2], DT_ALIAS_LED2_GPIOS_PIN, power < 50); - - gpio_pin_set(led_device[3], DT_ALIAS_LED3_GPIOS_PIN, color < 50); + gpio_pin_set(led_device[2], DT_GPIO_PIN(DT_ALIAS(led2), gpios), + power < 50); + gpio_pin_set(led_device[3], DT_GPIO_PIN(DT_ALIAS(led3), gpios), + color < 50); #endif } diff --git a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c index 5450a003f7..7cd367cea8 100644 --- a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c +++ b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/publisher.c @@ -22,7 +22,8 @@ void publish(struct k_work *work) int err = 0; #ifndef ONE_LED_ONE_BUTTON_BOARD - if (gpio_pin_get(button_device[0], DT_ALIAS_SW0_GPIOS_PIN) == 1) { + if (gpio_pin_get(button_device[0], + DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) == 1) { #if defined(ONOFF) bt_mesh_model_msg_init(root_models[3].pub->msg, BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK); @@ -44,8 +45,8 @@ void publish(struct k_work *work) net_buf_simple_add_u8(vnd_models[0].pub->msg, tid++); err = bt_mesh_model_publish(&vnd_models[0]); #endif - } else if (gpio_pin_get(button_device[1], DT_ALIAS_SW1_GPIOS_PIN) == - 1) { + } else if (gpio_pin_get(button_device[1], + DT_GPIO_PIN(DT_ALIAS(sw1), gpios)) == 1) { #if defined(ONOFF) bt_mesh_model_msg_init(root_models[3].pub->msg, BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK); @@ -67,8 +68,8 @@ void publish(struct k_work *work) net_buf_simple_add_u8(vnd_models[0].pub->msg, tid++); err = bt_mesh_model_publish(&vnd_models[0]); #endif - } else if (gpio_pin_get(button_device[2], DT_ALIAS_SW2_GPIOS_PIN) == - 1) { + } else if (gpio_pin_get(button_device[2], + DT_GPIO_PIN(DT_ALIAS(sw2), gpios)) == 1) { #if defined(GENERIC_LEVEL) bt_mesh_model_msg_init(root_models[5].pub->msg, BT_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK); @@ -138,8 +139,8 @@ void publish(struct k_work *work) net_buf_simple_add_u8(root_models[16].pub->msg, tid++); err = bt_mesh_model_publish(&root_models[16]); #endif - } else if (gpio_pin_get(button_device[3], DT_ALIAS_SW3_GPIOS_PIN) == - 1) { + } else if (gpio_pin_get(button_device[3], + DT_GPIO_PIN(DT_ALIAS(sw3), gpios)) == 1) { #if defined(GENERIC_LEVEL) bt_mesh_model_msg_init(root_models[5].pub->msg, BT_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK); @@ -207,7 +208,8 @@ void publish(struct k_work *work) #endif } #else - if (gpio_pin_get(button_device[0], DT_ALIAS_SW0_GPIOS_PIN) == 1) { + if (gpio_pin_get(button_device[0], + DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) == 1) { #if defined(ONOFF) static u8_t state = STATE_ON; diff --git a/samples/boards/nrf/nrfx/src/main.c b/samples/boards/nrf/nrfx/src/main.c index f799b5ed1f..a38b7d65e8 100644 --- a/samples/boards/nrf/nrfx/src/main.c +++ b/samples/boards/nrf/nrfx/src/main.c @@ -12,8 +12,8 @@ #include LOG_MODULE_REGISTER(nrfx_sample, LOG_LEVEL_INF); -#define INPUT_PIN DT_ALIAS_SW0_GPIOS_PIN -#define OUTPUT_PIN DT_ALIAS_LED0_GPIOS_PIN +#define INPUT_PIN DT_GPIO_PIN(DT_ALIAS(sw0), gpios) +#define OUTPUT_PIN DT_GPIO_PIN(DT_ALIAS(led0), gpios) static void button_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { diff --git a/samples/boards/reel_board/mesh_badge/src/reel_board.c b/samples/boards/reel_board/mesh_badge/src/reel_board.c index 9dbcb94ad3..27156c4e66 100644 --- a/samples/boards/reel_board/mesh_badge/src/reel_board.c +++ b/samples/boards/reel_board/mesh_badge/src/reel_board.c @@ -47,8 +47,8 @@ struct font_info { #define STAT_COUNT 128 -#ifdef DT_ALIAS_SW0_GPIOS_FLAGS -#define PULL_UP DT_ALIAS_SW0_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, flags) +#define PULL_UP DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) #else #define PULL_UP 0 #endif @@ -67,12 +67,15 @@ static struct { gpio_pin_t pin; gpio_flags_t flags; } leds[] = { - { .name = DT_ALIAS_LED0_GPIOS_CONTROLLER, .pin = DT_ALIAS_LED0_GPIOS_PIN, - .flags = DT_ALIAS_LED0_GPIOS_FLAGS}, - { .name = DT_ALIAS_LED1_GPIOS_CONTROLLER, .pin = DT_ALIAS_LED1_GPIOS_PIN, - .flags = DT_ALIAS_LED1_GPIOS_FLAGS}, - { .name = DT_ALIAS_LED2_GPIOS_CONTROLLER, .pin = DT_ALIAS_LED2_GPIOS_PIN, - .flags = DT_ALIAS_LED2_GPIOS_FLAGS} + { .name = DT_GPIO_LABEL(DT_ALIAS(led0), gpios), + .pin = DT_GPIO_PIN(DT_ALIAS(led0), gpios), + .flags = DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)}, + { .name = DT_GPIO_LABEL(DT_ALIAS(led1), gpios), + .pin = DT_GPIO_PIN(DT_ALIAS(led1), gpios), + .flags = DT_GPIO_FLAGS(DT_ALIAS(led1), gpios)}, + { .name = DT_GPIO_LABEL(DT_ALIAS(led2), gpios), + .pin = DT_GPIO_PIN(DT_ALIAS(led2), gpios), + .flags = DT_GPIO_FLAGS(DT_ALIAS(led2), gpios)} }; struct k_delayed_work led_timer; @@ -446,7 +449,7 @@ static void long_press(struct k_work *work) static bool button_is_pressed(void) { - return gpio_pin_get(gpio, DT_ALIAS_SW0_GPIOS_PIN) > 0; + return gpio_pin_get(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) > 0; } static void button_interrupt(struct device *dev, struct gpio_callback *cb, @@ -476,7 +479,7 @@ static void button_interrupt(struct device *dev, struct gpio_callback *cb, case SCREEN_STATS: return; case SCREEN_MAIN: - if (pins & BIT(DT_ALIAS_SW0_GPIOS_PIN)) { + if (pins & BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))) { u32_t uptime = k_uptime_get_32(); static u32_t bad_count, press_ts; @@ -509,19 +512,19 @@ static int configure_button(void) { static struct gpio_callback button_cb; - gpio = device_get_binding(DT_ALIAS_SW0_GPIOS_CONTROLLER); + gpio = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); if (!gpio) { return -ENODEV; } - gpio_pin_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, - GPIO_INPUT | DT_ALIAS_SW0_GPIOS_FLAGS); + gpio_pin_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), + GPIO_INPUT | DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios)); - gpio_pin_interrupt_configure(gpio, DT_ALIAS_SW0_GPIOS_PIN, + gpio_pin_interrupt_configure(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios), GPIO_INT_EDGE_BOTH); gpio_init_callback(&button_cb, button_interrupt, - BIT(DT_ALIAS_SW0_GPIOS_PIN)); + BIT(DT_GPIO_PIN(DT_ALIAS(sw0), gpios))); gpio_add_callback(gpio, &button_cb); diff --git a/samples/boards/sensortile_box/src/main.c b/samples/boards/sensortile_box/src/main.c index c4e93b9849..9db2d1f115 100644 --- a/samples/boards/sensortile_box/src/main.c +++ b/samples/boards/sensortile_box/src/main.c @@ -251,23 +251,25 @@ void main(void) int i, on = 1; int cnt = 1; - led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); - gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, - GPIO_OUTPUT_ACTIVE | DT_ALIAS_LED0_GPIOS_FLAGS); + led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); + gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), + GPIO_OUTPUT_ACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); - led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER); - gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, - GPIO_OUTPUT_INACTIVE | DT_ALIAS_LED1_GPIOS_FLAGS); + led1 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led1), gpios)); + gpio_pin_configure(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), + GPIO_OUTPUT_INACTIVE | + DT_GPIO_FLAGS(DT_ALIAS(led1), gpios)); for (i = 0; i < 6; i++) { - gpio_pin_set(led0, DT_ALIAS_LED0_GPIOS_PIN, on); - gpio_pin_set(led1, DT_ALIAS_LED1_GPIOS_PIN, !on); + gpio_pin_set(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), on); + gpio_pin_set(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), !on); k_sleep(K_MSEC(100)); on = (on == 1) ? 0 : 1; } - gpio_pin_set(led0, DT_ALIAS_LED0_GPIOS_PIN, 0); - gpio_pin_set(led1, DT_ALIAS_LED1_GPIOS_PIN, 1); + gpio_pin_set(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), 0); + gpio_pin_set(led1, DT_GPIO_PIN(DT_ALIAS(led1), gpios), 1); printk("SensorTile.box test!!\n"); diff --git a/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c b/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c index 4481c2e97c..e6a0c322ee 100644 --- a/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c +++ b/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c @@ -15,9 +15,9 @@ #include -#define PORT DT_ALIAS_SW0_GPIOS_CONTROLLER -#define PIN DT_ALIAS_SW0_GPIOS_PIN -#define PULL_UP DT_ALIAS_SW0_GPIOS_FLAGS +#define PORT DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) +#define PIN DT_GPIO_PIN(DT_ALIAS(sw0), gpios) +#define PULL_UP DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) #define BUSY_WAIT_S 5U #define SLEEP_US 2000U diff --git a/samples/drivers/can/src/main.c b/samples/drivers/can/src/main.c index 79d440ad59..e597af3146 100644 --- a/samples/drivers/can/src/main.c +++ b/samples/drivers/can/src/main.c @@ -81,7 +81,8 @@ void change_led(struct zcan_frame *msg, void *led_dev_param) { struct device *led_dev = (struct device *)led_dev_param; -#if defined(DT_ALIAS_LED0_GPIOS_PIN) && defined(DT_ALIAS_LED0_GPIOS_CONTROLLER) +#if DT_PHA_HAS_CELL(DT_ALIAS(led0), gpios, pin) && \ + DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) if (!led_dev_param) { printk("No LED GPIO device\n"); @@ -90,10 +91,10 @@ void change_led(struct zcan_frame *msg, void *led_dev_param) switch (msg->data[0]) { case SET_LED: - gpio_pin_set(led_dev, DT_ALIAS_LED0_GPIOS_PIN, 1); + gpio_pin_set(led_dev, DT_GPIO_PIN(DT_ALIAS(led0), gpios), 1); break; case RESET_LED: - gpio_pin_set(led_dev, DT_ALIAS_LED0_GPIOS_PIN, 0); + gpio_pin_set(led_dev, DT_GPIO_PIN(DT_ALIAS(led0), gpios), 0); break; } #else @@ -206,15 +207,18 @@ void main(void) can_configure(can_dev, CAN_LOOPBACK_MODE, 125000); #endif -#if defined(DT_ALIAS_LED0_GPIOS_PIN) && defined(DT_ALIAS_LED0_GPIOS_CONTROLLER) - led_gpio_dev = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER); +#if DT_PHA_HAS_CELL(DT_ALIAS(led0), gpios, pin) && \ + DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) + led_gpio_dev = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); if (!led_gpio_dev) { printk("LED: Device driver not found.\n"); return; } - ret = gpio_pin_configure(led_gpio_dev, DT_ALIAS_LED0_GPIOS_PIN, - GPIO_OUTPUT_HIGH | DT_ALIAS_LED0_GPIOS_FLAGS); + ret = gpio_pin_configure(led_gpio_dev, + DT_GPIO_PIN(DT_ALIAS(led0), gpios), + GPIO_OUTPUT_HIGH | + DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)); if (ret < 0) { printk("Error setting LED pin to output mode [%d]", ret); } diff --git a/samples/drivers/i2c_fujitsu_fram/src/main.c b/samples/drivers/i2c_fujitsu_fram/src/main.c index a49a993750..6e94311d9b 100644 --- a/samples/drivers/i2c_fujitsu_fram/src/main.c +++ b/samples/drivers/i2c_fujitsu_fram/src/main.c @@ -10,7 +10,7 @@ #include #include -#define I2C_DEV DT_ALIAS_I2C_0_LABEL +#define I2C_DEV DT_LABEL(DT_ALIAS(i2c_0)) /** * @file Sample app using the Fujitsu MB85RC256V FRAM through ARC I2C. diff --git a/samples/drivers/led_apa102c_bitbang/src/main.c b/samples/drivers/led_apa102c_bitbang/src/main.c index e1cfeb847f..f15dc038ea 100644 --- a/samples/drivers/led_apa102c_bitbang/src/main.c +++ b/samples/drivers/led_apa102c_bitbang/src/main.c @@ -29,7 +29,7 @@ #define GPIO_CLK_PIN 19 #define GPIO_NAME "GPIO_" -#define GPIO_DRV_NAME DT_ALIAS_GPIO_0_LABEL +#define GPIO_DRV_NAME DT_LABEL(DT_ALIAS(gpio_0)) #define APA102C_START_FRAME 0x00000000 #define APA102C_END_FRAME 0xFFFFFFFF diff --git a/samples/drivers/led_ws2812/src/main.c b/samples/drivers/led_ws2812/src/main.c index adf0423fc9..2ee641274b 100644 --- a/samples/drivers/led_ws2812/src/main.c +++ b/samples/drivers/led_ws2812/src/main.c @@ -18,8 +18,8 @@ LOG_MODULE_REGISTER(main); #include #include -#define STRIP_LABEL DT_ALIAS_LED_STRIP_LABEL -#define STRIP_NUM_PIXELS DT_ALIAS_LED_STRIP_CHAIN_LENGTH +#define STRIP_LABEL DT_LABEL(DT_ALIAS(led_strip)) +#define STRIP_NUM_PIXELS DT_PROP(DT_ALIAS(led_strip), chain_length) #define DELAY_TIME K_MSEC(50) diff --git a/samples/drivers/peci/src/main.c b/samples/drivers/peci/src/main.c index 6ba88060bd..5ea31932bd 100644 --- a/samples/drivers/peci/src/main.c +++ b/samples/drivers/peci/src/main.c @@ -176,7 +176,7 @@ static void monitor_temperature_func(void *dummy1, void *dummy2, void *dummy3) void main(void) { -#ifdef DT_ALIAS_PECI_0_LABEL +#if DT_HAS_NODE(DT_ALIAS(peci_0)) int ret; #endif @@ -186,8 +186,8 @@ void main(void) monitor_temperature_func, NULL, NULL, NULL, PRIORITY, K_INHERIT_PERMS, K_FOREVER); -#ifdef DT_ALIAS_PECI_0_LABEL - peci_dev = device_get_binding(DT_ALIAS_PECI_0_LABEL); +#if DT_HAS_NODE(DT_ALIAS(peci_0)) + peci_dev = device_get_binding(DT_LABEL(DT_ALIAS(peci_0))); if (!peci_dev) { printk("Err: PECI device not found\n"); return; diff --git a/samples/drivers/spi_fujitsu_fram/src/main.c b/samples/drivers/spi_fujitsu_fram/src/main.c index 91f1ddb2c4..f6c9792877 100644 --- a/samples/drivers/spi_fujitsu_fram/src/main.c +++ b/samples/drivers/spi_fujitsu_fram/src/main.c @@ -143,7 +143,7 @@ void main(void) printk("fujitsu FRAM example application\n"); - spi = device_get_binding(DT_ALIAS_SPI_1_LABEL); + spi = device_get_binding(DT_LABEL(DT_ALIAS(spi_1))); if (!spi) { printk("Could not find SPI driver\n"); return; diff --git a/samples/net/lwm2m_client/src/lwm2m-client.c b/samples/net/lwm2m_client/src/lwm2m-client.c index 6ab1365fb3..e44960bc8a 100644 --- a/samples/net/lwm2m_client/src/lwm2m-client.c +++ b/samples/net/lwm2m_client/src/lwm2m-client.c @@ -51,10 +51,10 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #define ENDPOINT_LEN 32 -#ifdef DT_ALIAS_LED0_GPIOS_CONTROLLER -#define LED_GPIO_PORT DT_ALIAS_LED0_GPIOS_CONTROLLER -#define LED_GPIO_PIN DT_ALIAS_LED0_GPIOS_PIN -#define LED_GPIO_FLAGS DT_ALIAS_LED0_GPIOS_FLAGS +#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) +#define LED_GPIO_PORT DT_GPIO_LABEL(DT_ALIAS(led0), gpios) +#define LED_GPIO_PIN DT_GPIO_PIN(DT_ALIAS(led0), gpios) +#define LED_GPIO_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios) #else #define LED_GPIO_PORT "(fail)" #define LED_GPIO_PIN 0 diff --git a/samples/sensor/fxos8700-hid/src/main.c b/samples/sensor/fxos8700-hid/src/main.c index d6df937894..7317cd0f51 100644 --- a/samples/sensor/fxos8700-hid/src/main.c +++ b/samples/sensor/fxos8700-hid/src/main.c @@ -16,42 +16,42 @@ LOG_MODULE_REGISTER(main); /* change this to use another GPIO port */ -#ifdef DT_ALIAS_SW0_GPIOS_CONTROLLER -#define PORT0 DT_ALIAS_SW0_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw0), gpios) +#define PORT0 DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_CONTROLLER needs to be set +#error DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) needs to be set #endif /* change this to use another GPIO pin */ -#ifdef DT_ALIAS_SW0_GPIOS_PIN -#define PIN0 DT_ALIAS_SW0_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, pin) +#define PIN0 DT_GPIO_PIN(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_PIN needs to be set +#error DT_GPIO_PIN(DT_ALIAS(sw0), gpios) needs to be set #endif /* The switch pin pull-up/down flags */ -#ifdef DT_ALIAS_SW0_GPIOS_FLAGS -#define PIN0_FLAGS DT_ALIAS_SW0_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, flags) +#define PIN0_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_FLAGS needs to be set +#error DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) needs to be set #endif /* If second button exists, use it as right-click. */ -#ifdef DT_ALIAS_SW1_GPIOS_PIN -#define PIN1 DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) +#define PIN1 DT_GPIO_PIN(DT_ALIAS(sw1), gpios) #endif -#ifdef DT_ALIAS_SW1_GPIOS_CONTROLLER -#define PORT1 DT_ALIAS_SW1_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw1), gpios) +#define PORT1 DT_GPIO_LABEL(DT_ALIAS(sw1), gpios) #endif -#ifdef DT_ALIAS_SW1_GPIOS_FLAGS -#define PIN1_FLAGS DT_ALIAS_SW1_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, flags) +#define PIN1_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw1), gpios) #endif -#define LED_PORT DT_ALIAS_LED0_GPIOS_CONTROLLER -#define LED DT_ALIAS_LED0_GPIOS_PIN -#define LED_FLAGS DT_ALIAS_LED0_GPIOS_FLAGS +#define LED_PORT DT_GPIO_LABEL(DT_ALIAS(led0), gpios) +#define LED DT_GPIO_PIN(DT_ALIAS(led0), gpios) +#define LED_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios) #ifdef CONFIG_FXOS8700 #include @@ -93,7 +93,7 @@ static void left_button(struct device *gpio, struct gpio_callback *cb, } } -#ifdef DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) static void right_button(struct device *gpio, struct gpio_callback *cb, u32_t pins) { @@ -217,7 +217,7 @@ void main(void) return; } -#ifdef DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) if (callbacks_configure(device_get_binding(PORT1), PIN1, PIN1_FLAGS, &right_button, &callback[1], &def_val[1])) { LOG_ERR("Failed configuring right button callback."); diff --git a/samples/subsys/canbus/canopen/src/main.c b/samples/subsys/canbus/canopen/src/main.c index 63bc22fbe9..6996c8c32a 100644 --- a/samples/subsys/canbus/canopen/src/main.c +++ b/samples/subsys/canbus/canopen/src/main.c @@ -21,22 +21,22 @@ LOG_MODULE_REGISTER(app); #error CANopen CAN interface not set #endif -#ifdef DT_ALIAS_GREEN_LED_GPIOS_CONTROLLER -#define LED_GREEN_PORT DT_ALIAS_GREEN_LED_GPIOS_CONTROLLER -#define LED_GREEN_PIN DT_ALIAS_GREEN_LED_GPIOS_PIN -#define LED_GREEN_FLAGS DT_ALIAS_GREEN_LED_GPIOS_FLAGS +#if DT_NODE_HAS_PROP(DT_ALIAS(green_led), gpios) +#define LED_GREEN_PORT DT_GPIO_LABEL(DT_ALIAS(green_led), gpios) +#define LED_GREEN_PIN DT_GPIO_PIN(DT_ALIAS(green_led), gpios) +#define LED_GREEN_FLAGS DT_GPIO_FLAGS(DT_ALIAS(green_led), gpios) #endif -#ifdef DT_ALIAS_RED_LED_GPIOS_CONTROLLER -#define LED_RED_PORT DT_ALIAS_RED_LED_GPIOS_CONTROLLER -#define LED_RED_PIN DT_ALIAS_RED_LED_GPIOS_PIN -#define LED_RED_FLAGS DT_ALIAS_RED_LED_GPIOS_FLAGS +#if DT_NODE_HAS_PROP(DT_ALIAS(red_led), gpios) +#define LED_RED_PORT DT_GPIO_LABEL(DT_ALIAS(red_led), gpios) +#define LED_RED_PIN DT_GPIO_PIN(DT_ALIAS(red_led), gpios) +#define LED_RED_FLAGS DT_GPIO_FLAGS(DT_ALIAS(red_led), gpios) #endif -#ifdef DT_ALIAS_SW0_GPIOS_CONTROLLER -#define BUTTON_PORT DT_ALIAS_SW0_GPIOS_CONTROLLER -#define BUTTON_PIN DT_ALIAS_SW0_GPIOS_PIN -#define BUTTON_FLAGS DT_ALIAS_SW0_GPIOS_FLAGS +#if DT_NODE_HAS_PROP(DT_ALIAS(sw0), gpios) +#define BUTTON_PORT DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) +#define BUTTON_PIN DT_GPIO_PIN(DT_ALIAS(sw0), gpios) +#define BUTTON_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) static struct gpio_callback button_callback; #endif diff --git a/samples/subsys/usb/hid-cdc/src/main.c b/samples/subsys/usb/hid-cdc/src/main.c index 60e775ad36..995329b717 100644 --- a/samples/subsys/usb/hid-cdc/src/main.c +++ b/samples/subsys/usb/hid-cdc/src/main.c @@ -17,58 +17,58 @@ #define LOG_LEVEL LOG_LEVEL_DBG LOG_MODULE_REGISTER(main); -#ifdef DT_ALIAS_SW0_GPIOS_CONTROLLER -#define PORT0 DT_ALIAS_SW0_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw0), gpios) +#define PORT0 DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_CONTROLLER needs to be set +#error DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) needs to be set #endif -#ifdef DT_ALIAS_SW0_GPIOS_PIN -#define PIN0 DT_ALIAS_SW0_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, pin) +#define PIN0 DT_GPIO_PIN(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_PIN needs to be set +#error DT_GPIO_PIN(DT_ALIAS(sw0), gpios) needs to be set #endif -#ifdef DT_ALIAS_SW0_GPIOS_FLAGS -#define PIN0_FLAGS DT_ALIAS_SW0_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, flags) +#define PIN0_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_FLAGS needs to be set +#error DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) needs to be set #endif -#ifdef DT_ALIAS_SW1_GPIOS_PIN -#define PIN1 DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) +#define PIN1 DT_GPIO_PIN(DT_ALIAS(sw1), gpios) #endif -#ifdef DT_ALIAS_SW1_GPIOS_CONTROLLER -#define PORT1 DT_ALIAS_SW1_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw1), gpios) +#define PORT1 DT_GPIO_LABEL(DT_ALIAS(sw1), gpios) #endif -#ifdef DT_ALIAS_SW1_GPIOS_FLAGS -#define PIN1_FLAGS DT_ALIAS_SW1_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, flags) +#define PIN1_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw1), gpios) #endif -#ifdef DT_ALIAS_SW2_GPIOS_PIN -#define PIN2 DT_ALIAS_SW2_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, pin) +#define PIN2 DT_GPIO_PIN(DT_ALIAS(sw2), gpios) #endif -#ifdef DT_ALIAS_SW2_GPIOS_CONTROLLER -#define PORT2 DT_ALIAS_SW2_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw2), gpios) +#define PORT2 DT_GPIO_LABEL(DT_ALIAS(sw2), gpios) #endif -#ifdef DT_ALIAS_SW2_GPIOS_FLAGS -#define PIN2_FLAGS DT_ALIAS_SW2_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, flags) +#define PIN2_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw2), gpios) #endif -#ifdef DT_ALIAS_SW3_GPIOS_PIN -#define PIN3 DT_ALIAS_SW3_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, pin) +#define PIN3 DT_GPIO_PIN(DT_ALIAS(sw3), gpios) #endif -#ifdef DT_ALIAS_SW3_GPIOS_CONTROLLER -#define PORT3 DT_ALIAS_SW3_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw3), gpios) +#define PORT3 DT_GPIO_LABEL(DT_ALIAS(sw3), gpios) #endif -#ifdef DT_ALIAS_SW3_GPIOS_FLAGS -#define PIN3_FLAGS DT_ALIAS_SW3_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, flags) +#define PIN3_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw3), gpios) #endif /* Event FIFO */ @@ -501,7 +501,7 @@ static void btn0(struct device *gpio, struct gpio_callback *cb, u32_t pins) k_sem_give(&evt_sem); } -#ifdef DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) static void btn1(struct device *gpio, struct gpio_callback *cb, u32_t pins) { struct app_evt_t *ev = app_evt_alloc(); @@ -512,7 +512,7 @@ static void btn1(struct device *gpio, struct gpio_callback *cb, u32_t pins) } #endif -#ifdef DT_ALIAS_SW2_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, pin) static void btn2(struct device *gpio, struct gpio_callback *cb, u32_t pins) { struct app_evt_t *ev = app_evt_alloc(); @@ -523,7 +523,7 @@ static void btn2(struct device *gpio, struct gpio_callback *cb, u32_t pins) } #endif -#ifdef DT_ALIAS_SW3_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, pin) static void btn3(struct device *gpio, struct gpio_callback *cb, u32_t pins) { struct app_evt_t *ev = app_evt_alloc(); @@ -598,7 +598,7 @@ void main(void) return; } -#ifdef DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) if (callbacks_configure(device_get_binding(PORT1), PIN1, PIN1_FLAGS, &btn1, &callback[1])) { LOG_ERR("Failed configuring button 1 callback."); @@ -606,7 +606,7 @@ void main(void) } #endif -#ifdef DT_ALIAS_SW2_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, pin) if (callbacks_configure(device_get_binding(PORT2), PIN2, PIN2_FLAGS, &btn2, &callback[2])) { LOG_ERR("Failed configuring button 2 callback."); @@ -614,7 +614,7 @@ void main(void) } #endif -#ifdef DT_ALIAS_SW3_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, pin) if (callbacks_configure(device_get_binding(PORT3), PIN3, PIN3_FLAGS, &btn3, &callback[3])) { LOG_ERR("Failed configuring button 3 callback."); diff --git a/samples/subsys/usb/hid-mouse/README.rst b/samples/subsys/usb/hid-mouse/README.rst index 95394b2bd4..0dd2a1bff4 100644 --- a/samples/subsys/usb/hid-mouse/README.rst +++ b/samples/subsys/usb/hid-mouse/README.rst @@ -25,14 +25,14 @@ GPIO button in your board. To use this sample, you will require a board that defines the user switch in its header file. The :file:`board.h` must define the following variables: -- DT_ALIAS_SW0_GPIOS_CONTROLLER -- DT_ALIAS_SW0_GPIOS_PIN +- DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) +- DT_GPIO_PIN(DT_ALIAS(sw0), gpios) The following variables are optional and depend on available board buttons: -- For right-button: DT_ALIAS_SW1_GPIOS_CONTROLLER, DT_ALIAS_SW1_GPIOS_PIN -- For X-axis: DT_ALIAS_SW2_GPIOS_CONTROLLER, DT_ALIAS_SW2_GPIOS_PIN -- For Y-axis: DT_ALIAS_SW3_GPIOS_CONTROLLER, DT_ALIAS_SW3_GPIOS_PIN +- For right-button: DT_GPIO_LABEL(DT_ALIAS(sw1), gpios), DT_GPIO_PIN(DT_ALIAS(sw1), gpios) +- For X-axis: DT_GPIO_LABEL(DT_ALIAS(sw2), gpios), DT_GPIO_PIN(DT_ALIAS(sw2), gpios) +- For Y-axis: DT_GPIO_LABEL(DT_ALIAS(sw3), gpios), DT_GPIO_PIN(DT_ALIAS(sw3), gpios) Building and Running ******************** diff --git a/samples/subsys/usb/hid-mouse/src/main.c b/samples/subsys/usb/hid-mouse/src/main.c index 3aa7014f1c..281652faa9 100644 --- a/samples/subsys/usb/hid-mouse/src/main.c +++ b/samples/subsys/usb/hid-mouse/src/main.c @@ -15,68 +15,68 @@ LOG_MODULE_REGISTER(main); /* change this to use another GPIO port */ -#ifdef DT_ALIAS_SW0_GPIOS_CONTROLLER -#define PORT0 DT_ALIAS_SW0_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw0), gpios) +#define PORT0 DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_CONTROLLER needs to be set +#error DT_GPIO_LABEL(DT_ALIAS(sw0), gpios) needs to be set #endif /* change this to use another GPIO pin */ -#ifdef DT_ALIAS_SW0_GPIOS_PIN -#define PIN0 DT_ALIAS_SW0_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, pin) +#define PIN0 DT_GPIO_PIN(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_PIN needs to be set +#error DT_GPIO_PIN(DT_ALIAS(sw0), gpios) needs to be set #endif /* The switch pin pull-up/down flags */ -#ifdef DT_ALIAS_SW0_GPIOS_FLAGS -#define PIN0_FLAGS DT_ALIAS_SW0_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, flags) +#define PIN0_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) #else -#error DT_ALIAS_SW0_GPIOS_FLAGS needs to be set +#error DT_GPIO_FLAGS(DT_ALIAS(sw0), gpios) needs to be set #endif /* If second button exists, use it as right-click. */ -#ifdef DT_ALIAS_SW1_GPIOS_PIN -#define PIN1 DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) +#define PIN1 DT_GPIO_PIN(DT_ALIAS(sw1), gpios) #endif -#ifdef DT_ALIAS_SW1_GPIOS_CONTROLLER -#define PORT1 DT_ALIAS_SW1_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw1), gpios) +#define PORT1 DT_GPIO_LABEL(DT_ALIAS(sw1), gpios) #endif -#ifdef DT_ALIAS_SW1_GPIOS_FLAGS -#define PIN1_FLAGS DT_ALIAS_SW1_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, flags) +#define PIN1_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw1), gpios) #endif /* If third button exists, use it as X axis movement. */ -#ifdef DT_ALIAS_SW2_GPIOS_PIN -#define PIN2 DT_ALIAS_SW2_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, pin) +#define PIN2 DT_GPIO_PIN(DT_ALIAS(sw2), gpios) #endif -#ifdef DT_ALIAS_SW2_GPIOS_CONTROLLER -#define PORT2 DT_ALIAS_SW2_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw2), gpios) +#define PORT2 DT_GPIO_LABEL(DT_ALIAS(sw2), gpios) #endif -#ifdef DT_ALIAS_SW2_GPIOS_FLAGS -#define PIN2_FLAGS DT_ALIAS_SW2_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, flags) +#define PIN2_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw2), gpios) #endif /* If fourth button exists, use it as Y axis movement. */ -#ifdef DT_ALIAS_SW3_GPIOS_PIN -#define PIN3 DT_ALIAS_SW3_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, pin) +#define PIN3 DT_GPIO_PIN(DT_ALIAS(sw3), gpios) #endif -#ifdef DT_ALIAS_SW3_GPIOS_CONTROLLER -#define PORT3 DT_ALIAS_SW3_GPIOS_CONTROLLER +#if DT_NODE_HAS_PROP(DT_ALIAS(sw3), gpios) +#define PORT3 DT_GPIO_LABEL(DT_ALIAS(sw3), gpios) #endif -#ifdef DT_ALIAS_SW3_GPIOS_FLAGS -#define PIN3_FLAGS DT_ALIAS_SW3_GPIOS_FLAGS +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, flags) +#define PIN3_FLAGS DT_GPIO_FLAGS(DT_ALIAS(sw3), gpios) #endif -#define LED_PORT DT_ALIAS_LED0_GPIOS_CONTROLLER -#define LED DT_ALIAS_LED0_GPIOS_PIN -#define LED_FLAGS DT_ALIAS_LED0_GPIOS_FLAGS +#define LED_PORT DT_GPIO_LABEL(DT_ALIAS(led0), gpios) +#define LED DT_GPIO_PIN(DT_ALIAS(led0), gpios) +#define LED_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios) static const u8_t hid_report_desc[] = HID_MOUSE_REPORT_DESC(2); @@ -133,7 +133,7 @@ static void left_button(struct device *gpio, struct gpio_callback *cb, } } -#ifdef DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) static void right_button(struct device *gpio, struct gpio_callback *cb, u32_t pins) { @@ -167,7 +167,7 @@ static void right_button(struct device *gpio, struct gpio_callback *cb, } #endif -#ifdef DT_ALIAS_SW2_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, pin) static void x_move(struct device *gpio, struct gpio_callback *cb, u32_t pins) { int ret; @@ -191,7 +191,7 @@ static void x_move(struct device *gpio, struct gpio_callback *cb, u32_t pins) } #endif -#ifdef DT_ALIAS_SW3_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, pin) static void y_move(struct device *gpio, struct gpio_callback *cb, u32_t pins) { int ret; @@ -290,7 +290,7 @@ void main(void) return; } -#ifdef DT_ALIAS_SW1_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw1), gpios, pin) if (callbacks_configure(device_get_binding(PORT1), PIN1, PIN1_FLAGS, &right_button, &callback[1], &def_val[1])) { LOG_ERR("Failed configuring right button callback."); @@ -298,7 +298,7 @@ void main(void) } #endif -#ifdef DT_ALIAS_SW2_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw2), gpios, pin) if (callbacks_configure(device_get_binding(PORT2), PIN2, PIN2_FLAGS, &x_move, &callback[2], &def_val[2])) { LOG_ERR("Failed configuring X axis movement callback."); @@ -306,7 +306,7 @@ void main(void) } #endif -#ifdef DT_ALIAS_SW3_GPIOS_PIN +#if DT_PHA_HAS_CELL(DT_ALIAS(sw3), gpios, pin) if (callbacks_configure(device_get_binding(PORT3), PIN3, PIN3_FLAGS, &y_move, &callback[3], &def_val[3])) { LOG_ERR("Failed configuring Y axis movement callback.");