samples/basic/custom_dts_binding/README.html · samples/basic/custom_dts_binding/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Devicetree

GPIO custom Devicetree binding

일반 gpio-leds나 gpio-keys가 아닌 용도에 custom binding을 정의해 GPIO를 할당합니다.

Official pathsamples/basic/custom_dts_binding/README.html
Source filesamples/basic/custom_dts_binding/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

power-switch.yaml, board overlay, MOSFET gate driver 연결과 active-level 출력 순서를 설명합니다.

Binding

power-switch.yaml

Overlay

Board-specific pin

Load

MOSFET gate

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 A6C75F1FE20BC7D242579D109DDB3F2C0A2556AD58EC798247AC8597DA3ABE9C
.. zephyr:code-sample:: gpio-custom-dts-binding
   :name: GPIO with custom Devicetree binding
   :relevant-api: gpio_interface devicetree-generic-id devicetree-generic-exist

   Use custom Devicetree binding to control a GPIO.

Overview
********

In Zephyr, all hardware-specific configuration is described in the devicetree.

Consequently, also GPIO pins are configured in the devicetree and assigned to a specific purpose
using a compatible.

This is in contrast to other embedded environments like Arduino, where e.g. the direction (input /
output) of a GPIO pin is configured in the application firmware.

For typical use cases like LEDs or buttons, the existing :dtcompatible:`gpio-leds` or
:dtcompatible:`gpio-keys` compatibles can be used.

This sample demonstrates how to use a GPIO pin for other purposes with a custom devicetree binding.

We assume that a load with high current demands should be switched on or off via a MOSFET. The
custom devicetree binding for the power output controlled via a GPIO pin is specified in the file
:zephyr_file:`samples/basic/custom_dts_binding/dts/bindings/power-switch.yaml`. The gate driver for
the MOSFET would be connected to the pin as specified in the ``.overlay`` file in the boards
folder.

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

For each board that should be supported, a ``.overlay`` file has to be defined
in the ``boards`` subfolder.

Afterwards, the sample can be built and executed for the ``<board>`` as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/basic/custom_dts_binding
   :board: <board>
   :goals: build flash
   :compact:

For demonstration purposes, some boards use the GPIO pin of the built-in LED.

Sample output
=============

The GPIO pin should be switched to active level after one second.

The following output is printed:

.. code-block:: console

   Initializing pin with inactive level.
   Waiting one second.
   Setting pin to active level.

Part 3

한국어 전문 번역

개요

Zephyr에서는 hardware별 configuration을 모두 Devicetree에 기술합니다.

따라서 GPIO pin도 Devicetree에서 configuration하고 compatible을 사용해 특정 용도에 할당합니다. 이는 GPIO pin의 input/output direction 등을 application firmware에서 설정하는 Arduino 같은 다른 embedded 환경과 대조적입니다.

LED나 button 같은 일반적인 용도에는 기존 gpio-leds 또는 gpio-keys compatible을 사용할 수 있습니다.

이 sample은 custom Devicetree binding을 사용해 GPIO pin을 다른 용도로 사용하는 방법을 보여줍니다.

전류 요구량이 큰 load를 MOSFET으로 켜고 끈다고 가정합니다. GPIO pin으로 제어하는 power output용 custom Devicetree binding은 samples/basic/custom_dts_binding/dts/bindings/power-switch.yaml에 정의돼 있습니다. MOSFET gate driver는 boards folder의 .overlay file이 지정한 pin에 연결합니다.

Build와 실행

지원할 각 board마다 boards subfolder에 .overlay file을 정의해야 합니다.

그다음 다음 명령으로 <board>용 sample을 build하고 실행합니다.

west build -b <board> samples/basic/custom_dts_binding
west flash

Demonstration을 위해 일부 board에서는 내장 LED의 GPIO pin을 사용합니다.

Sample 출력

1초 뒤 GPIO pin이 active level로 전환돼야 하며 다음 내용을 출력합니다.

Initializing pin with inactive level.
Waiting one second.
Setting pin to active level.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.