/* Send SWITCH_FUNCTION command to switch the card function group.  */
static status_t SD_SwitchFunction(sd_card_t *card, uint32_t mode, uint32_t group, uint32_t number, uint32_t *status)
/* Send SWITCH_FUNCTION command to switch the card function group.  */
static status_t SD_SwitchFunction(sd_card_t *card, uint32_t mode, uint32_t group, uint32_t number, uint32_t *status)
{
    assert(card);
    assert(status);
    HOST_TRANSFER content = {0};
    HOST_COMMAND command = {0};
    HOST_DATA data = {0};
    command.index = kSD_Switch;
    command.argument = (mode << 31U | 0x00FFFFFFU);
    command.argument &= ~((uint32_t)(0xFU) << (group * 4U));
    command.argument |= (number << (group * 4U));
    command.responseType = kCARD_ResponseTypeR1;
    data.blockSize = 64U;
    data.blockCount = 1U;
    data.rxData = status;
    content.command = &command;
    content.data = &data;
    if ((kStatus_Success != card->host.transfer(card->host.base, &content)) ||
        ((command.response[0U]) & kSDMMC_R1ErrorAllFlag))
    {
        return kStatus_SDMMC_TransferFailed;
    }
    return kStatus_Success;
}