• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/03-Apr-2024-170153

src/03-Apr-2024-417326

CMakeLists.txtD03-Apr-2024191 95

README.rstD03-Apr-20242.5 KiB6045

prj.confD03-Apr-2024332 104

sample.yamlD03-Apr-2024517 2019

README.rst

1.. _nrfx_prs_sample:
2
3nrfx peripheral resource sharing example
4########################################
5
6Overview
7********
8
9This sample shows how to use in Zephyr nRF peripherals that share the same ID
10and base address. Such peripherals cannot be used simultaneously because they
11share certain hardware resources, but it is possible to switch between them and
12use one or the other alternately. Because of the current driver model in Zephyr
13and the lack of possibility to deinitialize a peripheral that is initialized by
14a driver at boot, such switching cannot be achieved with Zephyr APIs. Therefore,
15this sample uses the nrfx drivers directly for those peripheral instances that
16are to be switched (SPIM2 and UARTE2) while the standard Zephyr drivers are used
17for other instances of the same peripheral types (UARTE0 is used by the standard
18Zephyr console and SPIM1 is used for performing additional sample transfers).
19
20The sample uses two buttons:
21  - by pressing Button 1 user can request a transfer to be performed using the
22    currently initialized peripheral (SPIM2 or UARTE2)
23  - by pressing Button 2 user can switch between the two peripherals
24
25When no button is pressed, every 5 seconds a background transfer using SPIM1
26is performed.
27
28The sample outputs on the standard console the hex codes of all sent and
29received bytes, so when the proper loopback wiring is provided on the used
30board (between the MOSI and MISO pins for SPIMs and between the TX and RX pins
31for the UARTE), it can be checked that what is sent by a given peripheral
32is also received back. Without such wiring, no data is received by UARTE and
33all zeros are received by SPIMs. Refer to the overlay files provided in the
34:zephyr_file:`samples/boards/nrf/nrfx_prs/boards` directory to check which pins
35on the boards supported by the sample are assigned as MOSI/MISO and TX/RX pins.
36
37Requirements
38************
39
40This sample has been tested on the Nordic Semiconductor nRF9160 DK
41(nrf9160dk_nrf9160) and nRF5340 DK (nrf5340dk_nrf5340_cpuapp) boards.
42
43Building and Running
44********************
45
46The code can be found in :zephyr_file:`samples/boards/nrf/nrfx_prs`.
47
48To build and flash the application:
49
50.. zephyr-app-commands::
51   :zephyr-app: samples/boards/nrf/nrfx_prs
52   :board: nrf9160dk_nrf9160
53   :goals: build flash
54   :compact:
55
56Press Button 1 to trigger a sample transfer on SPIM2 or UARTE2.
57Press Button 2 to switch the type of peripheral to be used for the transfer.
58
59When no button is pressed, a background transfer on SPIM1 is performed.
60