hardware/peripherals/uart.html · hardware/peripherals/uart.rst 공식 원문 ↗

Zephyr 3.7.0 · Hardware · Peripherals · UART

Universal Asynchronous Receiver-Transmitter(UART)

세 UART 접근 방식의 blocking·background 동작과 callback 상호 배타성을 설명합니다.

Official pathhardware/peripherals/uart.html
Source filehardware/peripherals/uart.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

필요한 Kconfig만 enable해 memory footprint를 줄이는 방법을 포함합니다.

Polling

basic · mixed blocking

Interrupt

background · callbacks

Async

DMA · no MCU interrupt

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 36496979781A4114822138E3282A532E06FF9215B2757C90D64A7174D7183F42
.. _uart_api:

Universal Asynchronous Receiver-Transmitter (UART)
##################################################

Overview
********

Zephyr provides three different ways to access the UART peripheral. Depending
on the method, different API functions are used according to below sections:

1. :ref:`uart_polling_api`
2. :ref:`uart_interrupt_api`
3. :ref:`uart_async_api` using :ref:`dma_api`

Polling is the most basic method to access the UART peripheral. The reading
function, `uart_poll_in`, is a non-blocking function and returns a character
or `-1` when no valid data is available. The writing function,
`uart_poll_out`, is a blocking function and the thread waits until the given
character is sent.

With the Interrupt-driven API, possibly slow communication can happen in the
background while the thread continues with other tasks. The Kernel's
:ref:`kernel_data_passing_api` features can be used to communicate between
the thread and the UART driver.

The Asynchronous API allows to read and write data in the background using DMA
without interrupting the MCU at all. However, the setup is more complex
than the other methods.

.. warning::

   Interrupt-driven API and the Asynchronous API should NOT be used at
   the same time for the same hardware peripheral, since both APIs require
   hardware interrupts to function properly. Using the callbacks for both
   APIs would result in interference between each other.
   :kconfig:option:`CONFIG_UART_EXCLUSIVE_API_CALLBACKS` is enabled by default
   so that only the callbacks associated with one API is active at a time.


Configuration Options
*********************

Most importantly, the Kconfig options define whether the polling API (default),
the interrupt-driven API or the asynchronous API can be used. Only enable the
features you need in order to minimize memory footprint.

Related configuration options:

* :kconfig:option:`CONFIG_SERIAL`
* :kconfig:option:`CONFIG_UART_INTERRUPT_DRIVEN`
* :kconfig:option:`CONFIG_UART_ASYNC_API`
* :kconfig:option:`CONFIG_UART_WIDE_DATA`
* :kconfig:option:`CONFIG_UART_USE_RUNTIME_CONFIGURE`
* :kconfig:option:`CONFIG_UART_LINE_CTRL`
* :kconfig:option:`CONFIG_UART_DRV_CMD`


API Reference
*************

.. doxygengroup:: uart_interface


.. _uart_polling_api:

Polling API
===========

.. doxygengroup:: uart_polling


.. _uart_interrupt_api:

Interrupt-driven API
====================

.. doxygengroup:: uart_interrupt


.. _uart_async_api:

Asynchronous API
================

.. doxygengroup:: uart_async

Part 3

한국어 전문 번역

Overview

Zephyr는 UART peripheral에 접근하는 다음 세 가지 방법을 제공합니다. 방법마다 사용하는 API function이 다릅니다.

  1. Polling API
  2. Interrupt-driven API
  3. DMA를 사용하는 Asynchronous API

uart_poll_in()을 사용하는 polling은 가장 기본적인 UART 접근 방식입니다. Read function은 non-blocking이며 유효한 data가 있으면 character를, 없으면 -1을 반환합니다. uart_poll_out() write function은 blocking이며 주어진 character를 보낼 때까지 thread가 기다립니다.

Interrupt-driven API를 사용하면 느릴 수 있는 communication이 background에서 진행되는 동안 thread가 다른 task를 계속할 수 있습니다. Kernel data-passing 기능으로 thread와 UART driver 사이에 통신할 수 있습니다.

Asynchronous API는 DMA로 MCU를 전혀 interrupt하지 않고 background에서 data를 읽고 쓸 수 있습니다. 다만 다른 방식보다 setup이 복잡합니다.

Configuration Options

Kconfig option은 polling API(기본값), interrupt-driven API, asynchronous API 가운데 어떤 방식을 사용할 수 있는지 정합니다. Memory footprint를 최소화하려면 필요한 feature만 enable합니다.

  • CONFIG_SERIAL
  • CONFIG_UART_INTERRUPT_DRIVEN
  • CONFIG_UART_ASYNC_API
  • CONFIG_UART_WIDE_DATA
  • CONFIG_UART_USE_RUNTIME_CONFIGURE
  • CONFIG_UART_LINE_CTRL
  • CONFIG_UART_DRV_CMD

API Reference

uart_interface Doxygen group이 UART interface의 공식 API reference를 제공합니다.

Polling API

uart_polling Doxygen group이 polling API reference를 제공합니다.

Interrupt-driven API

uart_interrupt Doxygen group이 interrupt-driven API reference를 제공합니다.

Asynchronous API

uart_async Doxygen group이 asynchronous API reference를 제공합니다.

Source

출처

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