Funzione UcmConnectorCreate (ucmmanager.h)

Crea un oggetto connettore.

Sintassi

NTSTATUS UcmConnectorCreate(
  [in]  WDFDEVICE              WdfDevice,
  [in]  PUCM_CONNECTOR_CONFIG  Config,
  [in]  PWDF_OBJECT_ATTRIBUTES Attributes,
  [out] UCMCONNECTOR           *Connector
);

Parametri

[in] WdfDevice

Handle a un oggetto dispositivo framework ricevuto dal driver client nella chiamata precedente a WdfDeviceCreate.

[in] Config

Puntatore a una struttura di UCM_CONNECTOR_CONFIG fornita dal chiamante che viene inizializzata chiamando UCM_CONNECTOR_CONFIG_INIT.

[in] Attributes

Puntatore a una struttura di WDF_OBJECT_ATTRIBUTES fornita dal chiamante che contiene attributi per il nuovo oggetto connettore. Questo parametro è facoltativo e può essere WDF_NO_OBJECT_ATTRIBUTES.

[out] Connector

Puntatore a una posizione che riceve un handle per il nuovo oggetto connettore.

Valore restituito

UcmConnectorCreate restituisce STATUS_SUCCESS se l'operazione ha esito positivo. In caso contrario, questo metodo può restituire un valore NTSTATUS appropriato.

Commenti

Se il driver client specifica un identificatore del connettore già in uso, il metodo ha esito negativo con STATUS_INVALID_PARAMETER codice di errore.

Se il connettore Type-C viene specificato come una porta Dual-Role (DRP), il driver client deve registrare il callback dell'evento EVT_UCM_CONNECTOR_SET_DATA_ROLE .

L'oggetto padre è WdfDevice. È possibile impostare il membro ParentObject di WDF_OBJECT_ATTRIBUTES su NULL o sull'handle WDFDEVICE. L'oggetto connector viene eliminato quando l'oggetto WDFDEVICE padre viene eliminato.

Un posto appropriato per un driver client UCM per chiamare UcmConnectorCreate è in EvtDevicePrepareHardware o EvtDeviceD0Entry. Al contrario, il driver deve rilasciare l'handle UCMCONNECTOR in EvtDeviceReleaseHardware o EvtDeviceD0Exit.

Esempio

Questo codice di esempio illustra come creare un connettore Type-C compatibile con PD.

    
    UCMCONNECTOR Connector;
  
    UCM_CONNECTOR_CONFIG_INIT(&connCfg, 0);

    UCM_CONNECTOR_TYPE_C_CONFIG_INIT(
        &connCfg.TypeCConfig,
        UcmTypeCOperatingModeDrp,
        UcmTypeCCurrentDefaultUsb | UcmTypeCCurrent1500mA | UcmTypeCCurrent3000mA);

    connCfg.EvtSetDataRole = EvtSetDataRole;

    UCM_CONNECTOR_PD_CONFIG_INIT(&connCfg.PdConfig, UcmPowerRoleSink | UcmPowerRoleSource);

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, CONNECTOR_CONTEXT);

    status = UcmConnectorCreate(Device, &connCfg, &attr, &Connector);
    if (!NT_SUCCESS(status))
    {
        TRACE_ERROR(
            "UcmConnectorCreate failed with %!STATUS!.",
            status);
        goto Exit;
    }

    TRACE_INFO("UcmConnectorCreate() succeeded.");

Requisiti

Requisito Valore
Client minimo supportato Windows 10
Server minimo supportato Windows Server 2016
Piattaforma di destinazione Windows
Versione KMDF minima 1.15
Versione UMDF minima 2.15
Intestazione ucmmanager.h (includere Ucmcx.h)
Libreria UcmCxstub.lib
IRQL PASSIVE_LEVEL

Vedi anche

UCM_CONNECTOR_CONFIG

UCM_CONNECTOR_CONFIG_INIT