Skip to content
Permalink
Browse files

dts: Rename LED._GPIO_* -> DT_ALIAS_LED._GPIOS_*

We use the following commands to rename any
LED._GPIO_{CONTROLLER,PIN,FLAGS} to
DT_ALIAS_LED._GPIOS_{CONTROLLER,PIN,FLAGS}

git grep -l LED._GPIO_CONTROLLER | xargs sed -i 's/LED\(.\)_GPIO_CONTROLLER/DT_ALIAS_LED\1_GPIOS_CONTROLLER/g'
git grep -l LED._GPIO_PIN | xargs sed -i 's/LED\(.\)_GPIO_PIN/DT_ALIAS_LED\1_GPIOS_PIN/g'
git grep -l LED._GPIO_FLAGS | xargs sed -i 's/LED\(.\)_GPIO_FLAGS/DT_ALIAS_LED\1_GPIOS_FLAGS/g'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
  • Loading branch information...
galak authored and nashif committed Jun 22, 2019
1 parent c661cc6 commit db167c606d14f1dacf25dd368b74bc040f61e742
@@ -32,7 +32,7 @@
#else
#define PWM_DRIVER DT_NORDIC_NRF_PWM_PWM_0_LABEL
#endif /* CONFIG_PWM_NRF5_SW */
#define PWM_CHANNEL LED0_GPIO_PIN
#define PWM_CHANNEL DT_ALIAS_LED0_GPIOS_PIN
#elif defined(CONFIG_BOARD_COLIBRI_IMX7D_M4)
#define PWM_DRIVER PWM_1_LABEL
#define PWM_CHANNEL 0
@@ -18,8 +18,8 @@ sample code is configured to work on boards that have defined the led0
alias in their board device tree description file. Doing so will generate
these variables:

- LED0_GPIO_CONTROLLER
- LED0_GPIO_PIN
- DT_ALIAS_LED0_GPIOS_CONTROLLER
- DT_ALIAS_LED0_GPIOS_PIN


Building and Running
@@ -8,8 +8,8 @@
#include <device.h>
#include <drivers/gpio.h>

#define LED_PORT LED0_GPIO_CONTROLLER
#define LED LED0_GPIO_PIN
#define LED_PORT DT_ALIAS_LED0_GPIOS_CONTROLLER
#define LED DT_ALIAS_LED0_GPIOS_PIN

/* 1000 msec = 1 sec */
#define SLEEP_TIME 1000
@@ -2,7 +2,7 @@ sample:
name: Disco Lights
tests:
sample.disco:
filter: DT_GPIO_LEDS_LED0_GPIO_CONTROLLER and DT_GPIO_LEDS_LED1_GPIOS_CONTROLLER
filter: DT_GPIO_LEDS_LED0_GPIOS_CONTROLLER and DT_GPIO_LEDS_LED1_GPIOS_CONTROLLER
tags: LED gpio
depends_on: gpio
harness: led
@@ -8,11 +8,11 @@
#include <device.h>
#include <drivers/gpio.h>

#define PORT0 LED0_GPIO_CONTROLLER
#define PORT1 LED1_GPIO_CONTROLLER
#define PORT0 DT_ALIAS_LED0_GPIOS_CONTROLLER
#define PORT1 DT_ALIAS_LED1_GPIOS_CONTROLLER

#define LED0 LED0_GPIO_PIN
#define LED1 LED1_GPIO_PIN
#define LED0 DT_ALIAS_LED0_GPIOS_PIN
#define LED1 DT_ALIAS_LED1_GPIOS_PIN

#define SLEEP_TIME 500

@@ -30,7 +30,7 @@
#else
#define PWM_DRIVER DT_NORDIC_NRF_PWM_PWM_0_LABEL
#endif /* CONFIG_PWM_NRF5_SW */
#define PWM_CHANNEL LED0_GPIO_PIN
#define PWM_CHANNEL DT_ALIAS_LED0_GPIOS_PIN
#elif defined(CONFIG_SOC_ESP32)
#define PWM_DRIVER CONFIG_PWM_LED_ESP32_DEV_NAME_0
#define PWM_CHANNEL 21
@@ -5,7 +5,7 @@ sample:
tests:
sample.threads:
tags: kernel threads gpio
filter: DT_GPIO_LEDS_LED0_GPIO_CONTROLLER and DT_GPIO_LEDS_LED1_GPIOS_CONTROLLER
filter: DT_GPIO_LEDS_LED0_GPIOS_CONTROLLER and DT_GPIO_LEDS_LED1_GPIOS_CONTROLLER
depends_on: gpio
harness: console
harness_config:
@@ -18,20 +18,20 @@
#define PRIORITY 7

/* Change this if you have an LED connected to a custom port */
#ifndef LED0_GPIO_CONTROLLER
#define LED0_GPIO_CONTROLLER LED0_GPIO_PORT
#ifndef DT_ALIAS_LED0_GPIOS_CONTROLLER
#define DT_ALIAS_LED0_GPIOS_CONTROLLER LED0_GPIO_PORT
#endif
#ifndef LED1_GPIO_CONTROLLER
#define LED1_GPIO_CONTROLLER LED1_GPIO_PORT
#ifndef DT_ALIAS_LED1_GPIOS_CONTROLLER
#define DT_ALIAS_LED1_GPIOS_CONTROLLER LED1_GPIO_PORT
#endif

#define PORT0 LED0_GPIO_CONTROLLER
#define PORT1 LED1_GPIO_CONTROLLER
#define PORT0 DT_ALIAS_LED0_GPIOS_CONTROLLER
#define PORT1 DT_ALIAS_LED1_GPIOS_CONTROLLER


/* Change this if you have an LED connected to a custom pin */
#define LED0 LED0_GPIO_PIN
#define LED1 LED1_GPIO_PIN
#define LED0 DT_ALIAS_LED0_GPIOS_PIN
#define LED1 DT_ALIAS_LED1_GPIOS_PIN

struct printk_data_t {
void *fifo_reserved; /* 1st word reserved for use by fifo */
@@ -50,39 +50,39 @@ void signal_sampling_started(void)
{
static struct device *led0, *led1;

led0 = device_get_binding(LED0_GPIO_CONTROLLER);
gpio_pin_configure(led0, LED0_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, LED0_GPIO_PIN, 1);
led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER);
gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, DT_ALIAS_LED0_GPIOS_PIN, 1);

led1 = device_get_binding(LED1_GPIO_CONTROLLER);
gpio_pin_configure(led1, LED1_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_write(led1, LED1_GPIO_PIN, 0);
led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER);
gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, GPIO_DIR_OUT);
gpio_pin_write(led1, DT_ALIAS_LED1_GPIOS_PIN, 0);
}

void signal_sampling_stopped(void)
{
static struct device *led0, *led1;

led0 = device_get_binding(LED0_GPIO_CONTROLLER);
gpio_pin_configure(led0, LED0_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, LED0_GPIO_PIN, 1);
led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER);
gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, DT_ALIAS_LED0_GPIOS_PIN, 1);

led1 = device_get_binding(LED1_GPIO_CONTROLLER);
gpio_pin_configure(led1, LED1_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_write(led1, LED1_GPIO_PIN, 1);
led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER);
gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, GPIO_DIR_OUT);
gpio_pin_write(led1, DT_ALIAS_LED1_GPIOS_PIN, 1);
}

void signal_print_stopped(void)
{
static struct device *led0, *led1;

led0 = device_get_binding(LED0_GPIO_CONTROLLER);
gpio_pin_configure(led0, LED0_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, LED0_GPIO_PIN, 0);
led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER);
gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, DT_ALIAS_LED0_GPIOS_PIN, 0);

led1 = device_get_binding(LED1_GPIO_CONTROLLER);
gpio_pin_configure(led1, LED1_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_write(led1, LED1_GPIO_PIN, 1);
led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER);
gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, GPIO_DIR_OUT);
gpio_pin_write(led1, DT_ALIAS_LED1_GPIOS_PIN, 1);
}

void *rx_block[NUM_MS];
@@ -133,15 +133,15 @@ void main(void)
}
#endif

led0 = device_get_binding(LED0_GPIO_CONTROLLER);
gpio_pin_configure(led0, LED0_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, LED0_GPIO_PIN, 1);
led0 = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER);
gpio_pin_configure(led0, DT_ALIAS_LED0_GPIOS_PIN, GPIO_DIR_OUT);
gpio_pin_write(led0, DT_ALIAS_LED0_GPIOS_PIN, 1);

led1 = device_get_binding(LED1_GPIO_CONTROLLER);
gpio_pin_configure(led1, LED1_GPIO_PIN, GPIO_DIR_OUT);
led1 = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER);
gpio_pin_configure(led1, DT_ALIAS_LED1_GPIOS_PIN, GPIO_DIR_OUT);

for (i = 0; i < 5; i++) {
gpio_pin_write(led1, LED1_GPIO_PIN, on);
gpio_pin_write(led1, DT_ALIAS_LED1_GPIOS_PIN, on);
k_sleep(200);
on = (on == 1) ? 0 : 1;
}
@@ -180,10 +180,10 @@ struct onoff_state {
*/

static struct onoff_state onoff_state[] = {
{ .led_gpio_pin = LED0_GPIO_PIN },
{ .led_gpio_pin = LED1_GPIO_PIN },
{ .led_gpio_pin = LED2_GPIO_PIN },
{ .led_gpio_pin = LED3_GPIO_PIN },
{ .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 },
};

/*
@@ -635,10 +635,10 @@ void main(void)
gpio_pin_enable_callback(sw_device, DT_ALIAS_SW3_GPIOS_PIN);

/* Initialize LED's */
init_led(0, LED0_GPIO_CONTROLLER, LED0_GPIO_PIN);
init_led(1, LED1_GPIO_CONTROLLER, LED1_GPIO_PIN);
init_led(2, LED2_GPIO_CONTROLLER, LED2_GPIO_PIN);
init_led(3, LED3_GPIO_CONTROLLER, LED3_GPIO_PIN);
init_led(0, DT_ALIAS_LED0_GPIOS_CONTROLLER, DT_ALIAS_LED0_GPIOS_PIN);
init_led(1, DT_ALIAS_LED1_GPIOS_CONTROLLER, DT_ALIAS_LED1_GPIOS_PIN);
init_led(2, DT_ALIAS_LED2_GPIOS_CONTROLLER, DT_ALIAS_LED2_GPIOS_PIN);
init_led(3, DT_ALIAS_LED3_GPIOS_CONTROLLER, DT_ALIAS_LED3_GPIOS_PIN);

/* Initialize the Bluetooth Subsystem */
err = bt_enable(bt_ready);
@@ -26,25 +26,25 @@ void app_gpio_init(void)

/* LEDs configuration & setting */

led_device[0] = device_get_binding(LED0_GPIO_CONTROLLER);
gpio_pin_configure(led_device[0], LED0_GPIO_PIN,
led_device[0] = device_get_binding(DT_ALIAS_LED0_GPIOS_CONTROLLER);
gpio_pin_configure(led_device[0], DT_ALIAS_LED0_GPIOS_PIN,
GPIO_DIR_OUT | GPIO_PUD_PULL_UP);
gpio_pin_write(led_device[0], LED0_GPIO_PIN, 1);
gpio_pin_write(led_device[0], DT_ALIAS_LED0_GPIOS_PIN, 1);

led_device[1] = device_get_binding(LED1_GPIO_CONTROLLER);
gpio_pin_configure(led_device[1], LED1_GPIO_PIN,
led_device[1] = device_get_binding(DT_ALIAS_LED1_GPIOS_CONTROLLER);
gpio_pin_configure(led_device[1], DT_ALIAS_LED1_GPIOS_PIN,
GPIO_DIR_OUT | GPIO_PUD_PULL_UP);
gpio_pin_write(led_device[1], LED1_GPIO_PIN, 1);
gpio_pin_write(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, 1);

led_device[2] = device_get_binding(LED2_GPIO_CONTROLLER);
gpio_pin_configure(led_device[2], LED2_GPIO_PIN,
led_device[2] = device_get_binding(DT_ALIAS_LED2_GPIOS_CONTROLLER);
gpio_pin_configure(led_device[2], DT_ALIAS_LED2_GPIOS_PIN,
GPIO_DIR_OUT | GPIO_PUD_PULL_UP);
gpio_pin_write(led_device[2], LED2_GPIO_PIN, 1);
gpio_pin_write(led_device[2], DT_ALIAS_LED2_GPIOS_PIN, 1);

led_device[3] = device_get_binding(LED3_GPIO_CONTROLLER);
gpio_pin_configure(led_device[3], LED3_GPIO_PIN,
led_device[3] = device_get_binding(DT_ALIAS_LED3_GPIOS_CONTROLLER);
gpio_pin_configure(led_device[3], DT_ALIAS_LED3_GPIOS_PIN,
GPIO_DIR_OUT | GPIO_PUD_PULL_UP);
gpio_pin_write(led_device[3], LED3_GPIO_PIN, 1);
gpio_pin_write(led_device[3], DT_ALIAS_LED3_GPIOS_PIN, 1);

/* Buttons configuration & setting */

@@ -124,26 +124,26 @@ void update_led_gpio(void)

if (lightness) {
/* LED1 On */
gpio_pin_write(led_device[0], LED0_GPIO_PIN, 0);
gpio_pin_write(led_device[0], DT_ALIAS_LED0_GPIOS_PIN, 0);
} else {
/* LED1 Off */
gpio_pin_write(led_device[0], LED0_GPIO_PIN, 1);
gpio_pin_write(led_device[0], DT_ALIAS_LED0_GPIOS_PIN, 1);
}

if (power < 50) {
/* LED3 On */
gpio_pin_write(led_device[2], LED2_GPIO_PIN, 0);
gpio_pin_write(led_device[2], DT_ALIAS_LED2_GPIOS_PIN, 0);
} else {
/* LED3 Off */
gpio_pin_write(led_device[2], LED2_GPIO_PIN, 1);
gpio_pin_write(led_device[2], DT_ALIAS_LED2_GPIOS_PIN, 1);
}

if (color < 50) {
/* LED4 On */
gpio_pin_write(led_device[3], LED3_GPIO_PIN, 0);
gpio_pin_write(led_device[3], DT_ALIAS_LED3_GPIOS_PIN, 0);
} else {
/* LED4 Off */
gpio_pin_write(led_device[3], LED3_GPIO_PIN, 1);
gpio_pin_write(led_device[3], DT_ALIAS_LED3_GPIOS_PIN, 1);
}
}

@@ -1144,10 +1144,10 @@ static void vnd_set_unack(struct bt_mesh_model *model,

if (state->current == STATE_ON) {
/* LED2 On */
gpio_pin_write(led_device[1], LED1_GPIO_PIN, 0);
gpio_pin_write(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, 0);
} else {
/* LED2 Off */
gpio_pin_write(led_device[1], LED1_GPIO_PIN, 1);
gpio_pin_write(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, 1);
}
}

@@ -18,8 +18,8 @@
#define PORT DT_ALIAS_SW0_GPIOS_CONTROLLER
#define BUTTON_1 DT_ALIAS_SW0_GPIOS_PIN
#define BUTTON_2 DT_ALIAS_SW1_GPIOS_PIN
#define LED_1 LED0_GPIO_PIN
#define LED_2 LED1_GPIO_PIN
#define LED_1 DT_ALIAS_LED0_GPIOS_PIN
#define LED_2 DT_ALIAS_LED1_GPIOS_PIN

#define LOW 0
#define HIGH 1
@@ -24,10 +24,10 @@ struct led_device_info {
};

static struct led_device_info led_dev_info[] = {
{ NULL, LED0_GPIO_CONTROLLER, LED0_GPIO_PIN }, /* green back LED */
{ NULL, LED1_GPIO_CONTROLLER, LED1_GPIO_PIN }, /* red front LED */
{ NULL, LED2_GPIO_CONTROLLER, LED2_GPIO_PIN }, /* green front LED */
{ NULL, LED3_GPIO_CONTROLLER, LED3_GPIO_PIN }, /* blue front LED */
{ NULL, DT_ALIAS_LED0_GPIOS_CONTROLLER, DT_ALIAS_LED0_GPIOS_PIN }, /* green back LED */
{ NULL, DT_ALIAS_LED1_GPIOS_CONTROLLER, DT_ALIAS_LED1_GPIOS_PIN }, /* red front LED */
{ NULL, DT_ALIAS_LED2_GPIOS_CONTROLLER, DT_ALIAS_LED2_GPIOS_PIN }, /* green front LED */
{ NULL, DT_ALIAS_LED3_GPIOS_CONTROLLER, DT_ALIAS_LED3_GPIOS_PIN }, /* blue front LED */
};

static struct device_info dev_info[] = {
@@ -68,10 +68,10 @@ static struct {
const char *name;
u32_t pin;
} leds[] = {
{ .name = LED0_GPIO_CONTROLLER, .pin = LED0_GPIO_PIN, },
{ .name = LED1_GPIO_CONTROLLER, .pin = LED1_GPIO_PIN, },
{ .name = LED2_GPIO_CONTROLLER, .pin = LED2_GPIO_PIN, },
{ .name = LED3_GPIO_CONTROLLER, .pin = LED3_GPIO_PIN, },
{ .name = DT_ALIAS_LED0_GPIOS_CONTROLLER, .pin = DT_ALIAS_LED0_GPIOS_PIN, },
{ .name = DT_ALIAS_LED1_GPIOS_CONTROLLER, .pin = DT_ALIAS_LED1_GPIOS_PIN, },
{ .name = DT_ALIAS_LED2_GPIOS_CONTROLLER, .pin = DT_ALIAS_LED2_GPIOS_PIN, },
{ .name = DT_ALIAS_LED3_GPIOS_CONTROLLER, .pin = DT_ALIAS_LED3_GPIOS_PIN, },
};

struct k_delayed_work led_timer;
@@ -3,7 +3,7 @@ sample:
tests:
sample.driver.gpio:
tags: drivers
filter: DT_GPIO_LEDS_LED0_GPIO_CONTROLLER and DT_GPIO_KEYS_SW0_GPIOS_CONTROLLER
filter: DT_GPIO_LEDS_LED0_GPIOS_CONTROLLER and DT_GPIO_KEYS_SW0_GPIOS_CONTROLLER
harness: console
harness_config:
type: one_line
@@ -20,9 +20,9 @@
#include <drivers/gpio.h>
#include <sys/util.h>

#if defined(DT_ALIAS_SW0_GPIOS_CONTROLLER) && defined(LED0_GPIO_CONTROLLER)
#define GPIO_OUT_DRV_NAME LED0_GPIO_CONTROLLER
#define GPIO_OUT_PIN LED0_GPIO_PIN
#if defined(DT_ALIAS_SW0_GPIOS_CONTROLLER) && defined(DT_ALIAS_LED0_GPIOS_CONTROLLER)
#define GPIO_OUT_DRV_NAME DT_ALIAS_LED0_GPIOS_CONTROLLER
#define GPIO_OUT_PIN DT_ALIAS_LED0_GPIOS_PIN
#define GPIO_IN_DRV_NAME DT_ALIAS_SW0_GPIOS_CONTROLLER
#define GPIO_INT_PIN DT_ALIAS_SW0_GPIOS_PIN
#else
@@ -48,17 +48,17 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);

#define ENDPOINT_LEN 32

#ifndef LED0_GPIO_CONTROLLER
#ifndef DT_ALIAS_LED0_GPIOS_CONTROLLER
#ifdef LED0_GPIO_PORT
#define LED0_GPIO_CONTROLLER LED0_GPIO_PORT
#define DT_ALIAS_LED0_GPIOS_CONTROLLER LED0_GPIO_PORT
#else
#define LED0_GPIO_CONTROLLER "(fail)"
#define LED0_GPIO_PIN 0
#define DT_ALIAS_LED0_GPIOS_CONTROLLER "(fail)"
#define DT_ALIAS_LED0_GPIOS_PIN 0
#endif
#endif

#define LED_GPIO_PORT LED0_GPIO_CONTROLLER
#define LED_GPIO_PIN LED0_GPIO_PIN
#define LED_GPIO_PORT DT_ALIAS_LED0_GPIOS_CONTROLLER
#define LED_GPIO_PIN DT_ALIAS_LED0_GPIOS_PIN

static int pwrsrc_bat;
static int pwrsrc_usb;

0 comments on commit db167c6

Please sign in to comment.
You can’t perform that action at this time.