mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
Using find_package to locate Zephyr.
Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.
Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.
It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
.. _button-sample: 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_* 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 Alternatively, this could also be done by defining 'sw0' alias in the board devicetree description file. Building and Running ******************** This sample can be built for multiple boards, in this example we will build it for the nucleo_f103rb board: .. zephyr-app-commands:: :zephyr-app: samples/basic/button :board: nucleo_f103rb :goals: build :compact: 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.