Skip to content

Commit

Permalink
pw_uart_mcuxpresso: Add support for configuring flow control
Browse files Browse the repository at this point in the history
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 <[email protected]>
Lint: Lint 🤖 <[email protected]>
Pigweed-Auto-Submit: Austin Foxley <[email protected]>
Reviewed-by: Jonathon Reinhart <[email protected]>
Docs-Not-Needed: Austin Foxley <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
afoxley authored and CQ Bot Account committed Sep 19, 2024
1 parent c1c7dac commit e8ab2b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions pw_uart_mcuxpresso/dma_uart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions pw_uart_mcuxpresso/dma_uart_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::byte, 65536> ring_buffer = {};
constexpr uint32_t kUartRxDmaCh = 0;
Expand All @@ -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,
Expand Down
16 changes: 9 additions & 7 deletions pw_uart_mcuxpresso/public/pw_uart_mcuxpresso/dma_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8ab2b0

Please sign in to comment.