pw_stream_uart_mcuxpresso#

Pigweed AI summary: The pw_stream_uart_mcuxpresso module implements the pw_stream interface for reading and writing to a UART using the NXP MCUXpresso SDK. However, it is likely to be replaced by a future pw_uart interface. To set up this module, you need to use pw_build_mcuxpresso to create a pw_source_set for an MCUXpresso SDK, include the debug console component in the SDK definition, specify the pw_third_party_mcuxpresso_SDK GN global variable to specify the name of this

pw_stream_uart_mcuxpresso implements the pw_stream interface for reading and writing to a UART using the NXP MCUXpresso SDK.

Note

This module will likely be superseded by a future pw_uart interface.

Setup#

Pigweed AI summary: This paragraph provides a summary of the setup required for a module. It mentions that the module requires some setup and provides a list of steps to follow. These steps include creating a source set for an MCUXpresso SDK using "pw_build_mcuxpresso," including the debug console component in the SDK definition, specifying the name of the source set using the "pw_third_party_mcuxpresso_SDK" GN global variable, and using a target that calls "pw_sys_io_mcuxpresso_Init" in "

This module requires a little setup:

  1. Use pw_build_mcuxpresso to create a pw_source_set for an MCUXpresso SDK.

  2. Include the debug console component in this SDK definition.

  3. Specify the pw_third_party_mcuxpresso_SDK GN global variable to specify the name of this source set.

  4. Use a target that calls pw_sys_io_mcuxpresso_Init in pw_boot_PreMainInit or similar.

The name of the SDK source set must be set in the “pw_third_party_mcuxpresso_SDK” GN arg

Usage#

Pigweed AI summary: This paragraph provides a code snippet that demonstrates the usage of a UART stream in C++. It initializes the necessary variables and objects, sets the baud rate, configures the UART settings, and initializes the stream. Finally, it writes data to the stream.

constexpr uint32_t kFlexcomm = 0;
constexpr uint32_t kBaudRate = 115200;
std::array<std::byte, 20> kBuffer = {};

auto stream = UartStreamMcuxpresso{USART0,
                                   kBaudRate,
                                   kUSART_ParityDisabled,
                                   kUSART_OneStopBit,
                                   kBuffer};

PW_TRY(stream.Init(CLOCK_GetFlexcommClkFreq(kFlexcomm)));

std::array<std::byte, 10> to_write = {};
PW_TRY(stream.Write(to_write));