zephyr/samples/basic/button
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
..
src license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
Makefile samples: tests: remove obsolete KERNEL_TYPE and kernel variables 2016-11-04 15:47:25 -04:00
README.rst boards: add quark_d2000_crb documentation 2017-01-10 02:45:55 +00:00
prj.conf
testcase.ini

README.rst

Button demo
###########

Overview
========

A simple button demo showcasing the use of GPIO input with interrupts.

Requirements
============

The demo assumes that a push button is connected to one of GPIO lines. The
sample code is configured to work on boards with user defined buttons and that
have defined the SW0_* variable in board.h

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
- SW0_GPIO_PIN

The following boards currently define the above variables:

- bbc_microbit
- cc3200_launchxl
- frdm_k64f
- nrf51_pca10028
- nrf52840_pca10056
- nrf52_pca10040
- nucleo_f103rb
- :ref:`quark_d2000_devboard`
- quark_se_c1000_devboard
- quark_se_c1000_ss_devboard


Building and Running
====================

This sample can be built for multiple boards, in this example we will build it
for the nucleo_f103rb board:

.. code-block:: console

   $ cd samples/basic/button
   $ make BOARD=nucleo_f103rb


After startup, the program looks up a predefined GPIO device, and configures the
pin in input mode, enabling interrupt generation on falling edge. During each
iteration of the main loop, the state of GPIO line is monitored and printed to
the serial console. When the input button gets pressed, the interrupt handler
will print an information about this event along with its timestamp.