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

Abstract base class for built-in USB Serial/JTAG controller wrappers. More...

#include <BaseUsbSerialJtag.h>

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

Public Member Functions

virtual ~BaseUsbSerialJtag () noexcept=default
 
 BaseUsbSerialJtag (const BaseUsbSerialJtag &)=delete
 
BaseUsbSerialJtag & operator= (const BaseUsbSerialJtag &)=delete
 
 BaseUsbSerialJtag (BaseUsbSerialJtag &&)=delete
 
BaseUsbSerialJtag & operator= (BaseUsbSerialJtag &&)=delete
 
bool EnsureInitialized () noexcept
 Install the underlying driver if not already installed.
 
bool EnsureDeinitialized () noexcept
 Uninstall the underlying driver if previously installed.
 
bool IsInitialized () const noexcept
 
virtual bool Initialize () noexcept=0
 Install the platform driver according to config_. Returns true on success.
 
virtual bool Deinitialize () noexcept=0
 Tear down the platform driver. Returns true on success.
 
virtual hf_uart_err_t Write (const hf_u8_t *data, hf_u32_t length, hf_u32_t timeout_ms=0) noexcept=0
 Push length bytes to the host PC.
 
virtual hf_uart_err_t Read (hf_u8_t *data, hf_u32_t length, hf_u32_t timeout_ms=0, hf_u32_t *out_read_count=nullptr) noexcept=0
 Pull up to length bytes from the host PC.
 
virtual hf_uart_err_t FlushTx (hf_u32_t timeout_ms=0) noexcept=0
 Block until the TX ring is fully drained to the host (or timeout_ms).
 
virtual bool IsHostConnected () const noexcept=0
 
hf_uart_err_t WriteString (const char *s, hf_u32_t timeout_ms=0) noexcept
 Write a NUL-terminated string (no automatic newline).
 
hf_uart_err_t WriteLine (const char *s, hf_u32_t timeout_ms=0) noexcept
 Write a NUL-terminated string then "\r\n".
 
hf_uart_err_t ReadByte (hf_u8_t &out, hf_u32_t timeout_ms=0) noexcept
 Read exactly one byte. Returns UART_ERR_TIMEOUT when nothing arrives.
 
virtual hf_uart_statistics_t GetStatistics () const noexcept
 Snapshot byte counters (default: zeroed). Implementations may override.
 
virtual hf_uart_diagnostics_t GetDiagnostics () const noexcept
 Snapshot diagnostic state (default: minimally populated).
 

Protected Member Functions

 BaseUsbSerialJtag (const hf_usb_serial_jtag_config_t &cfg) noexcept
 

Protected Attributes

hf_usb_serial_jtag_config_t config_ {}
 Subclasses may consult / mutate the buffered config before Initialize().
 
bool initialized_ {false}
 Lifecycle latch maintained by EnsureInitialized() / EnsureDeinitialized().
 

Detailed Description

Abstract base class for built-in USB Serial/JTAG controller wrappers.

Mirrors the lazy-initialise / Read / Write / Flush shape of BaseUart so a ConsoleSerialTransport can hold either a BaseUart* or a BaseUsbSerialJtag* behind a tiny adapter.

Note
Not inherently thread-safe. The underlying ESP-IDF driver is safe for concurrent reader/writer callers, but if you wrap it with stateful helpers (e.g. printf) protect them with a mutex.

Constructor & Destructor Documentation

◆ ~BaseUsbSerialJtag()

virtual BaseUsbSerialJtag::~BaseUsbSerialJtag ( )
virtualdefaultnoexcept

◆ BaseUsbSerialJtag() [1/3]

BaseUsbSerialJtag::BaseUsbSerialJtag ( const BaseUsbSerialJtag &  )
delete

◆ BaseUsbSerialJtag() [2/3]

BaseUsbSerialJtag::BaseUsbSerialJtag ( BaseUsbSerialJtag &&  )
delete

◆ BaseUsbSerialJtag() [3/3]

BaseUsbSerialJtag::BaseUsbSerialJtag ( const hf_usb_serial_jtag_config_t &  cfg)
inlineexplicitprotectednoexcept

Member Function Documentation

◆ Deinitialize()

virtual bool BaseUsbSerialJtag::Deinitialize ( )
pure virtualnoexcept

Tear down the platform driver. Returns true on success.

Implemented in EspUsbSerialJtag.

◆ EnsureDeinitialized()

bool BaseUsbSerialJtag::EnsureDeinitialized ( )
inlinenoexcept

Uninstall the underlying driver if previously installed.

◆ EnsureInitialized()

bool BaseUsbSerialJtag::EnsureInitialized ( )
inlinenoexcept

Install the underlying driver if not already installed.

◆ FlushTx()

virtual hf_uart_err_t BaseUsbSerialJtag::FlushTx ( hf_u32_t  timeout_ms = 0)
pure virtualnoexcept

Block until the TX ring is fully drained to the host (or timeout_ms).

Implemented in EspUsbSerialJtag.

◆ GetDiagnostics()

virtual hf_uart_diagnostics_t BaseUsbSerialJtag::GetDiagnostics ( ) const
inlinevirtualnoexcept

Snapshot diagnostic state (default: minimally populated).

◆ GetStatistics()

virtual hf_uart_statistics_t BaseUsbSerialJtag::GetStatistics ( ) const
inlinevirtualnoexcept

Snapshot byte counters (default: zeroed). Implementations may override.

Reimplemented in EspUsbSerialJtag.

◆ Initialize()

virtual bool BaseUsbSerialJtag::Initialize ( )
pure virtualnoexcept

Install the platform driver according to config_. Returns true on success.

Implemented in EspUsbSerialJtag.

◆ IsHostConnected()

virtual bool BaseUsbSerialJtag::IsHostConnected ( ) const
pure virtualnoexcept

True iff the host PC is currently enumerating / receiving SOF packets. Returns false when only powered (e.g. plugged into a power bank).

Implemented in EspUsbSerialJtag.

◆ IsInitialized()

bool BaseUsbSerialJtag::IsInitialized ( ) const
inlinenoexcept

◆ operator=() [1/2]

BaseUsbSerialJtag & BaseUsbSerialJtag::operator= ( BaseUsbSerialJtag &&  )
delete

◆ operator=() [2/2]

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

◆ Read()

virtual hf_uart_err_t BaseUsbSerialJtag::Read ( hf_u8_t *  data,
hf_u32_t  length,
hf_u32_t  timeout_ms = 0,
hf_u32_t *  out_read_count = nullptr 
)
pure virtualnoexcept

Pull up to length bytes from the host PC.

Parameters
dataDestination buffer.
lengthCapacity of destination buffer.
timeout_msMaximum time to wait for the first byte (0 = poll, no wait).
[out]out_read_countOptional: number of bytes actually read.
Returns
UART_SUCCESS when at least one byte was read, UART_ERR_TIMEOUT when no byte arrived in time, or another error code on failure.

Implemented in EspUsbSerialJtag.

◆ ReadByte()

hf_uart_err_t BaseUsbSerialJtag::ReadByte ( hf_u8_t &  out,
hf_u32_t  timeout_ms = 0 
)
inlinenoexcept

Read exactly one byte. Returns UART_ERR_TIMEOUT when nothing arrives.

◆ Write()

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

Push length bytes to the host PC.

Parameters
dataPointer to source buffer.
lengthNumber of bytes to push.
timeout_msMaximum time to wait if the TX ring buffer is full (0 = use the driver's default).
Returns
UART_SUCCESS if all bytes were accepted into the TX ring, UART_ERR_TIMEOUT if only some were accepted, or one of the configuration / not-initialised errors otherwise.

Implemented in EspUsbSerialJtag.

◆ WriteLine()

hf_uart_err_t BaseUsbSerialJtag::WriteLine ( const char *  s,
hf_u32_t  timeout_ms = 0 
)
inlinenoexcept

Write a NUL-terminated string then "\r\n".

◆ WriteString()

hf_uart_err_t BaseUsbSerialJtag::WriteString ( const char *  s,
hf_u32_t  timeout_ms = 0 
)
inlinenoexcept

Write a NUL-terminated string (no automatic newline).

Member Data Documentation

◆ config_

hf_usb_serial_jtag_config_t BaseUsbSerialJtag::config_ {}
protected

Subclasses may consult / mutate the buffered config before Initialize().

◆ initialized_

bool BaseUsbSerialJtag::initialized_ {false}
protected

Lifecycle latch maintained by EnsureInitialized() / EnsureDeinitialized().


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