Edit

WinI3CWriteVendorCcc function (wini3c.h)

Performs a blocking write of the supplied Vendor Common Command Code (CCC) and optional payload to a WinI3C-Target. This corresponds to an I3C Direct Set CCC command.

WinI3CWriteVendorCcc is a Library-managed WinI3C API (the recommended way to use WinI3C). For an overlapped equivalent, see WinI3CWriteVendorCccWithFileHandle.

Syntax

_Must_inspect_result_
HRESULT WINAPI WinI3CWriteVendorCcc(
    _In_ WinI3CTarget target,
    _In_ UINT8 commandCode,
    _In_reads_opt_(1) const UINT8* definingByte,
    _When_(writeVendorCccPayload == NULL, _In_range_(0, 0)) UINT32 writeVendorCccPayloadSize,
    _In_reads_bytes_opt_(writeVendorCccPayloadSize) const void* writeVendorCccPayload);

Parameters

[in] target

The WinI3CTarget to write to.

The handle shall have been created by WinI3CInitializeTarget.

[in] commandCode

The Write CCC to be sent.

Only Vendor Direct CCCs (0xE0–0xFE, inclusive) are permitted.

[in, optional] definingByte

An optional defining byte (secondary code) for the Vendor Direct CCC.

Specify NULL if none is supplied.

Not all WinI3C-Targets/HostController-Instances support defining bytes.

[in] writeVendorCccPayloadSize

The number of bytes to write.

  • Shall be 0 when writeVendorCccPayload is NULL.
  • Shall be <= bufferSize(writeVendorCccPayload).
  • Shall be <= 65535 (the maximum I3C transfer size).

[in, optional] writeVendorCccPayload

An optional client-allocated buffer containing the payload to write.

The buffer shall be writeVendorCccPayloadSize bytes.

Shall be NULL when writeVendorCccPayloadSize is 0.

Return value

On success this function returns S_OK.

On failure this function returns an appropriate HRESULT error code, including the following.

Return code Description
S_OK Successfully wrote the CCC and payload.
E_INVALIDARG One or more parameters are invalid.
E_OUTOFMEMORY Available memory is insufficient to execute this function.
HRESULT_FROM_WIN32(ERROR_DEVICE_NACKED) The WinI3C-Target (passively) NACKed, because it is busy, does not support the CCC, or has experienced a fatal hardware error. Consider calling WinI3CGetStatus to understand the current WinI3C-Target state.
HRESULT_FROM_WIN32(ERROR_DEVICE_NOT_CONNECTED) The WinI3C-Target is not connected. Destroy the handle with WinI3CRelease.
HRESULT_FROM_WIN32(ERROR_DEVICE_HARDWARE_ERROR) A fatal hardware error occurred. Destroy the handle with WinI3CRelease.

Remarks

The maximum write size expected by the WinI3C-Target is set with WinI3CSetMaxWriteLength.

Only Vendor Direct CCCs (0xE0–0xFE) are supported; broadcast and bus-management CCCs (e.g. ENEC/DEFGRPA) are not permitted.

CCCs are always sent at SDR, so a preferred mode cannot be specified.

This function is thread-safe.

Example

#include <wini3c.h>

void main()
{
    ...

    const uint8_t directCCC = ...;
    std::vector<uint8_t> writePayload = { 0x01, 0x02 };

    if (FAILED(WinI3CWriteVendorCcc(
        target,
        directCCC,
        nullptr,
        (uint32_t)writePayload.size(),
        writePayload.data())))
    {
        // Handle failure.
    }

    ...
}

Requirements

Requirement Value
Minimum supported client Windows 11 25H2 October update (build 26200)
Target Platform Windows
Header wini3c.h
DLL wini3c.dll

See also

WinI3CWriteVendorCccWithFileHandle

WinI3CReadVendorCcc