Internal Interface Wrap
API reference
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
EspUsbSerialJtag Class Referencefinal

#include <EspUsbSerialJtag.h>

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

Public Member Functions

 EspUsbSerialJtag (const hf_usb_serial_jtag_config_t &cfg) noexcept
 
 EspUsbSerialJtag () noexcept
 Construct with library defaults (256-byte TX/RX rings).
 
 ~EspUsbSerialJtag () noexcept override
 
bool Initialize () noexcept override
 Install the platform driver according to config_. Returns true on success.
 
bool Deinitialize () noexcept override
 Tear down the platform driver. Returns true on success.
 
hf_uart_err_t Write (const hf_u8_t *data, hf_u32_t length, hf_u32_t timeout_ms=0) noexcept override
 Push length bytes to the host PC.
 
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 override
 Pull up to length bytes from the host PC.
 
hf_uart_err_t FlushTx (hf_u32_t timeout_ms=0) noexcept override
 Block until the TX ring is fully drained to the host (or timeout_ms).
 
bool IsHostConnected () const noexcept override
 
hf_uart_statistics_t GetStatistics () const noexcept override
 Snapshot byte counters (default: zeroed). Implementations may override.
 
- Public Member Functions inherited from BaseUsbSerialJtag
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
 
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_diagnostics_t GetDiagnostics () const noexcept
 Snapshot diagnostic state (default: minimally populated).
 

Static Public Member Functions

static EspUsbSerialJtag & Default (const hf_usb_serial_jtag_config_t &cfg={}) noexcept
 Get-or-create a process-wide shared instance.
 

Private Attributes

bool owns_driver_ {false}
 
hf_uart_statistics_t statistics_ {}
 

Additional Inherited Members

- Protected Member Functions inherited from BaseUsbSerialJtag
 BaseUsbSerialJtag (const hf_usb_serial_jtag_config_t &cfg) noexcept
 
- Protected Attributes inherited from BaseUsbSerialJtag
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().
 

Constructor & Destructor Documentation

◆ EspUsbSerialJtag() [1/2]

EspUsbSerialJtag::EspUsbSerialJtag ( const hf_usb_serial_jtag_config_t &  cfg)
explicitnoexcept

Construct with explicit configuration (driver is NOT installed yet — call EnsureInitialized() or Initialize() to install).

◆ EspUsbSerialJtag() [2/2]

EspUsbSerialJtag::EspUsbSerialJtag ( )
noexcept

Construct with library defaults (256-byte TX/RX rings).

◆ ~EspUsbSerialJtag()

EspUsbSerialJtag::~EspUsbSerialJtag ( )
overridenoexcept

Member Function Documentation

◆ Default()

EspUsbSerialJtag & EspUsbSerialJtag::Default ( const hf_usb_serial_jtag_config_t &  cfg = {})
staticnoexcept

Get-or-create a process-wide shared instance.

The first call configures the singleton with cfg. Subsequent calls ignore cfg and return the same instance. This matches the underlying hardware: the USB Serial/JTAG block is global.

Parameters
cfgConfiguration applied on first call only.
Returns
Reference to the shared instance.

◆ Deinitialize()

bool EspUsbSerialJtag::Deinitialize ( )
overridevirtualnoexcept

Tear down the platform driver. Returns true on success.

Implements BaseUsbSerialJtag.

◆ FlushTx()

hf_uart_err_t EspUsbSerialJtag::FlushTx ( hf_u32_t  timeout_ms = 0)
overridevirtualnoexcept

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

Implements BaseUsbSerialJtag.

◆ GetStatistics()

hf_uart_statistics_t EspUsbSerialJtag::GetStatistics ( ) const
inlineoverridevirtualnoexcept

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

Reimplemented from BaseUsbSerialJtag.

◆ Initialize()

bool EspUsbSerialJtag::Initialize ( )
overridevirtualnoexcept

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

Implements BaseUsbSerialJtag.

◆ IsHostConnected()

bool EspUsbSerialJtag::IsHostConnected ( ) const
overridevirtualnoexcept

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

Implements BaseUsbSerialJtag.

◆ Read()

hf_uart_err_t EspUsbSerialJtag::Read ( hf_u8_t *  data,
hf_u32_t  length,
hf_u32_t  timeout_ms = 0,
hf_u32_t *  out_read_count = nullptr 
)
overridevirtualnoexcept

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.

Implements BaseUsbSerialJtag.

◆ Write()

hf_uart_err_t EspUsbSerialJtag::Write ( const hf_u8_t *  data,
hf_u32_t  length,
hf_u32_t  timeout_ms = 0 
)
overridevirtualnoexcept

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.

Implements BaseUsbSerialJtag.

Member Data Documentation

◆ owns_driver_

bool EspUsbSerialJtag::owns_driver_ {false}
private

True when this wrapper called usb_serial_jtag_driver_install() itself (vs. discovering an already-installed IDF console driver). Controls whether Deinitialize() calls usb_serial_jtag_driver_uninstall().

◆ statistics_

hf_uart_statistics_t EspUsbSerialJtag::statistics_ {}
private

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