Pigweed
 
Loading...
Searching...
No Matches
pw::uart::UartBase Class Referenceabstract

#include <uart_base.h>

Inheritance diagram for pw::uart::UartBase:
pw::uart::Uart pw::uart::UartNonBlocking pw::uart::UartBlockingAdapter

Public Member Functions

Status Enable ()
 
Status Disable ()
 
Status SetBaudRate (uint32_t baud_rate)
 
Status SetFlowControl (bool enable)
 
size_t ConservativeReadAvailable ()
 
Status ClearPendingReceiveBytes ()
 

Detailed Description

The common abstract base class of the UART interface.

The UartBase interface provides basic method for enabling and configuring a UART. Methods for actually communicating via the UART are on the Uart and UartNonBlocking child classes.

Member Function Documentation

◆ ClearPendingReceiveBytes()

Status pw::uart::UartBase::ClearPendingReceiveBytes ( )
inline

Empties the UART's receive buffer and discards any unread data.

This function removes all data from the receive buffer, resetting the buffer to an empty state. This is useful for situations where you want to disregard any previously received data and resynchronize.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The operation was successful.
* 
*  May return other implementation-specific status codes.
* 
*  

◆ ConservativeReadAvailable()

size_t pw::uart::UartBase::ConservativeReadAvailable ( )
inline

Returns the number of bytes currently available for reading.

This function checks the receive buffer to determine how many bytes of data are ready to be read.

Returns
The number of bytes available for reading. When no data is available or in case of an error this function returns 0.

◆ Disable()

Status pw::uart::UartBase::Disable ( )
inline

Disables the UART module. Disabling the UART shuts down communication and prevents the microcontroller from sending or receiving data through the UART port.

This is usually done to save power. Interrupt handlers should also be disabled.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The UART module has been successfully initialized.
* 
*     INTERNAL: Internal errors  within the hardware abstraction layer.
* 
*  

◆ Enable()

Status pw::uart::UartBase::Enable ( )
inline

Initializes the UART module, sets it into the default state as determined by the concrete UART implementation. This function should be a no-op if the UART module is in an enabled state.

This may change the power state of the UART module, configure the interface parameters, enable the associated pins, setup the internal TX and RX buffers, etc...

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The UART module has been successfully initialized.
* 
*     INTERNAL: Internal errors within the hardware abstraction layer.
* 
*  

◆ SetBaudRate()

Status pw::uart::UartBase::SetBaudRate ( uint32_t  baud_rate)
inline

Configures the UART communication baud rate.

This function sets the communication speed (baud rate) for the UART. Whether the baud rate can be changed while the UART is enabled depends on the specific implementation.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The UART has been successfully initialized.
* 
*     FAILED_PRECONDITION: The device is enabled and does not support
*     changing settings on the fly.
* 
*     INTERNAL: Internal errors  within the hardware abstraction layer.
* 
*  

◆ SetFlowControl()

Status pw::uart::UartBase::SetFlowControl ( bool  enable)
inline

Configures the UART hardware flow control enable.

This function sets the hardware flow control enable for the UART. Whether the flow control setting rate can be changed while the UART is enabled depends on the specific implementation.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The UART has been successfully initialized.
* 
*     FAILED_PRECONDITION: The device is enabled and does not support
*     changing settings on the fly.
* 
*     UNIMPLEMENTED: The device does not support flow control.
* 
*     INTERNAL: Internal errors within the hardware abstraction layer.
* 
*  

The documentation for this class was generated from the following file: