xref: /aosp_15_r20/external/pigweed/pw_stream_uart_mcuxpresso/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1.. _module-pw_stream_uart_mcuxpresso:
2
3=========================
4pw_stream_uart_mcuxpresso
5=========================
6``pw_stream_uart_mcuxpresso`` implements the ``pw_stream`` interface for reading
7and writing to a UART using the NXP MCUXpresso SDK. ``UartStreamMcuxpresso``
8version uses the CPU to read and write to the UART, while ``DmaUartMcuxpresso``
9in :ref:`module-pw_uart_mcuxpresso` uses DMA transfers to read and write to the
10UART minimizing the CPU utilization.
11
12``InterruptSafeUartWriterMcuxpresso`` implements an interrupt safe
13write-only stream to UART. Intended for use in fault handlers. It can be
14constructed ``constinit`` for use in pre-static constructor environments as well.
15
16.. note::
17
18   This module is moving to :ref:`module-pw_uart_mcuxpresso`.
19
20Setup
21=====
22This module requires a little setup:
23
241. Use ``pw_build_mcuxpresso`` to create a ``pw_source_set`` for an
25   MCUXpresso SDK.
262. Include the debug console component in this SDK definition.
273. Specify the ``pw_third_party_mcuxpresso_SDK`` GN global variable to specify
28   the name of this source set.
294. Use a target that calls ``pw_sys_io_mcuxpresso_Init`` in
30   ``pw_boot_PreMainInit`` or similar.
31
32The name of the SDK source set must be set in the
33"pw_third_party_mcuxpresso_SDK" GN arg
34
35Usage
36=====
37
38``UartStreamMcuxpresso`` example:
39
40.. literalinclude:: stream_example.cc
41   :language: cpp
42   :linenos:
43   :start-after: [pw_stream_uart_mcuxpresso-UartStreamExample]
44   :end-before: [pw_stream_uart_mcuxpresso-UartStreamExample]
45
46``InterruptSafeUartWriterMcuxpresso`` example:
47
48.. literalinclude:: interrupt_safe_writer_example.cc
49   :language: cpp
50   :linenos:
51   :start-after: [pw_stream_uart_mcuxpresso-UartInterruptSafeWriterExample]
52   :end-before: [pw_stream_uart_mcuxpresso-UartInterruptSafeWriterExample]
53