pw_uart#

Core interfaces for UART communication

Unstable C++

Pigweed’s pw_uart module provides a set of interfaces for communicating via UART.

Overview#

pw_uart defines core methods for UART communication. This serves as a blueprint for concrete UART implementations. You will need to write the backend code tailored to your specific hardware device to interact with the UART peripheral.

The interface consists of these main classes:

  • UartBase - Base class which provides basic enable/disable and configuration control, but no communication.

  • Uart - Extends pw::uart::UartBase to provide blocking Read and Write APIs.

  • UartNonBlocking - Extends pw::uart::UartBase to provide non-blocking (callback-based) Read and Write APIs.

  • UartBlockingAdapter - Provides the blocking Uart interface on top of a UartNonBlocking device.

  • UartStream - Provides the pw::stream::NonSeekableReaderWriter (pw_stream) interface on top of a Uart device.

Warning

Drivers should not implement both Uart and UartNonBlocking interfaces.

Drivers which support non-blocking (callback) behavior should implement UartNonBlocking. Applications that require the blocking Uart interface can use the UartBlockingAdapter.

        classDiagram
 namespace uart {
   class UartBase
   class Uart
   class UartNonBlocking
   class UartBlockingAdapter
   class UartStream
 }

 namespace stream {
   class NonSeekableReaderWriter
 }

 UartBase <|-- Uart : extends
 UartBase <|-- UartNonBlocking : extends

 Uart <|-- UartBlockingAdapter : implements
 UartNonBlocking --> UartBlockingAdapter

 NonSeekableReaderWriter <|-- UartStream : implements
 Uart --> UartStream
    

Get started#

Add @pigweed//pw_uart to the deps list in your Bazel target:

cc_library("...") {
  # ...
  deps = [
    # ...
    "@pigweed//pw_uart",
    # ...
  ]
}

Add $dir_pw_uart to the deps list in your pw_executable() build target:

pw_executable("...") {
  # ...
  deps = [
    # ...
    "$dir_pw_uart",
    # ...
  ]
}

Add pw_uart to your pw_add_library or similar CMake target:

pw_add_library(my_library STATIC
  HEADERS
    ...
  PRIVATE_DEPS
    # ...
    pw_uart
    # ...
)

API reference#

Moved: pw_uart