diff options
author | Anas Nashif <anas.nashif@intel.com> | 2016-10-01 23:28:54 -0400 |
---|---|---|
committer | Anas Nashif <nashif@linux.intel.com> | 2016-10-27 20:56:13 +0000 |
commit | febe9f5571271afa67d3c99112a8647a41b0da83 (patch) | |
tree | 8cddbd5a792c5ddf6631fa32d7353541e24f0196 /samples | |
parent | 513c1c91fc1c112d9948bcc8dce21ba8f6a947c5 (diff) |
samples: add basic blinky application
The mandatory blinky sample at your service.
Change-Id: I999215fbda338effd6f7b65a2a165acf9b850a9a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/basic/blinky/Makefile | 5 | ||||
-rw-r--r-- | samples/basic/blinky/README.rst | 9 | ||||
-rw-r--r-- | samples/basic/blinky/prj.conf | 3 | ||||
-rw-r--r-- | samples/basic/blinky/src/Makefile | 1 | ||||
-rw-r--r-- | samples/basic/blinky/src/main.c | 43 |
5 files changed, 61 insertions, 0 deletions
diff --git a/samples/basic/blinky/Makefile b/samples/basic/blinky/Makefile new file mode 100644 index 000000000..6377eb866 --- /dev/null +++ b/samples/basic/blinky/Makefile @@ -0,0 +1,5 @@ +KERNEL_TYPE = nano +BOARD ?= quark_d2000_crb +CONF_FILE = prj.conf + +include ${ZEPHYR_BASE}/Makefile.inc diff --git a/samples/basic/blinky/README.rst b/samples/basic/blinky/README.rst new file mode 100644 index 000000000..040715116 --- /dev/null +++ b/samples/basic/blinky/README.rst @@ -0,0 +1,9 @@ +Blinky Application +################## + +Overview +======== + +The Blinky example shows how to configure GPIO pins as outputs which can also be +used to drive LEDs on the hardware usually delivered as "User LEDs" on many of +the supported boards in Zephyr. diff --git a/samples/basic/blinky/prj.conf b/samples/basic/blinky/prj.conf new file mode 100644 index 000000000..21db6cbcd --- /dev/null +++ b/samples/basic/blinky/prj.conf @@ -0,0 +1,3 @@ +CONFIG_GPIO=y +CONFIG_NANO_TIMEOUTS=y +CONFIG_SERIAL=n diff --git a/samples/basic/blinky/src/Makefile b/samples/basic/blinky/src/Makefile new file mode 100644 index 000000000..00066e156 --- /dev/null +++ b/samples/basic/blinky/src/Makefile @@ -0,0 +1 @@ +obj-y = main.o diff --git a/samples/basic/blinky/src/main.c b/samples/basic/blinky/src/main.c new file mode 100644 index 000000000..a0fbb0e43 --- /dev/null +++ b/samples/basic/blinky/src/main.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <zephyr.h> +#include <board.h> +#include <device.h> +#include <gpio.h> + +/* Change this if you have an LED connected to a custom port */ +#define PORT LED0_GPIO_PORT + +/* Change this if you have an LED connected to a custom pin */ +#define LED LED0_GPIO_PIN + +void main(void) +{ + int cnt = 0; + struct device *dev; + + dev = device_get_binding(PORT); + /* Set LED pin as output */ + gpio_pin_configure(dev, LED, GPIO_DIR_OUT); + + while (1) { + /* Set pin to HIGH/LOW every 1 second */ + gpio_pin_write(dev, LED, cnt % 2); + cnt++; + task_sleep(SECONDS(1)); + } +} |