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