From c64fbbd1bde2f1db0ab88b49dfe502eb91349421 Mon Sep 17 00:00:00 2001 From: Piotr Mienkowski Date: Tue, 3 Dec 2019 01:57:29 +0100 Subject: [PATCH] samples: gpio: remove redundant application The functionality of samples/drivers/gpio sample application duplicates already existing code in samples/basic/blinky and samples/basic/button. This commit removes the gpio sample application. Signed-off-by: Piotr Mienkowski --- samples/drivers/gpio/CMakeLists.txt | 8 -- samples/drivers/gpio/prj.conf | 1 - samples/drivers/gpio/sample.yaml | 13 ---- samples/drivers/gpio/src/main.c | 109 ---------------------------- 4 files changed, 131 deletions(-) delete mode 100644 samples/drivers/gpio/CMakeLists.txt delete mode 100644 samples/drivers/gpio/prj.conf delete mode 100644 samples/drivers/gpio/sample.yaml delete mode 100644 samples/drivers/gpio/src/main.c diff --git a/samples/drivers/gpio/CMakeLists.txt b/samples/drivers/gpio/CMakeLists.txt deleted file mode 100644 index 9a291db2f6e66..0000000000000 --- a/samples/drivers/gpio/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) -project(gpio) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/drivers/gpio/prj.conf b/samples/drivers/gpio/prj.conf deleted file mode 100644 index 91c3c15b37d1e..0000000000000 --- a/samples/drivers/gpio/prj.conf +++ /dev/null @@ -1 +0,0 @@ -CONFIG_GPIO=y diff --git a/samples/drivers/gpio/sample.yaml b/samples/drivers/gpio/sample.yaml deleted file mode 100644 index 815b4fdf307cc..0000000000000 --- a/samples/drivers/gpio/sample.yaml +++ /dev/null @@ -1,13 +0,0 @@ -sample: - name: GPIO toggling -tests: - sample.driver.gpio: - tags: drivers - filter: dt_compat_enabled_with_alias("gpio-leds", "led0") and - dt_compat_enabled_with_alias("gpio-keys", "sw0") - harness: console - harness_config: - type: one_line - regex: - - "Toggling (.*)" - depends_on: gpio diff --git a/samples/drivers/gpio/src/main.c b/samples/drivers/gpio/src/main.c deleted file mode 100644 index e9b887da6a621..0000000000000 --- a/samples/drivers/gpio/src/main.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @file - * @brief GPIO driver sample - * - * This sample toggles LED1 and waits for an interrupt on BUTTON1. - * Note that an internal pull-up is set on BUTTON1 as the button - * only drives low when pressed. - */ -#include - -#include - -#include -#include -#include - -#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 -#error Change the pins based on your configuration. This sample \ - defaults to built-in buttons and LEDs -#endif - -void gpio_callback(struct device *port, - struct gpio_callback *cb, u32_t pins) -{ - printk("Pin %d triggered\n", GPIO_INT_PIN); -} - -static struct gpio_callback gpio_cb; - -void main(void) -{ - struct device *gpio_out_dev, *gpio_in_dev; - int ret; - int toggle = 1; - - gpio_out_dev = device_get_binding(GPIO_OUT_DRV_NAME); - if (!gpio_out_dev) { - printk("Cannot find %s!\n", GPIO_OUT_DRV_NAME); - return; - } - - gpio_in_dev = device_get_binding(GPIO_IN_DRV_NAME); - if (!gpio_in_dev) { - printk("Cannot find %s!\n", GPIO_IN_DRV_NAME); - return; - } - - /* Setup GPIO output */ - ret = gpio_pin_configure(gpio_out_dev, GPIO_OUT_PIN, (GPIO_DIR_OUT)); - if (ret) { - printk("Error configuring pin %d!\n", GPIO_OUT_PIN); - } - - /* Setup GPIO input, and triggers on rising edge. */ -#ifdef CONFIG_SOC_CC2650 - ret = gpio_pin_configure(gpio_in_dev, GPIO_INT_PIN, - (GPIO_DIR_IN | GPIO_INT | - GPIO_INT_EDGE | GPIO_INT_ACTIVE_HIGH | - GPIO_INT_DEBOUNCE | GPIO_PUD_PULL_UP)); -#else - ret = gpio_pin_configure(gpio_in_dev, GPIO_INT_PIN, - (GPIO_DIR_IN | GPIO_INT | - GPIO_INT_EDGE | GPIO_INT_ACTIVE_HIGH | - GPIO_INT_DEBOUNCE)); -#endif - if (ret) { - printk("Error configuring pin %d!\n", GPIO_INT_PIN); - } - - gpio_init_callback(&gpio_cb, gpio_callback, BIT(GPIO_INT_PIN)); - - ret = gpio_add_callback(gpio_in_dev, &gpio_cb); - if (ret) { - printk("Cannot setup callback!\n"); - } - - ret = gpio_pin_enable_callback(gpio_in_dev, GPIO_INT_PIN); - if (ret) { - printk("Error enabling callback!\n"); - } - - while (1) { - printk("Toggling pin %d\n", GPIO_OUT_PIN); - - ret = gpio_pin_write(gpio_out_dev, GPIO_OUT_PIN, toggle); - if (ret) { - printk("Error set pin %d!\n", GPIO_OUT_PIN); - } - - if (toggle) { - toggle = 0; - } else { - toggle = 1; - } - - k_sleep(K_SECONDS(2)); - } -}