Partager via


UsbDbgPdd_SendCmd (Compact 2013)

10/16/2014

Implement this function to receive commands from the model device driver (MDD).

Syntax

extern "C" DWORD UsbDbgPdd_SendCmd(
    USBDBG_CMD cmd,
    DWORD epNum,
    USBDBG_ENDPTDIR epDir
)

Parameters

  • cmd
    [in] A USBDBG_CMD command that stalls the endpoint or aborts a transfer.
  • epNum
    [in] The endpoint to receive the command.
  • epDir
    [in] The endpoint direction, either ENDPT_DIR_IN or ENDPT_DIR_OUT.

Return Value

Implement this function so that it returns ERROR_SUCCESS if successful; otherwise, return an error code defined in WinError.h. The MDD ignores the return value.

Remarks

The MDD calls this function to send miscellaneous commands to the platform-dependent device driver (PDD). For a list of the messages that the MDD sends, see the USBDBG_CMD enumeration. For valid values for the epDir parameter, see the USBDBG_ENDPTDIR enumeration.

Example

The following example shows a typical implementation of the UsbDbgPdd_SendCmd function.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

extern "C" DWORD UsbDbgPdd_SendCmd(
    USBDBG_CMD cmd,
    DWORD epNum,
    USBDBG_ENDPTDIR epDir
    )
{
    DWORD dwRegVal;
    USBFN_PDD *pPdd = (USBFN_PDD *)&usbfn_pdd;
    DWORD mappedEp;

    USBDBGMSG(USBDBG_ZONE_FUNC, (L"usbdbgpdd: +UsbDbgPdd_SendCmd\r\n"));

    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"UsbDbgPdd_SendCmd:: Cmd 0x%x\r\n", cmd));
    // Select EP
    epNum &= USBD_EP_NUM;

    if ( epNum == 0 )
    {
        mappedEp = (epDir == ENDPT_DIR_IN) ? 0 : USBD_EP_NUM - 1;
    }
    else
        mappedEp = epNum;
    switch (cmd)
    {
        // abort transfer on an endpt
        case USBDBG_CMD_TRANSFER_ABORT:
        {
            if ( pPdd->ep[mappedEp]->pBuffer != NULL )
            {
                FlushEndpoint( pPdd, mappedEp, (epDir == ENDPT_DIR_OUT) );

                // Finish transfer
                pPdd->ep[mappedEp]->pBuffer = NULL;
            }
            USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"UsbDbgPdd_SendCmd::Abort Transfer Cmd\r\n"));
            break;
        }

        default:
            break;
    }

    USBDBGMSG(USBDBG_ZONE_FUNC, (L"usbdbgpdd: -UsbDbgPdd_SendCmd\r\n"));

    return ERROR_SUCCESS;
}

Requirements

Header

UsbDbgDdsi.h

See Also

Reference

USBDBG PDD Functions