zephyr/samples/boards/nrf/nrfx
Andrzej Głąbek 4212e95763 samples: boards: nrfx: Fix setting up of (D)PPI channel endpoints
There is a copy-paste error in this sample code that results
in a function for input events being called for an output pin.
By chance, this has no influence on the behavior of the sample,
as the function returns a register offset that for events and
tasks is the same for a given channel, but obviously the code
is confusing.
This is fixed by replacing the relevant part with more suitable
function calls, to also simplify the code a little.

On the occasion, also a remark is added about no button debouncing
used in the sample, to prevent users from being surprised by its
possible behavior.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-09-23 13:13:30 -04:00
..
src samples: boards: nrfx: Fix setting up of (D)PPI channel endpoints 2021-09-23 13:13:30 -04:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
Kconfig
README.rst samples: boards: nrfx: Fix setting up of (D)PPI channel endpoints 2021-09-23 13:13:30 -04:00
prj.conf
sample.yaml samples: tests: Fix sample.boards.nrf.nrfx test 2021-02-11 13:58:25 -05:00

README.rst

.. _nrfx_sample:

nrfx use example
################

Overview
********

This sample demonstrates the usage of nrfx library in Zephyr.
GPIOTE and DPPI/PPI are used as examples of nrfx drivers.

The code shows how to initialize the GPIOTE interrupt in Zephyr
so that the nrfx_gpiote driver can use it. Additionally, it shows
how the DPPI/PPI subsystem can be used to connect tasks and events of
nRF peripherals, enabling those peripherals to interact with each
other without any intervention from the CPU.

Zephyr GPIO driver is disabled to prevent it from registering its own handler
for the GPIOTE interrupt. Button 1 is configured to create an event when pushed.
This calls the ``button_handler()`` callback and triggers the LED 1 pin OUT task.
LED is then toggled.

Please note that no debouncing mechanism is used for the button, so it may
happen that one press results in multiple events. And because the event-task
connection is handled in hardware, for very fast coming events, toggling of
the LED may sometimes be even unnoticeable.

Requirements
************

This sample has been tested on the NordicSemiconductor nRF9160 DK
(nrf9160dk_nrf9160) and nRF52840 DK (nrf52840dk_nrf52840) boards.

Building and Running
********************

The code can be found in :zephyr_file:`samples/boards/nrf/nrfx`.

To build and flash the application:

.. zephyr-app-commands::
   :zephyr-app: samples/boards/nrf/nrfx
   :board: nrf9160dk_nrf9160
   :goals: build flash
   :compact:

Push Button 1 to toggle the LED 1.

Connect to the serial port - notice that each time the button is pressed,
the ``button_handler()`` function is called.

See nrfx_repository_ for more information about nrfx.

.. _nrfx_repository: https://github.com/NordicSemiconductor/nrfx