From e8ab2b0ac31c0dde6febd0d384c0ea7d688f6803 Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Thu, 19 Sep 2024 16:16:29 +0000 Subject: [PATCH] pw_uart_mcuxpresso: Add support for configuring flow control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set default values for flow_control,parity,stop_bits Bug: 368150004 Change-Id: I0e6982eac9ce13f2a609eeea7fcf0c7e83d0b486 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/236896 Presubmit-Verified: CQ Bot Account Lint: Lint 🤖 Pigweed-Auto-Submit: Austin Foxley Reviewed-by: Jonathon Reinhart Docs-Not-Needed: Austin Foxley Commit-Queue: Auto-Submit --- pw_uart_mcuxpresso/dma_uart.cc | 1 + pw_uart_mcuxpresso/dma_uart_example.cc | 2 ++ .../public/pw_uart_mcuxpresso/dma_uart.h | 16 +++++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pw_uart_mcuxpresso/dma_uart.cc b/pw_uart_mcuxpresso/dma_uart.cc index 85fea19093..291c20baab 100644 --- a/pw_uart_mcuxpresso/dma_uart.cc +++ b/pw_uart_mcuxpresso/dma_uart.cc @@ -64,6 +64,7 @@ Status DmaUartMcuxpresso::Init() { USART_GetDefaultConfig(&defconfig_); defconfig_.baudRate_Bps = config_.baud_rate; + defconfig_.enableHardwareFlowControl = config_.flow_control; defconfig_.parityMode = config_.parity; defconfig_.enableTx = true; defconfig_.enableRx = true; diff --git a/pw_uart_mcuxpresso/dma_uart_example.cc b/pw_uart_mcuxpresso/dma_uart_example.cc index 40e8cac754..623c8e9cc8 100644 --- a/pw_uart_mcuxpresso/dma_uart_example.cc +++ b/pw_uart_mcuxpresso/dma_uart_example.cc @@ -23,6 +23,7 @@ pw::Status DmaUartExample() { constexpr uint32_t kFlexcomm = 0; const auto kUartBase = USART0; constexpr uint32_t kBaudRate = 115200; + constexpr bool kFlowControl = true; constexpr uint32_t kUartInstance = 5; std::array ring_buffer = {}; constexpr uint32_t kUartRxDmaCh = 0; @@ -33,6 +34,7 @@ pw::Status DmaUartExample() { const pw::uart::DmaUartMcuxpresso::Config kConfig = { .usart_base = kUartBase, .baud_rate = kBaudRate, + .flow_control = kFlowControl, .parity = kUSART_ParityDisabled, .stop_bits = kUSART_OneStopBit, .dma_base = DMA0, diff --git a/pw_uart_mcuxpresso/public/pw_uart_mcuxpresso/dma_uart.h b/pw_uart_mcuxpresso/public/pw_uart_mcuxpresso/dma_uart.h index 4e3ed503dd..52f74c9132 100644 --- a/pw_uart_mcuxpresso/public/pw_uart_mcuxpresso/dma_uart.h +++ b/pw_uart_mcuxpresso/public/pw_uart_mcuxpresso/dma_uart.h @@ -32,13 +32,15 @@ class DmaUartMcuxpresso final : public Uart { public: // Configuration structure struct Config { - USART_Type* usart_base; // Base of USART control struct - uint32_t baud_rate; // Desired communication speed - usart_parity_mode_t parity; // Parity setting - usart_stop_bit_count_t stop_bits; // Number of stop bits to use - DMA_Type* dma_base; // Base of DMA control struct - uint32_t rx_dma_ch; // Receive DMA channel - uint32_t tx_dma_ch; // Transmit DMA channel + USART_Type* usart_base; // Base of USART control struct + uint32_t baud_rate; // Desired communication speed + bool flow_control = false; // Hardware flow control setting + usart_parity_mode_t parity = kUSART_ParityDisabled; // Parity setting + usart_stop_bit_count_t stop_bits = + kUSART_OneStopBit; // Number of stop bits to use + DMA_Type* dma_base; // Base of DMA control struct + uint32_t rx_dma_ch; // Receive DMA channel + uint32_t tx_dma_ch; // Transmit DMA channel inputmux_signal_t rx_input_mux_dmac_ch_request_en; // Rx input mux signal inputmux_signal_t tx_input_mux_dmac_ch_request_en; // Tx input mux signal ByteSpan buffer; // Receive ring buffer