Part 1
요약·해설
Button 전환, SPIM1 background transfer와 loopback wiring을 설명합니다.
SPIM2 · UARTE2
SPIM1 · 5 s
MOSI/MISO · TX/RX
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
EC2EAE0C3277F3103EF627890EB272CE40FDF85D1370A7AFDAD07CD5ABCAA67C
.. _nrfx_prs_sample:
nrfx peripheral resource sharing example
########################################
Overview
********
This sample shows how to use in Zephyr nRF peripherals that share the same ID
and base address. Such peripherals cannot be used simultaneously because they
share certain hardware resources, but it is possible to switch between them and
use one or the other alternately. Because of the current driver model in Zephyr
and the lack of possibility to deinitialize a peripheral that is initialized by
a driver at boot, such switching cannot be achieved with Zephyr APIs. Therefore,
this sample uses the nrfx drivers directly for those peripheral instances that
are to be switched (SPIM2 and UARTE2) while the standard Zephyr drivers are used
for other instances of the same peripheral types (UARTE0 is used by the standard
Zephyr console and SPIM1 is used for performing additional sample transfers).
The sample uses two buttons:
- by pressing Button 1 user can request a transfer to be performed using the
currently initialized peripheral (SPIM2 or UARTE2)
- by pressing Button 2 user can switch between the two peripherals
When no button is pressed, every 5 seconds a background transfer using SPIM1
is performed.
The sample outputs on the standard console the hex codes of all sent and
received bytes, so when the proper loopback wiring is provided on the used
board (between the MOSI and MISO pins for SPIMs and between the TX and RX pins
for the UARTE), it can be checked that what is sent by a given peripheral
is also received back. Without such wiring, no data is received by UARTE and
all zeros are received by SPIMs. Refer to the overlay files provided in the
:zephyr_file:`samples/boards/nrf/nrfx_prs/boards` directory to check which pins
on the boards supported by the sample are assigned as MOSI/MISO and TX/RX pins.
Requirements
************
This sample has been tested on the Nordic Semiconductor nRF9160 DK
(nrf9160dk/nrf9160) and nRF5340 DK (nrf5340dk/nrf5340/cpuapp) boards.
Building and Running
********************
The code can be found in :zephyr_file:`samples/boards/nrf/nrfx_prs`.
To build and flash the application:
.. zephyr-app-commands::
:zephyr-app: samples/boards/nrf/nrfx_prs
:board: nrf9160dk/nrf9160
:goals: build flash
:compact:
Press Button 1 to trigger a sample transfer on SPIM2 or UARTE2.
Press Button 2 to switch the type of peripheral to be used for the transfer.
When no button is pressed, a background transfer on SPIM1 is performed.
Part 3
한국어 전문 번역
개요
Zephyr에서 같은 ID와 base address를 공유하는 nRF peripheral을 사용하는 방법을 보여주는 sample입니다. 이 peripheral은 일부 hardware resource를 공유하므로 동시에 사용할 수 없지만, 둘 사이를 전환해 번갈아 사용할 수는 있습니다.
현재 Zephyr driver model에서는 boot 때 driver가 초기화한 peripheral을 deinitialize할 수 없기 때문에 Zephyr API만으로 이 전환을 구현할 수 없습니다. 따라서 sample은 전환 대상인 SPIM2와 UARTE2 instance에 nrfx driver를 직접 사용하고, 같은 peripheral type의 다른 instance에는 표준 Zephyr driver를 사용합니다. 표준 Zephyr console은 UARTE0을 사용하고, 추가 sample transfer는 SPIM1이 수행합니다.
Sample은 button 두 개를 사용합니다.
- Button 1을 누르면 현재 초기화된 peripheral(SPIM2 또는 UARTE2)을 사용해 transfer를 수행하도록 요청합니다.
- Button 2를 누르면 두 peripheral 사이를 전환합니다.
Button을 누르지 않으면 5초마다 SPIM1을 사용하는 background transfer를 수행합니다.
Sample은 보내고 받은 모든 byte의 hex code를 표준 console에 출력합니다. 사용하는 board에서 SPIM의 MOSI와 MISO pin 사이, UARTE의 TX와 RX pin 사이를 올바르게 loopback wiring하면 각 peripheral이 보낸 data가 그대로 돌아오는지 확인할 수 있습니다. 이 wiring이 없으면 UARTE는 data를 받지 못하고 SPIM은 모두 0인 값을 받습니다.
Sample이 지원하는 board에서 어느 pin이 MOSI/MISO와 TX/RX에 할당되는지는 samples/boards/nrf/nrfx_prs/boards directory의 overlay file을 참조하십시오.
요구 사항
이 sample은 Nordic Semiconductor nRF9160 DK(nrf9160dk/nrf9160)와 nRF5340 DK(nrf5340dk/nrf5340/cpuapp) board에서 시험되었습니다.
Build와 실행
Source code는 Zephyr tree의 samples/boards/nrf/nrfx_prs에 있습니다. 다음 명령으로 application을 build하고 flash합니다.
west build -b nrf9160dk/nrf9160 samples/boards/nrf/nrfx_prs
west flash
Button 1을 눌러 SPIM2 또는 UARTE2에서 sample transfer를 시작합니다. Button 2를 누르면 transfer에 사용할 peripheral type을 전환합니다.
아무 button도 누르지 않으면 SPIM1에서 background transfer가 수행됩니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.