Internal Interface Wrap
API reference
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BaseUart Class Referenceabstract

Abstract base class for UART driver implementations. More...

#include <BaseUart.h>

Inheritance diagram for BaseUart:
[legend]
Collaboration diagram for BaseUart:
[legend]

Public Member Functions

virtual ~BaseUart () noexcept=default
 Virtual destructor ensures proper cleanup in derived classes.
 
 BaseUart (const BaseUart &)=delete
 
BaseUart & operator= (const BaseUart &)=delete
 
 BaseUart (BaseUart &&)=delete
 
BaseUart & operator= (BaseUart &&)=delete
 
bool EnsureInitialized () noexcept
 Ensures that the UART is initialized (lazy initialization).
 
bool EnsureDeinitialized () noexcept
 Ensures that the UART is deinitialized (lazy deinitialization).
 
bool IsInitialized () const noexcept
 Checks if the driver is initialized.
 
hf_port_num_t GetPort () const noexcept
 Get the UART port number.
 
virtual bool Initialize () noexcept=0
 Initialize the UART driver.
 
virtual bool Deinitialize () noexcept=0
 Deinitialize the UART driver.
 
virtual hf_uart_err_t Write (const hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept=0
 Write data to the UART.
 
virtual hf_uart_err_t Read (hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept=0
 Read data from the UART.
 
virtual hf_u16_t BytesAvailable () noexcept=0
 Get the number of bytes available to read.
 
virtual hf_uart_err_t FlushTx () noexcept=0
 Flush the transmit buffer.
 
virtual hf_uart_err_t FlushRx () noexcept=0
 Flush the receive buffer.
 
virtual int Printf (const char *format,...) noexcept=0
 Printf-style formatted output.
 
virtual bool Open () noexcept
 Open the UART (alias for Initialize).
 
virtual bool Close () noexcept
 Close the UART (alias for Deinitialize).
 
virtual bool WriteString (const char *str) noexcept
 Write a string to the UART.
 
virtual bool WriteByte (hf_u8_t byte) noexcept
 Write a single byte to the UART.
 
virtual hf_uart_err_t ResetStatistics () noexcept
 Reset UART operation statistics.
 
virtual hf_uart_err_t ResetDiagnostics () noexcept
 Reset UART diagnostic information.
 
virtual hf_uart_err_t GetStatistics (hf_uart_statistics_t &statistics) const noexcept
 Get UART operation statistics.
 
virtual hf_uart_err_t GetDiagnostics (hf_uart_diagnostics_t &diagnostics) const noexcept
 Get UART diagnostic information.
 

Protected Member Functions

 BaseUart (hf_port_num_t port) noexcept
 Protected constructor with port.
 

Protected Attributes

hf_port_num_t port_
 UART port number.
 
bool initialized_
 Initialization status.
 
hf_uart_statistics_t statistics_
 UART operation statistics.
 
hf_uart_diagnostics_t diagnostics_
 UART diagnostic information.
 

Detailed Description

Abstract base class for UART driver implementations.

This class provides a comprehensive UART driver abstraction that serves as the base for all UART implementations in the HardFOC system. It supports:

Derived classes implement platform-specific details such as:

Note
This is a header-only abstract base class - instantiate concrete implementations instead.
This class is not inherently thread-safe. Use appropriate synchronization if accessed from multiple contexts.

Constructor & Destructor Documentation

◆ ~BaseUart()

virtual BaseUart::~BaseUart ( )
virtualdefaultnoexcept

Virtual destructor ensures proper cleanup in derived classes.

◆ BaseUart() [1/3]

BaseUart::BaseUart ( const BaseUart &  )
delete

◆ BaseUart() [2/3]

BaseUart::BaseUart ( BaseUart &&  )
delete

◆ BaseUart() [3/3]

BaseUart::BaseUart ( hf_port_num_t  port)
inlineprotectednoexcept

Protected constructor with port.

Parameters
portUART port number

Member Function Documentation

◆ BytesAvailable()

virtual hf_u16_t BaseUart::BytesAvailable ( )
pure virtualnoexcept

Get the number of bytes available to read.

Returns
Number of bytes available in the receive buffer

Implemented in EspUart, and StmUart.

◆ Close()

virtual bool BaseUart::Close ( )
inlinevirtualnoexcept

Close the UART (alias for Deinitialize).

Returns
true if successful, false otherwise

◆ Deinitialize()

virtual bool BaseUart::Deinitialize ( )
pure virtualnoexcept

Deinitialize the UART driver.

Returns
true if successful, false otherwise

Implemented in EspUart, and StmUart.

◆ EnsureDeinitialized()

bool BaseUart::EnsureDeinitialized ( )
inlinenoexcept

Ensures that the UART is deinitialized (lazy deinitialization).

Returns
true if the UART is deinitialized, false otherwise.

◆ EnsureInitialized()

bool BaseUart::EnsureInitialized ( )
inlinenoexcept

Ensures that the UART is initialized (lazy initialization).

Returns
true if the UART is initialized, false otherwise.

◆ FlushRx()

virtual hf_uart_err_t BaseUart::FlushRx ( )
pure virtualnoexcept

Flush the receive buffer.

Returns
hf_uart_err_t result code

Implemented in EspUart, and StmUart.

◆ FlushTx()

virtual hf_uart_err_t BaseUart::FlushTx ( )
pure virtualnoexcept

Flush the transmit buffer.

Returns
hf_uart_err_t result code

Implemented in EspUart, and StmUart.

◆ GetDiagnostics()

virtual hf_uart_err_t BaseUart::GetDiagnostics ( hf_uart_diagnostics_t &  diagnostics) const
inlinevirtualnoexcept

Get UART diagnostic information.

Parameters
diagnosticsReference to store diagnostics data
Returns
hf_uart_err_t::UART_SUCCESS if successful, UART_ERR_NOT_SUPPORTED if not implemented

Reimplemented in EspUart.

◆ GetPort()

hf_port_num_t BaseUart::GetPort ( ) const
inlinenoexcept

Get the UART port number.

Returns
Port number

◆ GetStatistics()

virtual hf_uart_err_t BaseUart::GetStatistics ( hf_uart_statistics_t &  statistics) const
inlinevirtualnoexcept

Get UART operation statistics.

Parameters
statisticsReference to store statistics data
Returns
hf_uart_err_t::UART_SUCCESS if successful, UART_ERR_NOT_SUPPORTED if not implemented

Reimplemented in EspUart.

◆ Initialize()

virtual bool BaseUart::Initialize ( )
pure virtualnoexcept

Initialize the UART driver.

Returns
true if successful, false otherwise

Implemented in EspUart, and StmUart.

◆ IsInitialized()

bool BaseUart::IsInitialized ( ) const
inlinenoexcept

Checks if the driver is initialized.

Returns
true if initialized, false otherwise

◆ Open()

virtual bool BaseUart::Open ( )
inlinevirtualnoexcept

Open the UART (alias for Initialize).

Returns
true if successful, false otherwise

◆ operator=() [1/2]

BaseUart & BaseUart::operator= ( BaseUart &&  )
delete

◆ operator=() [2/2]

BaseUart & BaseUart::operator= ( const BaseUart &  )
delete

◆ Printf()

virtual int BaseUart::Printf ( const char *  format,
  ... 
)
pure virtualnoexcept

Printf-style formatted output.

Parameters
formatFormat string
...Format arguments
Returns
Number of characters written, or -1 on error

Implemented in EspUart, and StmUart.

◆ Read()

virtual hf_uart_err_t BaseUart::Read ( hf_u8_t *  data,
hf_u16_t  length,
hf_u32_t  timeout_ms = 0 
)
pure virtualnoexcept

Read data from the UART.

Parameters
dataBuffer to store received data
lengthNumber of bytes to read
timeout_msTimeout in milliseconds (0 = use default)
Returns
hf_uart_err_t result code

Implemented in StmUart, and EspUart.

◆ ResetDiagnostics()

virtual hf_uart_err_t BaseUart::ResetDiagnostics ( )
inlinevirtualnoexcept

Reset UART diagnostic information.

Returns
hf_uart_err_t::UART_SUCCESS if successful, error code otherwise
Note
Override this method to provide platform-specific diagnostics reset

◆ ResetStatistics()

virtual hf_uart_err_t BaseUart::ResetStatistics ( )
inlinevirtualnoexcept

Reset UART operation statistics.

Returns
hf_uart_err_t::UART_SUCCESS if successful, error code otherwise
Note
Override this method to provide platform-specific statistics reset

◆ Write()

virtual hf_uart_err_t BaseUart::Write ( const hf_u8_t *  data,
hf_u16_t  length,
hf_u32_t  timeout_ms = 0 
)
pure virtualnoexcept

Write data to the UART.

Parameters
dataData buffer to transmit
lengthNumber of bytes to write
timeout_msTimeout in milliseconds (0 = use default)
Returns
hf_uart_err_t result code

Implemented in StmUart, and EspUart.

◆ WriteByte()

virtual bool BaseUart::WriteByte ( hf_u8_t  byte)
inlinevirtualnoexcept

Write a single byte to the UART.

Parameters
byteByte to write
Returns
true if successful, false otherwise

Reimplemented in EspUart.

◆ WriteString()

virtual bool BaseUart::WriteString ( const char *  str)
inlinevirtualnoexcept

Write a string to the UART.

Parameters
strString to write
Returns
true if successful, false otherwise

Member Data Documentation

◆ diagnostics_

hf_uart_diagnostics_t BaseUart::diagnostics_
protected

UART diagnostic information.

◆ initialized_

bool BaseUart::initialized_
protected

Initialization status.

◆ port_

hf_port_num_t BaseUart::port_
protected

UART port number.

◆ statistics_

hf_uart_statistics_t BaseUart::statistics_
protected

UART operation statistics.


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