/* This function initiates the Cmd transfer to SD card.  */
s32 XSdPs_SendCmd(XSdPs *InstancePtr, u32 Cmd)
/* This function initiates the Cmd transfer to SD card.  */
s32 XSdPs_SendCmd(XSdPs *InstancePtr, u32 Cmd)
{
    u32 PresentStateReg;
    u32 CommandReg;
    s32 Status;
    CommandReg = XSdPs_FrameCmd(InstancePtr, Cmd);
    CommandReg = CommandReg & 0x3FFFU;
    if ((Cmd != CMD21) && (Cmd != CMD19)) {
        PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress,
                XSDPS_PRES_STATE_OFFSET);
        if (((PresentStateReg & XSDPS_PSR_INHIBIT_DAT_MASK) != 0U) &&
                ((CommandReg & XSDPS_DAT_PRESENT_SEL_MASK) != 0U)) {
            Status = XST_FAILURE;
            goto RETURN_PATH;
        }
    }
    XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_XFER_MODE_OFFSET,
            (CommandReg << 16) | InstancePtr->TransferMode);
    Status = XST_SUCCESS;
RETURN_PATH:
    return Status;
}