Browse Source

Bsp lpc55sxx (#6897)

* [bsp_lpc55sxx] i2c,rtc bsp update

1. add i2c DMA mode
2. enable rtc driver

* [bsp_lpc55sxx] formmat code

using formmating.py for format code

* [lpc55sxx] remove .gitignore

* [bsp][lpc55sxx] update bsp driver

1. update sdif driver, enable DFS, FAT32
2. update rtc driver
杨熙 2 years ago
parent
commit
83bd8614ab
38 changed files with 2402 additions and 15085 deletions
  1. 0 166
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/common/fsl_sdmmc_common.c
  2. 0 366
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/common/fsl_sdmmc_common.h
  3. 0 1262
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/common/fsl_sdmmc_spec.h
  4. 0 41
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/ChangeLogKSDK.txt
  5. 0 238
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/blocking/fsl_sdmmc_host.c
  6. 0 405
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/fsl_sdmmc_host.h
  7. 0 457
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/non_blocking/fsl_sdmmc_host.c
  8. 0 113
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/mmc/ChangeLogKSDK.txt
  9. 0 2998
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/mmc/fsl_mmc.c
  10. 0 445
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/mmc/fsl_mmc.h
  11. 0 275
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/osa/fsl_sdmmc_osa.c
  12. 0 170
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/osa/fsl_sdmmc_osa.h
  13. 0 123
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sd/ChangeLogKSDK.txt
  14. 0 2290
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sd/fsl_sd.c
  15. 0 349
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sd/fsl_sd.h
  16. 0 98
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sdio/ChangeLogKSDK.txt
  17. 0 2109
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sdio/fsl_sdio.c
  18. 0 529
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sdio/fsl_sdio.h
  19. 0 58
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdhc/sdmmc_config.c
  20. 0 101
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdhc/sdmmc_config.h
  21. 0 115
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdif/sdmmc_config.c
  22. 0 92
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdif/sdmmc_config.h
  23. 0 149
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/usdhc/sdmmc_config.c
  24. 0 115
      bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/usdhc/sdmmc_config.h
  25. 1 1
      bsp/lpc55sxx/Libraries/drivers/SConscript
  26. 0 265
      bsp/lpc55sxx/Libraries/drivers/drv_sd.c
  27. 0 29
      bsp/lpc55sxx/Libraries/drivers/drv_sd.h
  28. 326 0
      bsp/lpc55sxx/Libraries/drivers/drv_sdif.c
  29. 50 8
      bsp/lpc55sxx/lpc55s69_nxp_evk/.config
  30. 0 2
      bsp/lpc55sxx/lpc55s69_nxp_evk/applications/SConscript
  31. 14 1
      bsp/lpc55sxx/lpc55s69_nxp_evk/applications/main.c
  32. 0 32
      bsp/lpc55sxx/lpc55s69_nxp_evk/applications/mnt.c
  33. 0 110
      bsp/lpc55sxx/lpc55s69_nxp_evk/applications/tfm_ps.c
  34. 1 1
      bsp/lpc55sxx/lpc55s69_nxp_evk/project.ewd
  35. 1494 1426
      bsp/lpc55sxx/lpc55s69_nxp_evk/project.ewp
  36. 378 134
      bsp/lpc55sxx/lpc55s69_nxp_evk/project.uvoptx
  37. 106 10
      bsp/lpc55sxx/lpc55s69_nxp_evk/project.uvprojx
  38. 32 2
      bsp/lpc55sxx/lpc55s69_nxp_evk/rtconfig.h

+ 0 - 166
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/common/fsl_sdmmc_common.c

@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "fsl_sdmmc_common.h"
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-#if SDMMCHOST_SUPPORT_DDR50 || SDMMCHOST_SUPPORT_SDR104 || SDMMCHOST_SUPPORT_SDR50 || SDMMCHOST_SUPPORT_HS200 || \
-    SDMMCHOST_SUPPORT_HS400
-/* sdmmc tuning block */
-const uint32_t SDMMC_TuningBlockPattern4Bit[16U] = {
-    0xFF0FFF00U, 0xFFCCC3CCU, 0xC33CCCFFU, 0xFEFFFEEFU, 0xFFDFFFDDU, 0xFFFBFFFBU, 0xBFFF7FFFU, 0x77F7BDEFU,
-    0xFFF0FFF0U, 0x0FFCCC3CU, 0xCC33CCCFU, 0xFFEFFFEEU, 0xFFFDFFFDU, 0xDFFFBFFFU, 0xBBFFF7FFU, 0xF77F7BDEU,
-};
-const uint32_t SDMMC_TuningBlockPattern8Bit[32U] = {
-    0xffff00ffU, 0xffff0000U, 0xffffccccU, 0xcc33ccccU, 0xcc3333ccU, 0xccccffffU, 0xffeeffffU, 0xffeeeeffU,
-    0xffffddffU, 0xffffddddU, 0xffffffbbU, 0xffffffbbU, 0xbbffffffU, 0x77ffffffU, 0x7777ff77U, 0xbbddeeffU,
-    0xffffff00U, 0xffffff00U, 0x00ffffccU, 0xcccc33ccU, 0xcccc3333U, 0xccccccffU, 0xffffeeffU, 0xffffeeeeU,
-    0xffffffddU, 0xffffffddU, 0xddffffffU, 0xbbffffffU, 0xbbbbffffU, 0xff77ffffU, 0xff7777ffU, 0x77bbddeeU,
-};
-#endif
-/*******************************************************************************
- * Code
- ******************************************************************************/
-status_t SDMMC_SelectCard(sdmmchost_t *host, uint32_t relativeAddress, bool isSelected)
-{
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index = (uint32_t)kSDMMC_SelectCard;
-    if (isSelected)
-    {
-        command.argument     = relativeAddress << 16U;
-        command.responseType = kCARD_ResponseTypeR1;
-    }
-    else
-    {
-        command.argument     = 0U;
-        command.responseType = kCARD_ResponseTypeNone;
-    }
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(host, &content);
-    if ((kStatus_Success != error) || ((command.response[0U] & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* Wait until card to transfer state */
-    return kStatus_Success;
-}
-
-status_t SDMMC_SendApplicationCommand(sdmmchost_t *host, uint32_t relativeAddress)
-{
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDMMC_ApplicationCommand;
-    command.argument     = (relativeAddress << 16U);
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(host, &content);
-    if ((kStatus_Success != error) || ((command.response[0U] & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    if (0U == (command.response[0U] & SDMMC_MASK(kSDMMC_R1ApplicationCommandFlag)))
-    {
-        return kStatus_SDMMC_CardNotSupport;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDMMC_SetBlockCount(sdmmchost_t *host, uint32_t blockCount)
-{
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDMMC_SetBlockCount;
-    command.argument     = blockCount;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(host, &content);
-    if ((kStatus_Success != error) || ((command.response[0U] & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDMMC_GoIdle(sdmmchost_t *host)
-{
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index = (uint32_t)kSDMMC_GoIdleState;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(host, &content);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDMMC_SetBlockSize(sdmmchost_t *host, uint32_t blockSize)
-{
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDMMC_SetBlockLength;
-    command.argument     = blockSize;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(host, &content);
-    if ((kStatus_Success != error) || ((command.response[0U] & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDMMC_SetCardInactive(sdmmchost_t *host)
-{
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDMMC_GoInactiveState;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeNone;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(host, &content);
-    if ((kStatus_Success != error))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}

+ 0 - 366
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/common/fsl_sdmmc_common.h

@@ -1,366 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _FSL_SDMMC_COMMON_H_
-#define _FSL_SDMMC_COMMON_H_
-
-#include "fsl_common.h"
-#include "fsl_sdmmc_host.h"
-#include "fsl_sdmmc_spec.h"
-#include "stdlib.h"
-
-/*!
- * @addtogroup sdmmc_common SDMMC Common
- * @ingroup card
- * @{
- */
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-
-/*! @brief Reverse byte sequence in uint32_t */
-#define SWAP_WORD_BYTE_SEQUENCE(x) (__REV(x))
-/*! @brief Reverse byte sequence for each half word in uint32_t */
-#define SWAP_HALF_WROD_BYTE_SEQUENCE(x) (__REV16(x))
-/*! @brief Maximum loop count to check the card operation voltage range */
-#define FSL_SDMMC_MAX_VOLTAGE_RETRIES (1000U)
-/*! @brief Maximum loop count to send the cmd */
-#define FSL_SDMMC_MAX_CMD_RETRIES (10U)
-/*! @brief Default block size */
-#define FSL_SDMMC_DEFAULT_BLOCK_SIZE (512U)
-
-/*! @brief make sure the internal buffer address is cache align */
-#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
-#if defined(FSL_FEATURE_L2DCACHE_LINESIZE_BYTE)
-#define SDMMC_DATA_BUFFER_ALIGN_CACHE MAX(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE, FSL_FEATURE_L2DCACHE_LINESIZE_BYTE)
-#else
-#define SDMMC_DATA_BUFFER_ALIGN_CACHE FSL_FEATURE_L1DCACHE_LINESIZE_BYTE
-#endif
-#else
-#define SDMMC_DATA_BUFFER_ALIGN_CACHE sizeof(uint32_t)
-#endif
-
-/*! @brief sdmmc card internal buffer size */
-#define FSL_SDMMC_CARD_INTERNAL_BUFFER_SIZE (FSL_SDMMC_DEFAULT_BLOCK_SIZE + SDMMC_DATA_BUFFER_ALIGN_CACHE)
-#define FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(buffer)                     \
-    (uint32_t)((uint32_t)(buffer) + (uint32_t)SDMMC_DATA_BUFFER_ALIGN_CACHE - \
-               ((uint32_t)(buffer) & ((uint32_t)SDMMC_DATA_BUFFER_ALIGN_CACHE - 1U)))
-/*! @brief get maximum freq */
-#define FSL_SDMMC_CARD_MAX_BUS_FREQ(max, target) ((max) == 0U ? (target) : ((max) > (target) ? (target) : (max)))
-/*! @brief SD/MMC error log. */
-#if defined SDMMC_ENABLE_LOG_PRINT
-#include "fsl_debug_console.h"
-#define SDMMC_LOG(...) PRINTF(__VA_ARGS__)
-#else
-#define SDMMC_LOG(format, ...)
-#endif
-
-/*! @brief SD/MMC card API's running status.
- *  @anchor _sdmmc_status
- */
-enum
-{
-    kStatus_SDMMC_NotSupportYet             = MAKE_STATUS(kStatusGroup_SDMMC, 0U),  /*!< Haven't supported */
-    kStatus_SDMMC_TransferFailed            = MAKE_STATUS(kStatusGroup_SDMMC, 1U),  /*!< Send command failed */
-    kStatus_SDMMC_SetCardBlockSizeFailed    = MAKE_STATUS(kStatusGroup_SDMMC, 2U),  /*!< Set block size failed */
-    kStatus_SDMMC_HostNotSupport            = MAKE_STATUS(kStatusGroup_SDMMC, 3U),  /*!< Host doesn't support */
-    kStatus_SDMMC_CardNotSupport            = MAKE_STATUS(kStatusGroup_SDMMC, 4U),  /*!< Card doesn't support */
-    kStatus_SDMMC_AllSendCidFailed          = MAKE_STATUS(kStatusGroup_SDMMC, 5U),  /*!< Send CID failed */
-    kStatus_SDMMC_SendRelativeAddressFailed = MAKE_STATUS(kStatusGroup_SDMMC, 6U),  /*!< Send relative address failed */
-    kStatus_SDMMC_SendCsdFailed             = MAKE_STATUS(kStatusGroup_SDMMC, 7U),  /*!< Send CSD failed */
-    kStatus_SDMMC_SelectCardFailed          = MAKE_STATUS(kStatusGroup_SDMMC, 8U),  /*!< Select card failed */
-    kStatus_SDMMC_SendScrFailed             = MAKE_STATUS(kStatusGroup_SDMMC, 9U),  /*!< Send SCR failed */
-    kStatus_SDMMC_SetDataBusWidthFailed     = MAKE_STATUS(kStatusGroup_SDMMC, 10U), /*!< Set bus width failed */
-    kStatus_SDMMC_GoIdleFailed              = MAKE_STATUS(kStatusGroup_SDMMC, 11U), /*!< Go idle failed */
-    kStatus_SDMMC_HandShakeOperationConditionFailed =
-        MAKE_STATUS(kStatusGroup_SDMMC, 12U), /*!< Send Operation Condition failed */
-    kStatus_SDMMC_SendApplicationCommandFailed =
-        MAKE_STATUS(kStatusGroup_SDMMC, 13U), /*!< Send application command failed */
-    kStatus_SDMMC_SwitchFailed               = MAKE_STATUS(kStatusGroup_SDMMC, 14U), /*!< Switch command failed */
-    kStatus_SDMMC_StopTransmissionFailed     = MAKE_STATUS(kStatusGroup_SDMMC, 15U), /*!< Stop transmission failed */
-    kStatus_SDMMC_WaitWriteCompleteFailed    = MAKE_STATUS(kStatusGroup_SDMMC, 16U), /*!< Wait write complete failed */
-    kStatus_SDMMC_SetBlockCountFailed        = MAKE_STATUS(kStatusGroup_SDMMC, 17U), /*!< Set block count failed */
-    kStatus_SDMMC_SetRelativeAddressFailed   = MAKE_STATUS(kStatusGroup_SDMMC, 18U), /*!< Set relative address failed */
-    kStatus_SDMMC_SwitchBusTimingFailed      = MAKE_STATUS(kStatusGroup_SDMMC, 19U), /*!< Switch high speed failed */
-    kStatus_SDMMC_SendExtendedCsdFailed      = MAKE_STATUS(kStatusGroup_SDMMC, 20U), /*!< Send EXT_CSD failed */
-    kStatus_SDMMC_ConfigureBootFailed        = MAKE_STATUS(kStatusGroup_SDMMC, 21U), /*!< Configure boot failed */
-    kStatus_SDMMC_ConfigureExtendedCsdFailed = MAKE_STATUS(kStatusGroup_SDMMC, 22U), /*!< Configure EXT_CSD failed */
-    kStatus_SDMMC_EnableHighCapacityEraseFailed =
-        MAKE_STATUS(kStatusGroup_SDMMC, 23U), /*!< Enable high capacity erase failed */
-    kStatus_SDMMC_SendTestPatternFailed    = MAKE_STATUS(kStatusGroup_SDMMC, 24U), /*!< Send test pattern failed */
-    kStatus_SDMMC_ReceiveTestPatternFailed = MAKE_STATUS(kStatusGroup_SDMMC, 25U), /*!< Receive test pattern failed */
-    kStatus_SDMMC_SDIO_ResponseError       = MAKE_STATUS(kStatusGroup_SDMMC, 26U), /*!< sdio response error */
-    kStatus_SDMMC_SDIO_InvalidArgument =
-        MAKE_STATUS(kStatusGroup_SDMMC, 27U), /*!< sdio invalid argument response error */
-    kStatus_SDMMC_SDIO_SendOperationConditionFail =
-        MAKE_STATUS(kStatusGroup_SDMMC, 28U), /*!< sdio send operation condition fail */
-    kStatus_SDMMC_InvalidVoltage           = MAKE_STATUS(kStatusGroup_SDMMC, 29U), /*!<  invaild voltage */
-    kStatus_SDMMC_SDIO_SwitchHighSpeedFail = MAKE_STATUS(kStatusGroup_SDMMC, 30U), /*!<  switch to high speed fail */
-    kStatus_SDMMC_SDIO_ReadCISFail         = MAKE_STATUS(kStatusGroup_SDMMC, 31U), /*!<  read CIS fail */
-    kStatus_SDMMC_SDIO_InvalidCard         = MAKE_STATUS(kStatusGroup_SDMMC, 32U), /*!<  invaild SDIO card */
-    kStatus_SDMMC_TuningFail               = MAKE_STATUS(kStatusGroup_SDMMC, 33U), /*!<  tuning fail */
-
-    kStatus_SDMMC_SwitchVoltageFail              = MAKE_STATUS(kStatusGroup_SDMMC, 34U), /*!< switch voltage fail*/
-    kStatus_SDMMC_SwitchVoltage18VFail33VSuccess = MAKE_STATUS(kStatusGroup_SDMMC, 35U), /*!< switch voltage fail*/
-
-    kStatus_SDMMC_ReTuningRequest       = MAKE_STATUS(kStatusGroup_SDMMC, 36U), /*!<  retuning request */
-    kStatus_SDMMC_SetDriverStrengthFail = MAKE_STATUS(kStatusGroup_SDMMC, 37U), /*!<  set driver strength fail */
-    kStatus_SDMMC_SetPowerClassFail     = MAKE_STATUS(kStatusGroup_SDMMC, 38U), /*!<  set power class fail */
-    kStatus_SDMMC_HostNotReady          = MAKE_STATUS(kStatusGroup_SDMMC, 39U), /*!<  host controller not ready */
-    kStatus_SDMMC_CardDetectFailed      = MAKE_STATUS(kStatusGroup_SDMMC, 40U), /*!<  card detect failed */
-    kStatus_SDMMC_AuSizeNotSetProperly  = MAKE_STATUS(kStatusGroup_SDMMC, 41U), /*!<  AU size not set properly */
-    kStatus_SDMMC_PollingCardIdleFailed = MAKE_STATUS(kStatusGroup_SDMMC, 42U), /*!< polling card idle status failed */
-    kStatus_SDMMC_DeselectCardFailed    = MAKE_STATUS(kStatusGroup_SDMMC, 43U), /*!< deselect card failed */
-    kStatus_SDMMC_CardStatusIdle        = MAKE_STATUS(kStatusGroup_SDMMC, 44U), /*!< card idle  */
-    kStatus_SDMMC_CardStatusBusy        = MAKE_STATUS(kStatusGroup_SDMMC, 45U), /*!< card busy */
-    kStatus_SDMMC_CardInitFailed        = MAKE_STATUS(kStatusGroup_SDMMC, 46U), /*!< card init failed */
-};
-
-/*! @brief sdmmc signal line
- * @anchor _sdmmc_signal_line
- */
-enum
-{
-    kSDMMC_SignalLineCmd   = 1U,   /*!< cmd line */
-    kSDMMC_SignalLineData0 = 2U,   /*!< data line */
-    kSDMMC_SignalLineData1 = 4U,   /*!< data line */
-    kSDMMC_SignalLineData2 = 8U,   /*!< data line */
-    kSDMMC_SignalLineData3 = 16U,  /*!< data line */
-    kSDMMC_SignalLineData4 = 32U,  /*!< data line */
-    kSDMMC_SignalLineData5 = 64U,  /*!< data line */
-    kSDMMC_SignalLineData6 = 128U, /*!< data line */
-    kSDMMC_SignalLineData7 = 256U, /*!< data line */
-};
-
-/*! @brief card operation voltage */
-typedef enum _sdmmc_operation_voltage
-{
-    kSDMMC_OperationVoltageNone = 0U, /*!< indicate current voltage setting is not setting by suser*/
-    kSDMMC_OperationVoltage330V = 1U, /*!< card operation voltage around 3.3v */
-    kSDMMC_OperationVoltage300V = 2U, /*!< card operation voltage around 3.0v */
-    kSDMMC_OperationVoltage180V = 3U, /*!< card operation voltage around 1.8v */
-} sdmmc_operation_voltage_t;
-
-/*!@brief card bus width
- * @anchor _sdmmc_bus_width
- */
-enum
-{
-    kSDMMC_BusWdith1Bit = 0U, /*!< card bus 1 width */
-    kSDMMC_BusWdith4Bit = 1U, /*!< card bus 4 width */
-    kSDMMC_BusWdith8Bit = 2U, /*!< card bus 8 width */
-};
-
-/*!@brief sdmmc capability flag
- * @anchor _sdmmc_capability_flag
- */
-enum
-{
-    kSDMMC_Support8BitWidth = 1U, /*!< 8 bit data width capability */
-};
-
-/*!@ brief sdmmc data packet format
- * @anchor _sdmmc_data_packet_format
- */
-enum
-{
-    kSDMMC_DataPacketFormatLSBFirst, /*!< usual data packet format LSB first, MSB last */
-    kSDMMC_DataPacketFormatMSBFirst, /*!< Wide width data packet format MSB first, LSB last */
-};
-
-/*! @brief sd card detect type */
-typedef enum _sd_detect_card_type
-{
-    kSD_DetectCardByGpioCD,    /*!< sd card detect by CD pin through GPIO */
-    kSD_DetectCardByHostCD,    /*!< sd card detect by CD pin through host */
-    kSD_DetectCardByHostDATA3, /*!< sd card detect by DAT3 pin through host */
-} sd_detect_card_type_t;
-
-/*!@ brief SD card detect status
- * @anchor _sd_card_cd_status
- */
-enum
-{
-    kSD_Inserted = 1U, /*!< card is inserted*/
-    kSD_Removed  = 0U, /*!< card is removed */
-};
-
-/*!@ brief SD card detect status
- * @anchor _sd_card_dat3_pull_status
- */
-enum
-{
-    kSD_DAT3PullDown = 0U, /*!< data3 pull down */
-    kSD_DAT3PullUp   = 1U, /*!< data3 pull up */
-};
-
-/*! @brief card detect aoolication callback definition */
-typedef void (*sd_cd_t)(bool isInserted, void *userData);
-/*! @brief card detect status */
-typedef bool (*sd_cd_status_t)(void);
-typedef void (*sd_dat3_pull_t)(uint32_t pullStatus);
-
-/*! @brief sd card detect */
-typedef struct _sd_detect_card
-{
-    sd_detect_card_type_t type;  /*!< card detect type */
-    uint32_t cdDebounce_ms;      /*!< card detect debounce delay ms */
-    sd_cd_t callback;            /*!< card inserted callback which is meaningful for interrupt case */
-    sd_cd_status_t cardDetected; /*!< used to check sd cd status when card detect through GPIO */
-    sd_dat3_pull_t dat3PullFunc; /*!< function pointer of DATA3 pull up/down */
-
-    void *userData; /*!< user data */
-} sd_detect_card_t;
-
-/*!@brief io voltage control type*/
-typedef enum _sd_io_voltage_ctrl_type
-{
-    kSD_IOVoltageCtrlNotSupport = 0U, /*!< io voltage control not support */
-    kSD_IOVoltageCtrlByHost     = 1U, /*!< io voltage control by host */
-    kSD_IOVoltageCtrlByGpio     = 2U, /*!< io voltage control by gpio */
-} sd_io_voltage_ctrl_type_t;
-
-/*! @brief card switch voltage function pointer */
-typedef void (*sd_io_voltage_func_t)(sdmmc_operation_voltage_t voltage);
-
-/*!@brief io voltage control configuration */
-typedef struct _sd_io_voltage
-{
-    sd_io_voltage_ctrl_type_t type; /*!< io voltage switch type */
-    sd_io_voltage_func_t func;      /*!< io voltage switch function */
-} sd_io_voltage_t;
-
-/*! @brief card power control function pointer */
-typedef void (*sd_pwr_t)(bool enable);
-/*! @brief card io strength control */
-typedef void (*sd_io_strength_t)(uint32_t busFreq);
-/*! @brief sdcard user parameter */
-typedef struct _sd_usr_param
-{
-    sd_pwr_t pwr;             /*!< power control configuration pointer */
-    uint32_t powerOnDelayMS;  /*!< power on delay time */
-    uint32_t powerOffDelayMS; /*!< power off delay time */
-
-    sd_io_strength_t ioStrength; /*!< swicth sd io strength */
-    sd_io_voltage_t *ioVoltage;  /*!< switch io voltage */
-    sd_detect_card_t *cd;        /*!< card detect */
-
-    uint32_t maxFreq;    /*!< board support maximum frequency */
-    uint32_t capability; /*!< board capability flag */
-} sd_usr_param_t;
-
-/*! @brief card interrupt function pointer */
-typedef void (*sdio_int_t)(void *userData);
-
-/*! @brief card interrupt application callback */
-typedef struct _sdio_card_int
-{
-    void *userData;           /*!< user data */
-    sdio_int_t cardInterrupt; /*!< card int call back */
-} sdio_card_int_t;
-
-/*! @brief sdio user parameter */
-typedef struct _sdio_usr_param
-{
-    sd_pwr_t pwr;             /*!< power control configuration pointer */
-    uint32_t powerOnDelayMS;  /*!< power on delay time */
-    uint32_t powerOffDelayMS; /*!< power off delay time */
-
-    sd_io_strength_t ioStrength; /*!< swicth sd io strength */
-    sd_io_voltage_t *ioVoltage;  /*!< switch io voltage */
-    sd_detect_card_t *cd;        /*!< card detect */
-    sdio_card_int_t *sdioInt;    /*!< card int */
-    uint32_t maxFreq;            /*!< board support maximum frequency */
-    uint32_t capability;         /*!< board capability flag */
-} sdio_usr_param_t;
-
-/*! @brief tuning pattern */
-#if SDMMCHOST_SUPPORT_DDR50 || SDMMCHOST_SUPPORT_SDR104 || SDMMCHOST_SUPPORT_SDR50 || SDMMCHOST_SUPPORT_HS200 || \
-    SDMMCHOST_SUPPORT_HS400
-/* sdmmc tuning block */
-extern const uint32_t SDMMC_TuningBlockPattern4Bit[16U];
-extern const uint32_t SDMMC_TuningBlockPattern8Bit[32U];
-#endif
-
-/*************************************************************************************************
- * API
- ************************************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-/*!
- * @name common function
- * @{
- */
-
-/*!
- * @brief Selects the card to put it into transfer state.
- *
- * @param host host handler.
- * @param relativeAddress Relative address.
- * @param isSelected True to put card into transfer state.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-status_t SDMMC_SelectCard(sdmmchost_t *host, uint32_t relativeAddress, bool isSelected);
-
-/*!
- * @brief Sends an application command.
- *
- * @param host host handler.
- * @param relativeAddress Card relative address.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support.
- * @retval kStatus_Success Operate successfully.
- */
-status_t SDMMC_SendApplicationCommand(sdmmchost_t *host, uint32_t relativeAddress);
-
-/*!
- * @brief Sets the block count.
- *
- * @param host host handler.
- * @param blockCount Block count.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-status_t SDMMC_SetBlockCount(sdmmchost_t *host, uint32_t blockCount);
-
-/*!
- * @brief Sets the card to be idle state.
- *
- * @param host host handler.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-status_t SDMMC_GoIdle(sdmmchost_t *host);
-/*!
- * @brief Sets data block size.
- *
- * @param host host handler.
- * @param blockSize Block size.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-status_t SDMMC_SetBlockSize(sdmmchost_t *host, uint32_t blockSize);
-/*!
- * @brief Sets card to inactive status
- *
- * @param host host handler.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-status_t SDMMC_SetCardInactive(sdmmchost_t *host);
-
-/* @} */
-
-#if defined(__cplusplus)
-}
-#endif
-/* @} */
-#endif /* _FSL_SDMMC_COMMON_H_ */

+ 0 - 1262
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/common/fsl_sdmmc_spec.h

@@ -1,1262 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _FSL_SDMMC_SPEC_H_
-#define _FSL_SDMMC_SPEC_H_
-
-#include <stdint.h>
-
-/*!
- * @addtogroup sdmmc_common SDMMC Common
- * @ingroup card
- * @{
- */
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*! @brief SD/MMC card initialization clock frequency */
-#define SDMMC_CLOCK_400KHZ (400000U)
-/*! @brief SD card bus frequency 1 in high-speed mode */
-#define SD_CLOCK_25MHZ (25000000U)
-/*! @brief SD card bus frequency 2 in high-speed mode */
-#define SD_CLOCK_50MHZ (50000000U)
-/*! @brief SD card bus frequency in SDR50 mode */
-#define SD_CLOCK_100MHZ (100000000U)
-/*! @brief SD card bus frequency in SDR104 mode */
-#define SD_CLOCK_208MHZ (208000000U)
-/*! @brief MMC card bus frequency 1 in high-speed mode */
-#define MMC_CLOCK_26MHZ (26000000U)
-/*! @brief MMC card bus frequency 2 in high-speed mode */
-#define MMC_CLOCK_52MHZ (52000000U)
-/*! @brief MMC card bus frequency  in high-speed DDR52 mode */
-#define MMC_CLOCK_DDR52 (52000000U)
-/*! @brief MMC card bus frequency  in high-speed HS200 mode */
-#define MMC_CLOCK_HS200 (200000000U)
-/*! @brief MMC card bus frequency  in high-speed HS400 mode */
-#define MMC_CLOCK_HS400 (400000000U)
-
-/*!@brief mask convert  */
-#define SDMMC_MASK(bit) (1UL << (bit))
-
-/*! @brief Card status bit in R1
- * @anchor _sdmmc_r1_card_status_flag
- */
-enum
-{
-    kSDMMC_R1OutOfRangeFlag                  = 31, /*!< Out of range status bit */
-    kSDMMC_R1AddressErrorFlag                = 30, /*!< Address error status bit */
-    kSDMMC_R1BlockLengthErrorFlag            = 29, /*!< Block length error status bit */
-    kSDMMC_R1EraseSequenceErrorFlag          = 28, /*!< Erase sequence error status bit */
-    kSDMMC_R1EraseParameterErrorFlag         = 27, /*!< Erase parameter error status bit */
-    kSDMMC_R1WriteProtectViolationFlag       = 26, /*!< Write protection violation status bit */
-    kSDMMC_R1CardIsLockedFlag                = 25, /*!< Card locked status bit */
-    kSDMMC_R1LockUnlockFailedFlag            = 24, /*!< lock/unlock error status bit */
-    kSDMMC_R1CommandCrcErrorFlag             = 23, /*!< CRC error status bit */
-    kSDMMC_R1IllegalCommandFlag              = 22, /*!< Illegal command status bit */
-    kSDMMC_R1CardEccFailedFlag               = 21, /*!< Card ecc error status bit */
-    kSDMMC_R1CardControllerErrorFlag         = 20, /*!< Internal card controller error status bit */
-    kSDMMC_R1ErrorFlag                       = 19, /*!< A general or an unknown error status bit */
-    kSDMMC_R1CidCsdOverwriteFlag             = 16, /*!< Cid/csd overwrite status bit */
-    kSDMMC_R1WriteProtectEraseSkipFlag       = 15, /*!< Write protection erase skip status bit */
-    kSDMMC_R1CardEccDisabledFlag             = 14, /*!< Card ecc disabled status bit */
-    kSDMMC_R1EraseResetFlag                  = 13, /*!< Erase reset status bit */
-    kSDMMC_R1ReadyForDataFlag                = 8,  /*!< Ready for data status bit */
-    kSDMMC_R1SwitchErrorFlag                 = 7,  /*!< Switch error status bit */
-    kSDMMC_R1ApplicationCommandFlag          = 5,  /*!< Application command enabled status bit */
-    kSDMMC_R1AuthenticationSequenceErrorFlag = 3,  /*!< error in the sequence of authentication process */
-};
-
-/*! @brief R1 all the error flag */
-#define SDMMC_R1_ALL_ERROR_FLAG                                                                      \
-    (SDMMC_MASK(kSDMMC_R1OutOfRangeFlag) | SDMMC_MASK(kSDMMC_R1AddressErrorFlag) |                   \
-     SDMMC_MASK(kSDMMC_R1BlockLengthErrorFlag) | SDMMC_MASK(kSDMMC_R1EraseSequenceErrorFlag) |       \
-     SDMMC_MASK(kSDMMC_R1EraseParameterErrorFlag) | SDMMC_MASK(kSDMMC_R1WriteProtectViolationFlag) | \
-     SDMMC_MASK(kSDMMC_R1CardIsLockedFlag) | SDMMC_MASK(kSDMMC_R1LockUnlockFailedFlag) |             \
-     SDMMC_MASK(kSDMMC_R1CommandCrcErrorFlag) | SDMMC_MASK(kSDMMC_R1IllegalCommandFlag) |            \
-     SDMMC_MASK(kSDMMC_R1CardEccFailedFlag) | SDMMC_MASK(kSDMMC_R1CardControllerErrorFlag) |         \
-     SDMMC_MASK(kSDMMC_R1ErrorFlag) | SDMMC_MASK(kSDMMC_R1CidCsdOverwriteFlag) |                     \
-     SDMMC_MASK(kSDMMC_R1AuthenticationSequenceErrorFlag))
-
-/*! @brief R1: current state */
-#define SDMMC_R1_CURRENT_STATE(x) (((x)&0x00001E00U) >> 9U)
-
-/*! @brief CURRENT_STATE filed in R1 */
-typedef enum _sdmmc_r1_current_state
-{
-    kSDMMC_R1StateIdle        = 0U, /*!< R1: current state: idle */
-    kSDMMC_R1StateReady       = 1U, /*!< R1: current state: ready */
-    kSDMMC_R1StateIdentify    = 2U, /*!< R1: current state: identification */
-    kSDMMC_R1StateStandby     = 3U, /*!< R1: current state: standby */
-    kSDMMC_R1StateTransfer    = 4U, /*!< R1: current state: transfer */
-    kSDMMC_R1StateSendData    = 5U, /*!< R1: current state: sending data */
-    kSDMMC_R1StateReceiveData = 6U, /*!< R1: current state: receiving data */
-    kSDMMC_R1StateProgram     = 7U, /*!< R1: current state: programming */
-    kSDMMC_R1StateDisconnect  = 8U, /*!< R1: current state: disconnect */
-} sdmmc_r1_current_state_t;
-
-/*! @brief Error bit in SPI mode R1
- * @anchor _sdspi_r1_error_status_flag
- */
-enum
-{
-    kSDSPI_R1InIdleStateFlag        = (1U << 0U), /*!< In idle state */
-    kSDSPI_R1EraseResetFlag         = (1U << 1U), /*!< Erase reset */
-    kSDSPI_R1IllegalCommandFlag     = (1U << 2U), /*!< Illegal command */
-    kSDSPI_R1CommandCrcErrorFlag    = (1U << 3U), /*!< Com crc error */
-    kSDSPI_R1EraseSequenceErrorFlag = (1U << 4U), /*!< Erase sequence error */
-    kSDSPI_R1AddressErrorFlag       = (1U << 5U), /*!< Address error */
-    kSDSPI_R1ParameterErrorFlag     = (1U << 6U), /*!< Parameter error */
-};
-
-/*! @brief Error bit in SPI mode R2
- * @anchor _sdspi_r2_error_status_flag
- */
-enum
-{
-    kSDSPI_R2CardLockedFlag            = (1U << 0U), /*!< Card is locked */
-    kSDSPI_R2WriteProtectEraseSkip     = (1U << 1U), /*!< Write protect erase skip */
-    kSDSPI_R2LockUnlockFailed          = (1U << 1U), /*!< Lock/unlock command failed */
-    kSDSPI_R2ErrorFlag                 = (1U << 2U), /*!< Unknown error */
-    kSDSPI_R2CardControllerErrorFlag   = (1U << 3U), /*!< Card controller error */
-    kSDSPI_R2CardEccFailedFlag         = (1U << 4U), /*!< Card ecc failed */
-    kSDSPI_R2WriteProtectViolationFlag = (1U << 5U), /*!< Write protect violation */
-    kSDSPI_R2EraseParameterErrorFlag   = (1U << 6U), /*!< Erase parameter error */
-    kSDSPI_R2OutOfRangeFlag            = (1U << 7U), /*!< Out of range */
-    kSDSPI_R2CsdOverwriteFlag          = (1U << 7U), /*!< CSD overwrite */
-};
-
-/*! @brief The bit mask for COMMAND VERSION field in R7 */
-#define SDSPI_R7_VERSION_SHIFT (28U)
-/*! @brief The bit mask for COMMAND VERSION field in R7 */
-#define SDSPI_R7_VERSION_MASK (0xFU)
-/*! @brief The bit shift for VOLTAGE ACCEPTED field in R7 */
-#define SDSPI_R7_VOLTAGE_SHIFT (8U)
-/*! @brief The bit mask for VOLTAGE ACCEPTED field in R7 */
-#define SDSPI_R7_VOLTAGE_MASK (0xFU)
-/*! @brief The bit mask for VOLTAGE 2.7V to 3.6V field in R7 */
-#define SDSPI_R7_VOLTAGE_27_36_MASK (0x1U << SDSPI_R7_VOLTAGE_SHIFT)
-/*! @brief The bit shift for ECHO field in R7 */
-#define SDSPI_R7_ECHO_SHIFT (0U)
-/*! @brief The bit mask for ECHO field in R7 */
-#define SDSPI_R7_ECHO_MASK (0xFFU)
-
-/*! @brief Data error token mask */
-#define SDSPI_DATA_ERROR_TOKEN_MASK (0xFU)
-/*! @brief Data Error Token mask bit
- * @anchor _sdspi_data_error_token
- */
-enum
-{
-    kSDSPI_DataErrorTokenError               = (1U << 0U), /*!< Data error */
-    kSDSPI_DataErrorTokenCardControllerError = (1U << 1U), /*!< Card controller error */
-    kSDSPI_DataErrorTokenCardEccFailed       = (1U << 2U), /*!< Card ecc error */
-    kSDSPI_DataErrorTokenOutOfRange          = (1U << 3U), /*!< Out of range */
-};
-
-/*! @brief Data Token */
-typedef enum _sdspi_data_token
-{
-    kSDSPI_DataTokenBlockRead          = 0xFEU, /*!< Single block read, multiple block read */
-    kSDSPI_DataTokenSingleBlockWrite   = 0xFEU, /*!< Single block write */
-    kSDSPI_DataTokenMultipleBlockWrite = 0xFCU, /*!< Multiple block write */
-    kSDSPI_DataTokenStopTransfer       = 0xFDU, /*!< Stop transmission */
-} sdspi_data_token_t;
-
-/* Data Response Token mask */
-#define SDSPI_DATA_RESPONSE_TOKEN_MASK (0x1FU) /*!< Mask for data response bits */
-/*! @brief Data Response Token */
-typedef enum _sdspi_data_response_token
-{
-    kSDSPI_DataResponseTokenAccepted   = 0x05U, /*!< Data accepted */
-    kSDSPI_DataResponseTokenCrcError   = 0x0BU, /*!< Data rejected due to CRC error */
-    kSDSPI_DataResponseTokenWriteError = 0x0DU, /*!< Data rejected due to write error */
-} sdspi_data_response_token_t;
-
-/*! @brief SD card individual commands */
-typedef enum _sd_command
-{
-    kSD_SendRelativeAddress    = 3U,  /*!< Send Relative Address */
-    kSD_Switch                 = 6U,  /*!< Switch Function */
-    kSD_SendInterfaceCondition = 8U,  /*!< Send Interface Condition */
-    kSD_VoltageSwitch          = 11U, /*!< Voltage Switch */
-    kSD_SpeedClassControl      = 20U, /*!< Speed Class control */
-    kSD_EraseWriteBlockStart   = 32U, /*!< Write Block Start */
-    kSD_EraseWriteBlockEnd     = 33U, /*!< Write Block End */
-    kSD_SendTuningBlock        = 19U, /*!< Send Tuning Block */
-} sd_command_t;
-
-/*! @brief SDSPI individual commands */
-typedef enum _sdspi_command
-{
-    kSDSPI_CommandCrc = 59U, /*!< Command crc protection on/off */
-} sdspi_command_t;
-
-/*! @brief SD card individual application commands */
-typedef enum _sd_application_command
-{
-    kSD_ApplicationSetBusWdith             = 6U,  /*!< Set Bus Width */
-    kSD_ApplicationStatus                  = 13U, /*!< Send SD status */
-    kSD_ApplicationSendNumberWriteBlocks   = 22U, /*!< Send Number Of Written Blocks */
-    kSD_ApplicationSetWriteBlockEraseCount = 23U, /*!< Set Write Block Erase Count */
-    kSD_ApplicationSendOperationCondition  = 41U, /*!< Send Operation Condition */
-    kSD_ApplicationSetClearCardDetect      = 42U, /*!< Set Connnect/Disconnect pull up on detect pin */
-    kSD_ApplicationSendScr                 = 51U, /*!< Send Scr */
-} sd_application_command_t;
-
-/*! @brief SD card command class
- * @anchor _sdmmc_command_class
- */
-enum
-{
-    kSDMMC_CommandClassBasic               = (1U << 0U),  /*!< Card command class 0 */
-    kSDMMC_CommandClassBlockRead           = (1U << 2U),  /*!< Card command class 2 */
-    kSDMMC_CommandClassBlockWrite          = (1U << 4U),  /*!< Card command class 4 */
-    kSDMMC_CommandClassErase               = (1U << 5U),  /*!< Card command class 5 */
-    kSDMMC_CommandClassWriteProtect        = (1U << 6U),  /*!< Card command class 6 */
-    kSDMMC_CommandClassLockCard            = (1U << 7U),  /*!< Card command class 7 */
-    kSDMMC_CommandClassApplicationSpecific = (1U << 8U),  /*!< Card command class 8 */
-    kSDMMC_CommandClassInputOutputMode     = (1U << 9U),  /*!< Card command class 9 */
-    kSDMMC_CommandClassSwitch              = (1U << 10U), /*!< Card command class 10 */
-};
-
-/*! @brief OCR register in SD card
- * @anchor _sd_ocr_flag
- */
-enum
-{
-    kSD_OcrPowerUpBusyFlag         = 31,                             /*!< Power up busy status */
-    kSD_OcrHostCapacitySupportFlag = 30,                             /*!< Card capacity status */
-    kSD_OcrCardCapacitySupportFlag = kSD_OcrHostCapacitySupportFlag, /*!< Card capacity status */
-    kSD_OcrSwitch18RequestFlag     = 24,                             /*!< Switch to 1.8V request */
-    kSD_OcrSwitch18AcceptFlag      = kSD_OcrSwitch18RequestFlag,     /*!< Switch to 1.8V accepted */
-    kSD_OcrVdd27_28Flag            = 15,                             /*!< VDD 2.7-2.8 */
-    kSD_OcrVdd28_29Flag            = 16,                             /*!< VDD 2.8-2.9 */
-    kSD_OcrVdd29_30Flag            = 17,                             /*!< VDD 2.9-3.0 */
-    kSD_OcrVdd30_31Flag            = 18,                             /*!< VDD 2.9-3.0 */
-    kSD_OcrVdd31_32Flag            = 19,                             /*!< VDD 3.0-3.1 */
-    kSD_OcrVdd32_33Flag            = 20,                             /*!< VDD 3.1-3.2 */
-    kSD_OcrVdd33_34Flag            = 21,                             /*!< VDD 3.2-3.3 */
-    kSD_OcrVdd34_35Flag            = 22,                             /*!< VDD 3.3-3.4 */
-    kSD_OcrVdd35_36Flag            = 23,                             /*!< VDD 3.4-3.5 */
-};
-
-/*! @brief SD card specification version number
- * @anchor _sd_specification_version
- */
-enum
-{
-    kSD_SpecificationVersion1_0 = (1U << 0U), /*!< SD card version 1.0-1.01 */
-    kSD_SpecificationVersion1_1 = (1U << 1U), /*!< SD card version 1.10 */
-    kSD_SpecificationVersion2_0 = (1U << 2U), /*!< SD card version 2.00 */
-    kSD_SpecificationVersion3_0 = (1U << 3U), /*!< SD card version 3.0 */
-};
-
-/*! @brief SD card switch mode */
-typedef enum _sd_switch_mode
-{
-    kSD_SwitchCheck = 0U, /*!< SD switch mode 0: check function */
-    kSD_SwitchSet   = 1U, /*!< SD switch mode 1: set function */
-} sd_switch_mode_t;
-
-/*! @brief SD card CSD register flags
- * @anchor _sd_csd_flag
- */
-enum
-{
-    kSD_CsdReadBlockPartialFlag         = (1U << 0U),  /*!< Partial blocks for read allowed [79:79] */
-    kSD_CsdWriteBlockMisalignFlag       = (1U << 1U),  /*!< Write block misalignment [78:78] */
-    kSD_CsdReadBlockMisalignFlag        = (1U << 2U),  /*!< Read block misalignment [77:77] */
-    kSD_CsdDsrImplementedFlag           = (1U << 3U),  /*!< DSR implemented [76:76] */
-    kSD_CsdEraseBlockEnabledFlag        = (1U << 4U),  /*!< Erase single block enabled [46:46] */
-    kSD_CsdWriteProtectGroupEnabledFlag = (1U << 5U),  /*!< Write protect group enabled [31:31] */
-    kSD_CsdWriteBlockPartialFlag        = (1U << 6U),  /*!< Partial blocks for write allowed [21:21] */
-    kSD_CsdFileFormatGroupFlag          = (1U << 7U),  /*!< File format group [15:15] */
-    kSD_CsdCopyFlag                     = (1U << 8U),  /*!< Copy flag [14:14] */
-    kSD_CsdPermanentWriteProtectFlag    = (1U << 9U),  /*!< Permanent write protection [13:13] */
-    kSD_CsdTemporaryWriteProtectFlag    = (1U << 10U), /*!< Temporary write protection [12:12] */
-};
-
-/*! @brief SD card SCR register flags
- * @anchor _sd_scr_flag
- */
-enum
-{
-    kSD_ScrDataStatusAfterErase = (1U << 0U), /*!< Data status after erases [55:55] */
-    kSD_ScrSdSpecification3     = (1U << 1U), /*!< Specification version 3.00 or higher [47:47]*/
-};
-
-/*! @brief SD timing function number
- * @anchor _sd_timing_function
- */
-enum
-{
-    kSD_FunctionSDR12Deafult   = 0U, /*!< SDR12 mode & default*/
-    kSD_FunctionSDR25HighSpeed = 1U, /*!< SDR25 & high speed*/
-    kSD_FunctionSDR50          = 2U, /*!< SDR50 mode*/
-    kSD_FunctionSDR104         = 3U, /*!< SDR104 mode*/
-    kSD_FunctionDDR50          = 4U, /*!< DDR50 mode*/
-};
-
-/*! @brief SD group number
- * @anchor _sd_group_num
- */
-enum
-{
-    kSD_GroupTimingMode     = 0U, /*!< acess mode group*/
-    kSD_GroupCommandSystem  = 1U, /*!< command system group*/
-    kSD_GroupDriverStrength = 2U, /*!< driver strength group*/
-    kSD_GroupCurrentLimit   = 3U, /*!< current limit group*/
-};
-
-/*! @brief SD card timing mode flags */
-typedef enum _sd_timing_mode
-{
-    kSD_TimingSDR12DefaultMode   = 0U, /*!< Identification mode & SDR12 */
-    kSD_TimingSDR25HighSpeedMode = 1U, /*!< High speed mode & SDR25 */
-    kSD_TimingSDR50Mode          = 2U, /*!< SDR50 mode*/
-    kSD_TimingSDR104Mode         = 3U, /*!< SDR104 mode */
-    kSD_TimingDDR50Mode          = 4U, /*!< DDR50 mode */
-} sd_timing_mode_t;
-
-/*! @brief SD card driver strength */
-typedef enum _sd_driver_strength
-{
-    kSD_DriverStrengthTypeB = 0U, /*!< default driver strength*/
-    kSD_DriverStrengthTypeA = 1U, /*!< driver strength TYPE A */
-    kSD_DriverStrengthTypeC = 2U, /*!< driver strength TYPE C */
-    kSD_DriverStrengthTypeD = 3U, /*!< driver strength TYPE D */
-} sd_driver_strength_t;
-
-/*! @brief SD card current limit */
-typedef enum _sd_max_current
-{
-    kSD_CurrentLimit200MA = 0U, /*!< default current limit */
-    kSD_CurrentLimit400MA = 1U, /*!< current limit to 400MA */
-    kSD_CurrentLimit600MA = 2U, /*!< current limit to 600MA */
-    kSD_CurrentLimit800MA = 3U, /*!< current limit to 800MA */
-} sd_max_current_t;
-
-/*! @brief SD/MMC card common commands */
-typedef enum _sdmmc_command
-{
-    kSDMMC_GoIdleState        = 0U,  /*!< Go Idle State */
-    kSDMMC_AllSendCid         = 2U,  /*!< All Send CID */
-    kSDMMC_SetDsr             = 4U,  /*!< Set DSR */
-    kSDMMC_SelectCard         = 7U,  /*!< Select Card */
-    kSDMMC_SendCsd            = 9U,  /*!< Send CSD */
-    kSDMMC_SendCid            = 10U, /*!< Send CID */
-    kSDMMC_StopTransmission   = 12U, /*!< Stop Transmission */
-    kSDMMC_SendStatus         = 13U, /*!< Send Status */
-    kSDMMC_GoInactiveState    = 15U, /*!< Go Inactive State */
-    kSDMMC_SetBlockLength     = 16U, /*!< Set Block Length */
-    kSDMMC_ReadSingleBlock    = 17U, /*!< Read Single Block */
-    kSDMMC_ReadMultipleBlock  = 18U, /*!< Read Multiple Block */
-    kSDMMC_SetBlockCount      = 23U, /*!< Set Block Count */
-    kSDMMC_WriteSingleBlock   = 24U, /*!< Write Single Block */
-    kSDMMC_WriteMultipleBlock = 25U, /*!< Write Multiple Block */
-    kSDMMC_ProgramCsd         = 27U, /*!< Program CSD */
-    kSDMMC_SetWriteProtect    = 28U, /*!< Set Write Protect */
-    kSDMMC_ClearWriteProtect  = 29U, /*!< Clear Write Protect */
-    kSDMMC_SendWriteProtect   = 30U, /*!< Send Write Protect */
-    kSDMMC_Erase              = 38U, /*!< Erase */
-    kSDMMC_LockUnlock         = 42U, /*!< Lock Unlock */
-    kSDMMC_ApplicationCommand = 55U, /*!< Send Application Command */
-    kSDMMC_GeneralCommand     = 56U, /*!< General Purpose Command */
-    kSDMMC_ReadOcr            = 58U, /*!< Read OCR */
-} sdmmc_command_t;
-
-/*! @brief sdio card cccr register number */
-#define SDIO_CCCR_REG_NUMBER (0x16U)
-/*! @brief sdio IO ready timeout steps */
-#ifndef SDIO_IO_READY_TIMEOUT_UNIT
-#define SDIO_IO_READY_TIMEOUT_UNIT (10U)
-#endif
-/*! @brief sdio card cccr register addr
- * @anchor _sdio_cccr_reg
- */
-enum
-{
-    kSDIO_RegCCCRSdioVer        = 0x00U, /*!< CCCR & SDIO version*/
-    kSDIO_RegSDVersion          = 0x01U, /*!< SD version */
-    kSDIO_RegIOEnable           = 0x02U, /*!< io enable register */
-    kSDIO_RegIOReady            = 0x03U, /*!< io ready register */
-    kSDIO_RegIOIntEnable        = 0x04U, /*!< io interrupt enable register */
-    kSDIO_RegIOIntPending       = 0x05U, /*!< io interrupt pending register */
-    kSDIO_RegIOAbort            = 0x06U, /*!< io abort register */
-    kSDIO_RegBusInterface       = 0x07U, /*!< bus interface register */
-    kSDIO_RegCardCapability     = 0x08U, /*!< card capability register */
-    kSDIO_RegCommonCISPointer   = 0x09U, /*!< common CIS pointer register */
-    kSDIO_RegBusSuspend         = 0x0C,  /*!< bus suspend register */
-    kSDIO_RegFunctionSelect     = 0x0DU, /*!< function select register */
-    kSDIO_RegExecutionFlag      = 0x0EU, /*!< execution flag register */
-    kSDIO_RegReadyFlag          = 0x0FU, /*!< ready flag register */
-    kSDIO_RegFN0BlockSizeLow    = 0x10U, /*!< FN0 block size register */
-    kSDIO_RegFN0BlockSizeHigh   = 0x11U, /*!< FN0 block size register */
-    kSDIO_RegPowerControl       = 0x12U, /*!< power control register */
-    kSDIO_RegBusSpeed           = 0x13U, /*!< bus speed register */
-    kSDIO_RegUHSITimingSupport  = 0x14U, /*!< UHS-I timing support register */
-    kSDIO_RegDriverStrength     = 0x15U, /*!< Driver strength register */
-    kSDIO_RegInterruptExtension = 0x16U, /*!< Interrupt extension register */
-};
-
-/*! @brief sdio card individual commands */
-typedef enum _sdio_command
-{
-    kSDIO_SendRelativeAddress    = 3U,  /*!< send relative address */
-    kSDIO_SendOperationCondition = 5U,  /*!< send operation condition */
-    kSDIO_SendInterfaceCondition = 8U,  /*!< send interface condition */
-    kSDIO_RWIODirect             = 52U, /*!< read/write IO direct command */
-    kSDIO_RWIOExtended           = 53U, /*!< read/write IO extended command */
-} sdio_command_t;
-
-/*! @brief sdio card individual commands */
-typedef enum _sdio_func_num
-{
-    kSDIO_FunctionNum0,   /*!< sdio function0*/
-    kSDIO_FunctionNum1,   /*!< sdio function1*/
-    kSDIO_FunctionNum2,   /*!< sdio function2*/
-    kSDIO_FunctionNum3,   /*!< sdio function3*/
-    kSDIO_FunctionNum4,   /*!< sdio function4*/
-    kSDIO_FunctionNum5,   /*!< sdio function5*/
-    kSDIO_FunctionNum6,   /*!< sdio function6*/
-    kSDIO_FunctionNum7,   /*!< sdio function7*/
-    kSDIO_FunctionMemory, /*!< for combo card*/
-} sdio_func_num_t;
-
-#define SDIO_CMD_ARGUMENT_RW_POS         (31U)      /*!< read/write flag position */
-#define SDIO_CMD_ARGUMENT_FUNC_NUM_POS   (28U)      /*!< function number position */
-#define SDIO_DIRECT_CMD_ARGUMENT_RAW_POS (27U)      /*!< direct raw flag position */
-#define SDIO_CMD_ARGUMENT_REG_ADDR_POS   (9U)       /*!< direct reg addr position */
-#define SDIO_CMD_ARGUMENT_REG_ADDR_MASK  (0x1FFFFU) /*!< direct reg addr mask */
-#define SDIO_DIRECT_CMD_DATA_MASK        (0xFFU)    /*!< data mask */
-
-#define SDIO_EXTEND_CMD_ARGUMENT_BLOCK_MODE_POS (27U)         /*!< extended command argument block mode bit position */
-#define SDIO_EXTEND_CMD_ARGUMENT_OP_CODE_POS    (26U)         /*!< extended command argument OP Code bit position */
-#define SDIO_EXTEND_CMD_BLOCK_MODE_MASK         (0x08000000U) /*!< block mode mask */
-#define SDIO_EXTEND_CMD_OP_CODE_MASK            (0x04000000U) /*!< op code mask */
-#define SDIO_EXTEND_CMD_COUNT_MASK              (0x1FFU)      /*!< byte/block count mask */
-#define SDIO_MAX_BLOCK_SIZE                     (2048U)       /*!< max block size */
-#define SDIO_FBR_BASE(x)                        ((x)*0x100U)  /*!< function basic register */
-#define SDIO_TPL_CODE_END                       (0xFFU)       /*!< tuple end */
-#define SDIO_TPL_CODE_MANIFID                   (0x20U)       /*!< manufacturer ID */
-#define SDIO_TPL_CODE_FUNCID                    (0x21U)       /*!< function ID */
-#define SDIO_TPL_CODE_FUNCE                     (0x22U)       /*!< function extension tuple*/
-/*! @brief sdio command response flag
- * @anchor _sdio_status_flag
- */
-enum
-{
-    kSDIO_StatusCmdCRCError      = 0x8000U, /*!< the CRC check of the previous cmd fail*/
-    kSDIO_StatusIllegalCmd       = 0x4000U, /*!< cmd illegal for the card state */
-    kSDIO_StatusR6Error          = 0x2000U, /*!< special for R6 error status */
-    kSDIO_StatusError            = 0x0800U, /*!< A general or an unknown error occurred */
-    kSDIO_StatusFunctionNumError = 0x0200U, /*!< invail function error */
-    kSDIO_StatusOutofRange       = 0x0100U, /*!<  cmd argument was out of the allowed range*/
-};
-
-/*! @brief sdio operation condition flag
- * @anchor _sdio_ocr_flag
- */
-enum
-{
-    kSDIO_OcrPowerUpBusyFlag = 31, /*!< Power up busy status */
-    kSDIO_OcrIONumber        = 28, /*!< number of IO function */
-    kSDIO_OcrMemPresent      = 27, /*!< memory present flag */
-
-    kSDIO_OcrVdd20_21Flag = 8,  /*!< VDD 2.0-2.1 */
-    kSDIO_OcrVdd21_22Flag = 9,  /*!< VDD 2.1-2.2 */
-    kSDIO_OcrVdd22_23Flag = 10, /*!< VDD 2.2-2.3 */
-    kSDIO_OcrVdd23_24Flag = 11, /*!< VDD 2.3-2.4 */
-    kSDIO_OcrVdd24_25Flag = 12, /*!< VDD 2.4-2.5 */
-    kSDIO_OcrVdd25_26Flag = 13, /*!< VDD 2.5-2.6 */
-    kSDIO_OcrVdd26_27Flag = 14, /*!< VDD 2.6-2.7 */
-    kSDIO_OcrVdd27_28Flag = 15, /*!< VDD 2.7-2.8 */
-    kSDIO_OcrVdd28_29Flag = 16, /*!< VDD 2.8-2.9 */
-    kSDIO_OcrVdd29_30Flag = 17, /*!< VDD 2.9-3.0 */
-    kSDIO_OcrVdd30_31Flag = 18, /*!< VDD 2.9-3.0 */
-    kSDIO_OcrVdd31_32Flag = 19, /*!< VDD 3.0-3.1 */
-    kSDIO_OcrVdd32_33Flag = 20, /*!< VDD 3.1-3.2 */
-    kSDIO_OcrVdd33_34Flag = 21, /*!< VDD 3.2-3.3 */
-    kSDIO_OcrVdd34_35Flag = 22, /*!< VDD 3.3-3.4 */
-    kSDIO_OcrVdd35_36Flag = 23, /*!< VDD 3.4-3.5 */
-};
-/*! @brief sdio ocr voltage window mask */
-#define SDIO_OCR_VOLTAGE_WINDOW_MASK (0xFFFFU << 8U)
-
-/*! @brief sdio ocr reigster IO NUMBER mask  */
-#define SDIO_OCR_IO_NUM_MASK (7U << kSDIO_OcrIONumber)
-
-/*! @brief sdio capability flag
- * @anchor _sdio_capability_flag
- */
-enum
-{
-    kSDIO_CCCRSupportDirectCmdDuringDataTrans = (1UL << 0U),  /*!< support direct cmd during data transfer */
-    kSDIO_CCCRSupportMultiBlock               = (1UL << 1U),  /*!< support multi block mode */
-    kSDIO_CCCRSupportReadWait                 = (1UL << 2U),  /*!< support read wait */
-    kSDIO_CCCRSupportSuspendResume            = (1UL << 3U),  /*!< support suspend resume */
-    kSDIO_CCCRSupportIntDuring4BitDataTrans   = (1UL << 4U),  /*!< support interrupt during 4-bit data transfer */
-    kSDIO_CCCRSupportLowSpeed1Bit             = (1UL << 6U),  /*!< support low speed 1bit mode */
-    kSDIO_CCCRSupportLowSpeed4Bit             = (1UL << 7U),  /*!< support low speed 4bit mode */
-    kSDIO_CCCRSupportMasterPowerControl       = (1UL << 8U),  /*!< support master power control */
-    kSDIO_CCCRSupportHighSpeed                = (1UL << 9U),  /*!< support high speed */
-    kSDIO_CCCRSupportContinuousSPIInt         = (1UL << 10U), /*!< support continuous SPI interrupt */
-};
-/*! @brief UHS timing mode flag */
-#define SDIO_CCCR_SUPPORT_HIGHSPEED     (1UL << 9U)
-#define SDIO_CCCR_SUPPORT_SDR50         (1UL << 11U)
-#define SDIO_CCCR_SUPPORT_SDR104        (1UL << 12U)
-#define SDIO_CCCR_SUPPORT_DDR50         (1UL << 13U)
-#define SDIO_CCCR_SUPPORT_DRIVER_TYPE_A (1UL << 14U)
-#define SDIO_CCCR_SUPPORT_DRIVER_TYPE_C (1UL << 15U)
-#define SDIO_CCCR_SUPPORT_DRIVER_TYPE_D (1UL << 16U)
-#define SDIO_CCCR_SUPPORT_ASYNC_INT     (1UL << 17U)
-
-#define SDIO_CCCR_BUS_SPEED_MASK        (7U << 1U)
-#define SDIO_CCCR_ENABLE_HIGHSPEED_MODE (1U << 1U)
-#define SDIO_CCCR_ENABLE_SDR50_MODE     (2U << 1U)
-#define SDIO_CCCR_ENABLE_SDR104_MODE    (3U << 1U)
-#define SDIO_CCCR_ENABLE_DDR50_MODE     (4U << 1U)
-
-/*! @brief Driver type flag */
-#define SDIO_CCCR_DRIVER_TYPE_MASK     (3U << 4U)
-#define SDIO_CCCR_ENABLE_DRIVER_TYPE_B (0U << 4U)
-#define SDIO_CCCR_ENABLE_DRIVER_TYPE_A (1U << 4U)
-#define SDIO_CCCR_ENABLE_DRIVER_TYPE_C (2U << 4U)
-#define SDIO_CCCR_ENABLE_DRIVER_TYPE_D (3U << 4U)
-
-/*! @brief aync interrupt flag*/
-#define SDIO_CCCR_ASYNC_INT_MASK  (1U)
-#define SDIO_CCCR_ENABLE_AYNC_INT (1U << 1U)
-
-/*! @brief 8 bit data bus flag*/
-#define SDIO_CCCR_SUPPORT_8BIT_BUS           (1UL << 18U)
-#define SDIO_CCCR_SUPPORT_LOW_SPEED_4BIT_BUS (1U << 7U)
-/*! @brief sdio fbr flag
- * @anchor _sdio_fbr_flag
- */
-enum
-{
-    kSDIO_FBRSupportCSA            = (1U << 0U), /*!< function support CSA */
-    kSDIO_FBRSupportPowerSelection = (1U << 1U), /*!< function support power selection */
-};
-
-/*! @brief sdio bus width */
-typedef enum _sdio_bus_width
-{
-    kSDIO_DataBus1Bit = 0x00U, /*!< 1 bit bus mode */
-    kSDIO_DataBus4Bit = 0X02U, /*!< 4 bit bus mode*/
-    kSDIO_DataBus8Bit = 0X03U, /*!< 8 bit bus mode*/
-} sdio_bus_width_t;
-
-/*! @brief MMC card individual commands */
-typedef enum _mmc_command
-{
-    kMMC_SendOperationCondition = 1U,  /*!< Send Operation Condition */
-    kMMC_SetRelativeAddress     = 3U,  /*!< Set Relative Address */
-    kMMC_SleepAwake             = 5U,  /*!< Sleep Awake */
-    kMMC_Switch                 = 6U,  /*!< Switch */
-    kMMC_SendExtendedCsd        = 8U,  /*!< Send EXT_CSD */
-    kMMC_ReadDataUntilStop      = 11U, /*!< Read Data Until Stop */
-    kMMC_BusTestRead            = 14U, /*!< Test Read */
-    kMMC_SendingBusTest         = 19U, /*!< test bus width cmd*/
-    kMMC_WriteDataUntilStop     = 20U, /*!< Write Data Until Stop */
-    kMMC_SendTuningBlock        = 21U, /*!< MMC sending tuning block */
-    kMMC_ProgramCid             = 26U, /*!< Program CID */
-    kMMC_EraseGroupStart        = 35U, /*!< Erase Group Start */
-    kMMC_EraseGroupEnd          = 36U, /*!< Erase Group End */
-    kMMC_FastInputOutput        = 39U, /*!< Fast IO */
-    kMMC_GoInterruptState       = 40U, /*!< Go interrupt State */
-} mmc_command_t;
-
-/*! @brief MMC card classified as voltage range */
-typedef enum _mmc_classified_voltage
-{
-    kMMC_ClassifiedVoltageHigh = 0U, /*!< High-voltage MMC card */
-    kMMC_ClassifiedVoltageDual = 1U, /*!< Dual-voltage MMC card */
-} mmc_classified_voltage_t;
-
-/*! @brief MMC card classified as density level */
-typedef enum _mmc_classified_density
-{
-    kMMC_ClassifiedDensityWithin2GB = 0U, /*!< Density byte is less than or equal 2GB */
-    kMMC_ClassifiedDensityHigher2GB = 1U, /* Density byte is higher than 2GB */
-} mmc_classified_density_t;
-
-/*! @brief The bit mask for VOLTAGE WINDOW 1.70V to 1.95V field in OCR */
-#define MMC_OCR_V170TO195_SHIFT (7U)
-/*! @brief The bit mask for VOLTAGE WINDOW 1.70V to 1.95V field in OCR */
-#define MMC_OCR_V170TO195_MASK (0x00000080U)
-/*! @brief The bit shift for VOLTAGE WINDOW 2.00V to 2.60V field in OCR */
-#define MMC_OCR_V200TO260_SHIFT (8U)
-/*! @brief The bit mask for VOLTAGE WINDOW 2.00V to 2.60V field in OCR */
-#define MMC_OCR_V200TO260_MASK (0x00007F00U)
-/*! @brief The bit shift for VOLTAGE WINDOW 2.70V to 3.60V field in OCR */
-#define MMC_OCR_V270TO360_SHIFT (15U)
-/*! @brief The bit mask for VOLTAGE WINDOW 2.70V to 3.60V field in OCR */
-#define MMC_OCR_V270TO360_MASK (0x00FF8000U)
-/*! @brief The bit shift for ACCESS MODE field in OCR */
-#define MMC_OCR_ACCESS_MODE_SHIFT (29U)
-/*! @brief The bit mask for ACCESS MODE field in OCR */
-#define MMC_OCR_ACCESS_MODE_MASK (0x60000000U)
-/*! @brief The bit shift for BUSY field in OCR */
-#define MMC_OCR_BUSY_SHIFT (31U)
-/*! @brief The bit mask for BUSY field in OCR */
-#define MMC_OCR_BUSY_MASK (1U << MMC_OCR_BUSY_SHIFT)
-
-/*! @brief MMC card access mode(Access mode in OCR). */
-typedef enum _mmc_access_mode
-{
-    kMMC_AccessModeByte   = 0U, /*!< The card should be accessed as byte */
-    kMMC_AccessModeSector = 2U, /*!< The card should be accessed as sector */
-} mmc_access_mode_t;
-
-/*! @brief MMC card voltage window(VDD voltage window in OCR). */
-typedef enum _mmc_voltage_window
-{
-    kMMC_VoltageWindowNone      = 0U,     /*!< voltage window is not define by user*/
-    kMMC_VoltageWindow120       = 0x01U,  /*!< Voltage window is 1.20V */
-    kMMC_VoltageWindow170to195  = 0x02U,  /*!< Voltage window is 1.70V to 1.95V */
-    kMMC_VoltageWindows270to360 = 0x1FFU, /*!< Voltage window is 2.70V to 3.60V */
-} mmc_voltage_window_t;
-
-/*! @brief CSD structure version(CSD_STRUCTURE in CSD). */
-typedef enum _mmc_csd_structure_version
-{
-    kMMC_CsdStrucureVersion10       = 0U, /*!< CSD version No. 1.0 */
-    kMMC_CsdStrucureVersion11       = 1U, /*!< CSD version No. 1.1 */
-    kMMC_CsdStrucureVersion12       = 2U, /*!< CSD version No. 1.2 */
-    kMMC_CsdStrucureVersionInExtcsd = 3U, /*!< Version coded in Extended CSD */
-} mmc_csd_structure_version_t;
-
-/*! @brief MMC card specification version(SPEC_VERS in CSD). */
-typedef enum _mmc_specification_version
-{
-    kMMC_SpecificationVersion0 = 0U, /*!< Allocated by MMCA */
-    kMMC_SpecificationVersion1 = 1U, /*!< Allocated by MMCA */
-    kMMC_SpecificationVersion2 = 2U, /*!< Allocated by MMCA */
-    kMMC_SpecificationVersion3 = 3U, /*!< Allocated by MMCA */
-    kMMC_SpecificationVersion4 = 4U, /*!< Version 4.1/4.2/4.3/4.41-4.5-4.51-5.0 */
-} mmc_specification_version_t;
-
-/*! @brief The bit shift for FREQUENCY UNIT field in TRANSFER SPEED(TRAN-SPEED in Extended CSD) */
-#define MMC_TRANSFER_SPEED_FREQUENCY_UNIT_SHIFT (0U)
-/*! @brief The bit mask for FRQEUENCY UNIT in TRANSFER SPEED */
-#define MMC_TRANSFER_SPEED_FREQUENCY_UNIT_MASK (0x07U)
-/*! @brief The bit shift for MULTIPLIER field in TRANSFER SPEED */
-#define MMC_TRANSFER_SPEED_MULTIPLIER_SHIFT (3U)
-/*! @brief The bit mask for MULTIPLIER field in TRANSFER SPEED  */
-#define MMC_TRANSFER_SPEED_MULTIPLIER_MASK (0x78U)
-
-/*! @brief Read the value of FREQUENCY UNIT in TRANSFER SPEED. */
-#define READ_MMC_TRANSFER_SPEED_FREQUENCY_UNIT(CSD) \
-    ((((CSD).transferSpeed) & MMC_TRANSFER_SPEED_FREQUENCY_UNIT_MASK) >> MMC_TRANSFER_SPEED_FREQUENCY_UNIT_SHIFT)
-/*! @brief Read the value of MULTIPLER filed in TRANSFER SPEED. */
-#define READ_MMC_TRANSFER_SPEED_MULTIPLIER(CSD) \
-    ((((CSD).transferSpeed) & MMC_TRANSFER_SPEED_MULTIPLIER_MASK) >> MMC_TRANSFER_SPEED_MULTIPLIER_SHIFT)
-
-/*! @brief MMC card Extended CSD fix version(EXT_CSD_REV in Extended CSD)
- * @anchor _mmc_extended_csd_revision
- */
-enum
-{
-    kMMC_ExtendedCsdRevision10 = 0U, /*!< Revision 1.0 */
-    kMMC_ExtendedCsdRevision11 = 1U, /*!< Revision 1.1 */
-    kMMC_ExtendedCsdRevision12 = 2U, /*!< Revision 1.2 */
-    kMMC_ExtendedCsdRevision13 = 3U, /*!< Revision 1.3 MMC4.3*/
-    kMMC_ExtendedCsdRevision14 = 4U, /*!< Revision 1.4 obsolete*/
-    kMMC_ExtendedCsdRevision15 = 5U, /*!< Revision 1.5 MMC4.41*/
-    kMMC_ExtendedCsdRevision16 = 6U, /*!< Revision 1.6 MMC4.5*/
-    kMMC_ExtendedCsdRevision17 = 7U, /*!< Revision 1.7 MMC5.0 */
-};
-
-/*! @brief MMC card command set(COMMAND_SET in Extended CSD) */
-typedef enum _mmc_command_set
-{
-    kMMC_CommandSetStandard = 0U, /*!< Standard MMC */
-    kMMC_CommandSet1        = 1U, /*!< Command set 1 */
-    kMMC_CommandSet2        = 2U, /*!< Command set 2 */
-    kMMC_CommandSet3        = 3U, /*!< Command set 3 */
-    kMMC_CommandSet4        = 4U, /*!< Command set 4 */
-} mmc_command_set_t;
-
-/*! @brief boot support(BOOT_INFO in Extended CSD)
- * @anchor _mmc_support_boot_mode
- */
-enum
-{
-    kMMC_SupportAlternateBoot = 1U, /*!< support alternative boot mode*/
-    kMMC_SupportDDRBoot       = 2U, /*!< support DDR boot mode*/
-    kMMC_SupportHighSpeedBoot = 4U, /*!< support high speed boot mode*/
-};
-/*! @brief The power class value bit mask when bus in 4 bit mode */
-#define MMC_POWER_CLASS_4BIT_MASK (0x0FU)
-/*! @brief The power class current value bit mask when bus in 8 bit mode */
-#define MMC_POWER_CLASS_8BIT_MASK (0xF0U)
-/*! @brief mmc cache control enable*/
-#define MMC_CACHE_CONTROL_ENABLE (1U)
-/*! @brief mmc cache flush */
-#define MMC_CACHE_TRIGGER_FLUSH (1U)
-
-/*! @brief MMC card high-speed timing(HS_TIMING in Extended CSD) */
-typedef enum _mmc_high_speed_timing
-{
-    kMMC_HighSpeedTimingNone       = 0U, /*!< MMC card using none high-speed timing */
-    kMMC_HighSpeedTiming           = 1U, /*!< MMC card using high-speed timing */
-    kMMC_HighSpeed200Timing        = 2U, /*!< MMC card high speed 200 timing*/
-    kMMC_HighSpeed400Timing        = 3U, /*!< MMC card high speed 400 timing*/
-    kMMC_EnhanceHighSpeed400Timing = 4U, /*!< MMC card high speed 400 timing*/
-} mmc_high_speed_timing_t;
-
-/*! @brief The number of data bus width type */
-#define MMC_DATA_BUS_WIDTH_TYPE_NUMBER (3U)
-/*! @brief MMC card data bus width(BUS_WIDTH in Extended CSD) */
-typedef enum _mmc_data_bus_width
-{
-    kMMC_DataBusWidth1bit          = 0U,    /*!< MMC data bus width is 1 bit */
-    kMMC_DataBusWidth4bit          = 1U,    /*!< MMC data bus width is 4 bits */
-    kMMC_DataBusWidth8bit          = 2U,    /*!< MMC data bus width is 8 bits */
-    kMMC_DataBusWidth4bitDDR       = 5U,    /*!< MMC data bus width is 4 bits ddr */
-    kMMC_DataBusWidth8bitDDR       = 6U,    /*!< MMC data bus width is 8 bits ddr */
-    kMMC_DataBusWidth8bitDDRSTROBE = 0x86U, /*!< MMC data bus width is 8 bits ddr  strobe mode */
-} mmc_data_bus_width_t;
-
-/*! @brief MMC card boot partition enabled(BOOT_PARTITION_ENABLE in Extended CSD) */
-typedef enum _mmc_boot_partition_enable
-{
-    kMMC_BootPartitionEnableNot        = 0U, /*!< Device not boot enabled (default) */
-    kMMC_BootPartitionEnablePartition1 = 1U, /*!< Boot partition 1 enabled for boot */
-    kMMC_BootPartitionEnablePartition2 = 2U, /*!< Boot partition 2 enabled for boot */
-    kMMC_BootPartitionEnableUserAera   = 7U, /*!< User area enabled for boot */
-} mmc_boot_partition_enable_t;
-
-/*! @brief boot mode configuration
- * Note: HS200 & HS400 is not support during BOOT operation.
- */
-typedef enum _mmc_boot_timing_mode
-{
-    kMMC_BootModeSDRWithDefaultTiming   = 0U, /*!< boot mode single data rate with backward compatiable timings */
-    kMMC_BootModeSDRWithHighSpeedTiming = 1U, /*!< boot mode single data rate with high speed timing */
-    kMMC_BootModeDDRTiming              = 2U, /*!< boot mode dual date rate */
-} mmc_boot_timing_mode_t;
-
-/*! @brief MMC card boot partition write protect configurations
- * All the bits in BOOT_WP register, except the two R/W bits B_PERM_WP_DIS
- * and B_PERM_WP_EN, shall only be written once per power cycle.The protection
- * mdde intended for both boot areas will be set with a single write.
- */
-typedef enum _mmc_boot_partition_wp
-{
-    kMMC_BootPartitionWPDisable = 0x50U, /*!< boot partition write protection disable */
-    kMMC_BootPartitionPwrWPToBothPartition =
-        0x01U, /*!< power on period write protection apply to both boot partitions */
-    kMMC_BootPartitionPermWPToBothPartition = 0x04U, /*!< permanent write protection apply to both boot partitions */
-
-    kMMC_BootPartitionPwrWPToPartition1 = (1U << 7U) | 1U, /*!< power on period write protection apply to partition1 */
-    kMMC_BootPartitionPwrWPToPartition2 = (1U << 7U) | 3U, /*!< power on period write protection apply to partition2 */
-
-    kMMC_BootPartitionPermWPToPartition1 =
-        (1U << 7U) | (1U << 2U), /*!< permanent write protection apply to partition1 */
-    kMMC_BootPartitionPermWPToPartition2 =
-        (1U << 7U) | (3U << 2U), /*!< permanent write protection apply to partition2 */
-
-    kMMC_BootPartitionPermWPToPartition1PwrWPToPartition2 =
-        (1U << 7U) | (1U << 2U) |
-        3U, /*!< permanent write protection apply to partition1, power on period write protection apply to partition2 */
-    kMMC_BootPartitionPermWPToPartition2PwrWPToPartition1 =
-        (1U << 7U) | (3U << 2U) |
-        1U, /*!< permanent write protection apply to partition2, power on period write protection apply to partition1 */
-} mmc_boot_partition_wp_t;
-
-/*! @brief MMC card boot partition write protect status
- * @anchor _mmc_boot_partition_wp_status
- */
-enum
-{
-    kMMC_BootPartitionNotProtected  = 0U, /*!< boot partition not protected */
-    kMMC_BootPartitionPwrProtected  = 1U, /*!< boot partition is power on period write protected */
-    kMMC_BootPartitionPermProtected = 2U, /*!< boot partition is permanently protected */
-};
-
-/*! @brief MMC card partition to be accessed(BOOT_PARTITION_ACCESS in Extended CSD) */
-typedef enum _mmc_access_partition
-{
-    kMMC_AccessPartitionUserAera        = 0U, /*!< No access to boot partition (default), normal partition */
-    kMMC_AccessPartitionBoot1           = 1U, /*!< Read/Write boot partition 1 */
-    kMMC_AccessPartitionBoot2           = 2U, /*!< Read/Write boot partition 2*/
-    kMMC_AccessRPMB                     = 3U, /*!< Replay protected mem block */
-    kMMC_AccessGeneralPurposePartition1 = 4U, /*!< access to general purpose partition 1 */
-    kMMC_AccessGeneralPurposePartition2 = 5U, /*!< access to general purpose partition 2 */
-    kMMC_AccessGeneralPurposePartition3 = 6U, /*!< access to general purpose partition 3 */
-    kMMC_AccessGeneralPurposePartition4 = 7U, /*!< access to general purpose partition 4 */
-} mmc_access_partition_t;
-
-/*! @brief The bit shift for PARTITION ACCESS filed in BOOT CONFIG (BOOT_CONFIG in Extend CSD) */
-#define MMC_PARTITION_CONFIG_PARTITION_ACCESS_SHIFT (0U)
-/*! @brief The bit mask for PARTITION ACCESS field in BOOT CONFIG */
-#define MMC_PARTITION_CONFIG_PARTITION_ACCESS_MASK (0x00000007U)
-/*! @brief The bit shift for PARTITION ENABLE field in BOOT CONFIG */
-#define MMC_PARTITION_CONFIG_PARTITION_ENABLE_SHIFT (3U)
-/*! @brief The bit mask for PARTITION ENABLE field in BOOT CONFIG */
-#define MMC_PARTITION_CONFIG_PARTITION_ENABLE_MASK (0x00000038U)
-/*! @brief The bit shift for ACK field in BOOT CONFIG */
-#define MMC_PARTITION_CONFIG_BOOT_ACK_SHIFT (6U)
-/*! @brief The bit mask for ACK field in BOOT CONFIG */
-#define MMC_PARTITION_CONFIG_BOOT_ACK_MASK (0x00000040U)
-/*! @brief The bit shift for BOOT BUS WIDTH field in BOOT CONFIG */
-#define MMC_BOOT_BUS_CONDITION_BUS_WIDTH_SHIFT (0U)
-/*! @brief The bit mask for BOOT BUS WIDTH field in BOOT CONFIG */
-#define MMC_BOOT_BUS_CONDITION_BUS_WIDTH_MASK (3U)
-/*! @brief The bit shift for BOOT BUS WIDTH RESET field in BOOT CONFIG */
-#define MMC_BOOT_BUS_CONDITION_RESET_BUS_CONDITION_SHIFT (2U)
-/*! @brief The bit mask for BOOT BUS WIDTH RESET field in BOOT CONFIG */
-#define MMC_BOOT_BUS_CONDITION_RESET_BUS_CONDITION_MASK (4U)
-/*! @brief The bit shift for BOOT MODE field in BOOT CONFIG */
-#define MMC_BOOT_BUS_CONDITION_BOOT_MODE_SHIFT (3U)
-/*! @brief The bit mask for BOOT MODE field in BOOT CONFIG */
-#define MMC_BOOT_BUS_CONDITION_BOOT_MODE_MASK (0x18U)
-
-/*! @brief MMC card CSD register flags
- * @anchor _mmc_csd_flag
- */
-enum
-{
-    kMMC_CsdReadBlockPartialFlag         = (1U << 0U),  /*!< Partial blocks for read allowed */
-    kMMC_CsdWriteBlockMisalignFlag       = (1U << 1U),  /*!< Write block misalignment */
-    kMMC_CsdReadBlockMisalignFlag        = (1U << 2U),  /*!< Read block misalignment */
-    kMMC_CsdDsrImplementedFlag           = (1U << 3U),  /*!< DSR implemented */
-    kMMC_CsdWriteProtectGroupEnabledFlag = (1U << 4U),  /*!< Write protect group enabled */
-    kMMC_CsdWriteBlockPartialFlag        = (1U << 5U),  /*!< Partial blocks for write allowed */
-    kMMC_ContentProtectApplicationFlag   = (1U << 6U),  /*!< Content protect application */
-    kMMC_CsdFileFormatGroupFlag          = (1U << 7U),  /*!< File format group */
-    kMMC_CsdCopyFlag                     = (1U << 8U),  /*!< Copy flag */
-    kMMC_CsdPermanentWriteProtectFlag    = (1U << 9U),  /*!< Permanent write protection */
-    kMMC_CsdTemporaryWriteProtectFlag    = (1U << 10U), /*!< Temporary write protection */
-};
-
-/*! @brief Extended CSD register access mode(Access mode in CMD6). */
-typedef enum _mmc_extended_csd_access_mode
-{
-    kMMC_ExtendedCsdAccessModeCommandSet = 0U, /*!< Command set related setting */
-    kMMC_ExtendedCsdAccessModeSetBits    = 1U, /*!< Set bits in specific byte in Extended CSD  */
-    kMMC_ExtendedCsdAccessModeClearBits  = 2U, /*!< Clear bits in specific byte in Extended CSD */
-    kMMC_ExtendedCsdAccessModeWriteBits  = 3U, /*!< Write a value to specific byte in Extended CSD */
-} mmc_extended_csd_access_mode_t;
-
-/*! @brief EXT CSD byte index */
-typedef enum _mmc_extended_csd_index
-{
-    kMMC_ExtendedCsdIndexFlushCache           = 32U,  /*!< flush cache */
-    kMMC_ExtendedCsdIndexCacheControl         = 33U,  /*!< cache control */
-    kMMC_ExtendedCsdIndexBootPartitionWP      = 173U, /*!< Boot partition write protect */
-    kMMC_ExtendedCsdIndexEraseGroupDefinition = 175U, /*!< Erase Group Def */
-    kMMC_ExtendedCsdIndexBootBusConditions    = 177U, /*!< Boot Bus conditions */
-    kMMC_ExtendedCsdIndexBootConfigWP         = 178U, /*!< Boot config write protect */
-    kMMC_ExtendedCsdIndexPartitionConfig      = 179U, /*!< Partition Config, before BOOT_CONFIG */
-    kMMC_ExtendedCsdIndexBusWidth             = 183U, /*!< Bus Width */
-    kMMC_ExtendedCsdIndexHighSpeedTiming      = 185U, /*!< High-speed Timing */
-    kMMC_ExtendedCsdIndexPowerClass           = 187U, /*!< Power Class */
-    kMMC_ExtendedCsdIndexCommandSet           = 191U, /*!< Command Set */
-} mmc_extended_csd_index_t;
-
-/*! @brief mmc driver strength
- * @anchor _mmc_driver_strength
- */
-enum
-{
-    kMMC_DriverStrength0 = 0U, /*!< Driver type0 ,nominal impedance 50ohm */
-    kMMC_DriverStrength1 = 1U, /*!< Driver type1 ,nominal impedance 33ohm */
-    kMMC_DriverStrength2 = 2U, /*!< Driver type2 ,nominal impedance 66ohm */
-    kMMC_DriverStrength3 = 3U, /*!< Driver type3 ,nominal impedance 100ohm */
-    kMMC_DriverStrength4 = 4U, /*!< Driver type4 ,nominal impedance 40ohm */
-};
-
-/*! @brief mmc extended csd flags*/
-typedef enum _mmc_extended_csd_flags
-{
-    kMMC_ExtCsdExtPartitionSupport       = (1 << 0U), /*!< partitioning support[160] */
-    kMMC_ExtCsdEnhancePartitionSupport   = (1 << 1U), /*!< partitioning support[160] */
-    kMMC_ExtCsdPartitioningSupport       = (1 << 2U), /*!< partitioning support[160] */
-    kMMC_ExtCsdPrgCIDCSDInDDRModeSupport = (1 << 3U), /*!< CMD26 and CMD27 are support dual data rate [130]*/
-    kMMC_ExtCsdBKOpsSupport              = (1 << 4U), /*!< background operation feature support [502]*/
-    kMMC_ExtCsdDataTagSupport            = (1 << 5U), /*!< data tag support[499]*/
-    kMMC_ExtCsdModeOperationCodeSupport  = (1 << 6U), /*!< mode operation code support[493]*/
-} mmc_extended_csd_flags_t;
-
-/*! @brief MMC card boot mode */
-typedef enum _mmc_boot_mode
-{
-    kMMC_BootModeNormal      = 0U, /*!< Normal boot */
-    kMMC_BootModeAlternative = 1U, /*!< Alternative boot */
-} mmc_boot_mode_t;
-
-/*! @brief The length of Extended CSD register, unit as bytes. */
-#define MMC_EXTENDED_CSD_BYTES (512U)
-
-/*! @brief MMC card default relative address */
-#define MMC_DEFAULT_RELATIVE_ADDRESS (2UL)
-
-/*! @brief SD card product name length united as bytes. */
-#define SD_PRODUCT_NAME_BYTES (5U)
-
-/*! @brief sdio card FBR register */
-typedef struct _sdio_fbr
-{
-    uint8_t flags;             /*!< current io flags */
-    uint8_t ioStdFunctionCode; /*!< current io standard function code */
-    uint8_t ioExtFunctionCode; /*!< current io extended function code*/
-    uint32_t ioPointerToCIS;   /*!< current io pointer to CIS */
-    uint32_t ioPointerToCSA;   /*!< current io pointer to CSA*/
-    uint16_t ioBlockSize;      /*!< current io block size */
-} sdio_fbr_t;
-
-/*! @brief sdio card common CIS  */
-typedef struct _sdio_common_cis
-{
-    /* manufacturer identification string tuple */
-    uint16_t mID;   /*!< manufacturer code */
-    uint16_t mInfo; /*!< manufacturer information */
-
-    /*function identification tuple */
-    uint8_t funcID; /*!< function ID */
-
-    /* function extension tuple */
-    uint16_t fn0MaxBlkSize; /*!< function 0 max block size */
-    uint8_t maxTransSpeed;  /*!< max data transfer speed for all function */
-
-} sdio_common_cis_t;
-
-/*! @brief sdio card function CIS  */
-typedef struct _sdio_func_cis
-{
-    /*function identification tuple */
-    uint8_t funcID; /*!< function ID */
-
-    /* function extension tuple */
-    uint8_t funcInfo;        /*!< function info */
-    uint8_t ioVersion;       /*!< level of application specification this io support */
-    uint32_t cardPSN;        /*!< product serial number */
-    uint32_t ioCSASize;      /*!< avaliable CSA size for io  */
-    uint8_t ioCSAProperty;   /*!< CSA property */
-    uint16_t ioMaxBlockSize; /*!< io max transfer data size */
-    uint32_t ioOCR;          /*!< io ioeration condition */
-    uint8_t ioOPMinPwr;      /*!< min current in operation mode */
-    uint8_t ioOPAvgPwr;      /*!< average current in operation mode */
-    uint8_t ioOPMaxPwr;      /*!< max current in operation mode */
-    uint8_t ioSBMinPwr;      /*!< min current in standby mode */
-    uint8_t ioSBAvgPwr;      /*!< average current in standby mode */
-    uint8_t ioSBMaxPwr;      /*!< max current in standby mode */
-
-    uint16_t ioMinBandWidth;          /*!< io min transfer bandwidth */
-    uint16_t ioOptimumBandWidth;      /*!< io optimum transfer bandwidth */
-    uint16_t ioReadyTimeout;          /*!< timeout value from enalbe to ready */
-    uint16_t ioHighCurrentAvgCurrent; /*!< the average peak current (mA)
-                                      when IO operating in high current mode */
-    uint16_t ioHighCurrentMaxCurrent; /*!< the max peak current (mA)
-                                      when IO operating in high current mode */
-    uint16_t ioLowCurrentAvgCurrent;  /*!< the average peak current (mA)
-                                      when IO operating in lower current mode */
-    uint16_t ioLowCurrentMaxCurrent;  /*!< the max peak current (mA)
-                                      when IO operating in lower current mode */
-} sdio_func_cis_t;
-
-/*! @brief SD AU start value */
-#define SD_AU_START_VALUE (1U)
-/*! @brief SD UHS AU start value */
-#define SD_UHS_AU_START_VALUE (7U)
-
-/*! @brief SD card status */
-typedef struct _sd_status
-{
-    uint8_t busWidth;        /*!< current buswidth */
-    uint8_t secureMode;      /*!< secured mode */
-    uint16_t cardType;       /*!< sdcard type */
-    uint32_t protectedSize;  /*!< size of protected area */
-    uint8_t speedClass;      /*!< speed class of card */
-    uint8_t performanceMove; /*!< Performance of move indicated by 1[MB/S]step */
-    uint8_t auSize;          /*!< size of AU */
-    uint16_t eraseSize;      /*!< number of AUs to be erased at a time */
-    uint8_t eraseTimeout;    /*!< timeout value for erasing areas specified by UNIT OF ERASE AU */
-    uint8_t eraseOffset;     /*!< fixed offset value added to erase time */
-    uint8_t uhsSpeedGrade;   /*!< speed grade for UHS mode */
-    uint8_t uhsAuSize;       /*!< size of AU for UHS mode */
-} sd_status_t;
-
-/*! @brief SD card CID register */
-typedef struct _sd_cid
-{
-    uint8_t manufacturerID;                     /*!< Manufacturer ID [127:120] */
-    uint16_t applicationID;                     /*!< OEM/Application ID [119:104] */
-    uint8_t productName[SD_PRODUCT_NAME_BYTES]; /*!< Product name [103:64] */
-    uint8_t productVersion;                     /*!< Product revision [63:56] */
-    uint32_t productSerialNumber;               /*!< Product serial number [55:24] */
-    uint16_t manufacturerData;                  /*!< Manufacturing date [19:8] */
-} sd_cid_t;
-
-/*! @brief SD card CSD register */
-typedef struct _sd_csd
-{
-    uint8_t csdStructure;        /*!< CSD structure [127:126] */
-    uint8_t dataReadAccessTime1; /*!< Data read access-time-1 [119:112] */
-    uint8_t dataReadAccessTime2; /*!< Data read access-time-2 in clock cycles (NSAC*100) [111:104] */
-    uint8_t transferSpeed;       /*!< Maximum data transfer rate [103:96] */
-    uint16_t cardCommandClass;   /*!< Card command classes [95:84] */
-    uint8_t readBlockLength;     /*!< Maximum read data block length [83:80] */
-    uint16_t flags;              /*!< Flags in _sd_csd_flag */
-    uint32_t deviceSize;         /*!< Device size [73:62] */
-    /* Following fields from 'readCurrentVddMin' to 'deviceSizeMultiplier' exist in CSD version 1 */
-    uint8_t readCurrentVddMin;    /*!< Maximum read current at VDD min [61:59] */
-    uint8_t readCurrentVddMax;    /*!< Maximum read current at VDD max [58:56] */
-    uint8_t writeCurrentVddMin;   /*!< Maximum write current at VDD min [55:53] */
-    uint8_t writeCurrentVddMax;   /*!< Maximum write current at VDD max [52:50] */
-    uint8_t deviceSizeMultiplier; /*!< Device size multiplier [49:47] */
-
-    uint8_t eraseSectorSize;       /*!< Erase sector size [45:39] */
-    uint8_t writeProtectGroupSize; /*!< Write protect group size [38:32] */
-    uint8_t writeSpeedFactor;      /*!< Write speed factor [28:26] */
-    uint8_t writeBlockLength;      /*!< Maximum write data block length [25:22] */
-    uint8_t fileFormat;            /*!< File format [11:10] */
-} sd_csd_t;
-
-/*! @brief The bit shift for RATE UNIT field in TRANSFER SPEED */
-#define SD_TRANSFER_SPEED_RATE_UNIT_SHIFT (0U)
-/*! @brief The bit mask for RATE UNIT field in TRANSFER SPEED */
-#define SD_TRANSFER_SPEED_RATE_UNIT_MASK (0x07U)
-/*! @brief The bit shift for TIME VALUE field in TRANSFER SPEED */
-#define SD_TRANSFER_SPEED_TIME_VALUE_SHIFT (2U)
-/*! @brief The bit mask for TIME VALUE field in TRANSFER SPEED */
-#define SD_TRANSFER_SPEED_TIME_VALUE_MASK (0x78U)
-/*! @brief Read the value of FREQUENCY UNIT in TRANSFER SPEED field */
-#define SD_RD_TRANSFER_SPEED_RATE_UNIT(x) \
-    (((x.transferSpeed) & SD_TRANSFER_SPEED_RATE_UNIT_MASK) >> SD_TRANSFER_SPEED_RATE_UNIT_SHIFT)
-/*! @brief Read the value of TIME VALUE in TRANSFER SPEED field */
-#define SD_RD_TRANSFER_SPEED_TIME_VALUE(x) \
-    (((x.transferSpeed) & SD_TRANSFER_SPEED_TIME_VALUE_MASK) >> SD_TRANSFER_SPEED_TIME_VALUE_SHIFT)
-
-/*! @brief SD card SCR register */
-typedef struct _sd_scr
-{
-    uint8_t scrStructure;             /*!< SCR Structure [63:60] */
-    uint8_t sdSpecification;          /*!< SD memory card specification version [59:56] */
-    uint16_t flags;                   /*!< SCR flags in _sd_scr_flag */
-    uint8_t sdSecurity;               /*!< Security specification supported [54:52] */
-    uint8_t sdBusWidths;              /*!< Data bus widths supported [51:48] */
-    uint8_t extendedSecurity;         /*!< Extended security support [46:43] */
-    uint8_t commandSupport;           /*!< Command support bits [33:32] 33-support CMD23, 32-support cmd20*/
-    uint32_t reservedForManufacturer; /*!< reserved for manufacturer usage [31:0] */
-} sd_scr_t;
-
-/*! @brief MMC card product name length united as bytes. */
-#define MMC_PRODUCT_NAME_BYTES (6U)
-/*! @brief MMC card CID register. */
-typedef struct _mmc_cid
-{
-    uint8_t manufacturerID;                      /*!< Manufacturer ID */
-    uint16_t applicationID;                      /*!< OEM/Application ID */
-    uint8_t productName[MMC_PRODUCT_NAME_BYTES]; /*!< Product name */
-    uint8_t productVersion;                      /*!< Product revision */
-    uint32_t productSerialNumber;                /*!< Product serial number */
-    uint8_t manufacturerData;                    /*!< Manufacturing date */
-} mmc_cid_t;
-
-/*! @brief MMC card CSD register. */
-typedef struct _mmc_csd
-{
-    uint8_t csdStructureVersion;        /*!< CSD structure [127:126] */
-    uint8_t systemSpecificationVersion; /*!< System specification version [125:122] */
-    uint8_t dataReadAccessTime1;        /*!< Data read access-time 1 [119:112] */
-    uint8_t dataReadAccessTime2;        /*!< Data read access-time 2 in CLOCK cycles (NSAC*100) [111:104] */
-    uint8_t transferSpeed;              /*!< Max. bus clock frequency [103:96] */
-    uint16_t cardCommandClass;          /*!< card command classes [95:84] */
-    uint8_t readBlockLength;            /*!< Max. read data block length [83:80] */
-    uint16_t flags;                     /*!< Contain flags in _mmc_csd_flag */
-    uint16_t deviceSize;                /*!< Device size [73:62] */
-    uint8_t readCurrentVddMin;          /*!< Max. read current @ VDD min [61:59] */
-    uint8_t readCurrentVddMax;          /*!< Max. read current @ VDD max [58:56] */
-    uint8_t writeCurrentVddMin;         /*!< Max. write current @ VDD min [55:53] */
-    uint8_t writeCurrentVddMax;         /*!< Max. write current @ VDD max [52:50] */
-    uint8_t deviceSizeMultiplier;       /*!< Device size multiplier [49:47] */
-    uint8_t eraseGroupSize;             /*!< Erase group size [46:42] */
-    uint8_t eraseGroupSizeMultiplier;   /*!< Erase group size multiplier [41:37] */
-    uint8_t writeProtectGroupSize;      /*!< Write protect group size [36:32] */
-    uint8_t defaultEcc;                 /*!< Manufacturer default ECC [30:29] */
-    uint8_t writeSpeedFactor;           /*!< Write speed factor [28:26] */
-    uint8_t maxWriteBlockLength;        /*!< Max. write data block length [25:22] */
-    uint8_t fileFormat;                 /*!< File format [11:10] */
-    uint8_t eccCode;                    /*!< ECC code [9:8] */
-} mmc_csd_t;
-
-/*! @brief MMC card Extended CSD register (unit: byte). */
-typedef struct _mmc_extended_csd
-{
-    /*uint8_t SecureRemoveType;*/             /*!< secure removal type[16]*/
-    /*uint8_t enProductStateAware;*/          /*!< product state awareness enablement[17]*/
-    /*uint32_t maxPreLoadDataSize;*/          /*!< max preload data size[21-18]*/
-    /*uint32_t preLoadDataSize;*/             /*!< pre-load data size[25-22]*/
-    /*uint8_t ffuStatus;*/                    /*!< FFU status [26]*/
-    /*uint8_t modeOperationCode;*/            /*!< mode operation code[29]*/
-    /*uint8_t modeConfig;*/                   /*!< mode config [30]*/
-    uint8_t cacheCtrl;                        /*!< control to turn on/off cache[33]*/
-    /*uint8_t pwroffNotify;*/                 /*!< power off notification[34]*/
-    /*uint8_t packedCmdFailIndex;*/           /*!< packed cmd fail index [35]*/
-    /*uint8_t packedCmdStatus;*/              /*!< packed cmd status[36]*/
-    /*uint32_t contextConfig[4U];*/           /*!< context configuration[51-37]*/
-    /*uint16_t extPartitionAttr;*/            /*!< extended partitions attribut[53-52]*/
-    /*uint16_t exceptEventStatus;*/           /*!< exception events status[55-54]*/
-    /*uint16_t exceptEventControl;*/          /*!< exception events control[57-56]*/
-    /*uint8_t toReleaseAddressedGroup;*/      /*!< number of group to be released[58]*/
-    /*uint8_t class6CmdCtrl;*/                /*!< class 6 command control[59]*/
-    /*uint8_t intTimeoutEmu;*/                /*!< 1st initiallization after disabling sector size emu[60]*/
-    /*uint8_t sectorSize;*/                   /*!< sector size[61] */
-    /*uint8_t sectorSizeEmu;*/                /*!< sector size emulation[62]*/
-    /*uint8_t nativeSectorSize;*/             /*!< native sector size[63]*/
-    /*uint8_t periodWakeup;*/                 /*!< period wakeup [131]*/
-    /*uint8_t tCASESupport;*/                 /*!< package case temperature is controlled[132]*/
-    /*uint8_t productionStateAware;*/         /*!< production state awareness[133]*/
-    /*uint32_t enhanceUsrDataStartAddr;*/     /*!< enhanced user data start addr [139-136]*/
-    /*uint32_t enhanceUsrDataSize;*/          /*!< enhanced user data area size[142-140]*/
-    /*uint32_t generalPartitionSize[3];*/     /*!< general purpose partition size[154-143]*/
-    uint8_t partitionAttribute;               /*!< partition attribute [156]*/
-    /*uint32_t maxEnhanceAreaSize;*/          /*!< max enhance area size [159-157]*/
-    /*uint8_t hpiManagementEn;*/              /*!< HPI management [161]*/
-    /*uint8_t writeReliabilityParameter;*/    /*!< write reliability parameter register[166] */
-    /*uint8_t writeReliabilitySet;*/          /*!< write reliability setting register[167] */
-    /*uint8_t rpmbSizeMult;*/                 /*!< RPMB size multi [168]*/
-    /*uint8_t fwConfig;*/                     /*!< FW configuration[169]*/
-    uint8_t userWP;                           /*!< user write protect register[171] */
-    uint8_t bootPartitionWP;                  /*!< boot write protect register[173]*/
-    uint8_t bootWPStatus;                     /*!< boot write protect status register[174]*/
-    uint8_t highDensityEraseGroupDefinition;  /*!< High-density erase group definition [175] */
-    uint8_t bootDataBusConditions;            /*!< Boot bus conditions [177] */
-    uint8_t bootConfigProtect;                /*!< Boot config protection [178]*/
-    uint8_t partitionConfig;                  /*!< Boot configuration [179] */
-    uint8_t eraseMemoryContent;               /*!< Erased memory content [181] */
-    uint8_t dataBusWidth;                     /*!< Data bus width mode [183] */
-    uint8_t highSpeedTiming;                  /*!< High-speed interface timing [185] */
-    uint8_t powerClass;                       /*!< Power class [187] */
-    uint8_t commandSetRevision;               /*!< Command set revision [189] */
-    uint8_t commandSet;                       /*!< Command set [191] */
-    uint8_t extendecCsdVersion;               /*!< Extended CSD revision [192] */
-    uint8_t csdStructureVersion;              /*!< CSD structure version [194] */
-    uint8_t cardType;                         /*!< Card Type [196] */
-    uint8_t ioDriverStrength;                 /*!< IO driver strength [197] */
-    /*uint8_t OutofInterruptBusyTiming;*/     /*!< out of interrupt busy timing [198] */
-    uint8_t partitionSwitchTimeout;           /*!< partition switch timing [199] */
-    uint8_t powerClass52MHz195V;              /*!< Power Class for 52MHz @ 1.95V [200] */
-    uint8_t powerClass26MHz195V;              /*!< Power Class for 26MHz @ 1.95V [201] */
-    uint8_t powerClass52MHz360V;              /*!< Power Class for 52MHz @ 3.6V [202] */
-    uint8_t powerClass26MHz360V;              /*!< Power Class for 26MHz @ 3.6V [203] */
-    uint8_t minimumReadPerformance4Bit26MHz;  /*!< Minimum Read Performance for 4bit at 26MHz [205] */
-    uint8_t minimumWritePerformance4Bit26MHz; /*!< Minimum Write Performance for 4bit at 26MHz [206] */
-    uint8_t minimumReadPerformance8Bit26MHz4Bit52MHz;
-    /*!< Minimum read Performance for 8bit at 26MHz/4bit @52MHz [207] */
-    uint8_t minimumWritePerformance8Bit26MHz4Bit52MHz;
-    /*!< Minimum Write Performance for 8bit at 26MHz/4bit @52MHz [208] */
-    uint8_t minimumReadPerformance8Bit52MHz;   /*!< Minimum Read Performance for 8bit at 52MHz [209] */
-    uint8_t minimumWritePerformance8Bit52MHz;  /*!< Minimum Write Performance for 8bit at 52MHz [210] */
-    uint32_t sectorCount;                      /*!< Sector Count [215:212] */
-    /*uint8_t sleepNotificationTimeout;*/      /*!< sleep notification timeout [216]*/
-    uint8_t sleepAwakeTimeout;                 /*!< Sleep/awake timeout [217] */
-    /*uint8_t productionStateAwareTimeout;*/   /*!< Production state awareness timeout [218]*/
-    uint8_t sleepCurrentVCCQ;                  /*!< Sleep current (VCCQ) [219] */
-    uint8_t sleepCurrentVCC;                   /*!< Sleep current (VCC) [220] */
-    uint8_t highCapacityWriteProtectGroupSize; /*!< High-capacity write protect group size [221] */
-    uint8_t reliableWriteSectorCount;          /*!< Reliable write sector count [222] */
-    uint8_t highCapacityEraseTimeout;          /*!< High-capacity erase timeout [223] */
-    uint8_t highCapacityEraseUnitSize;         /*!< High-capacity erase unit size [224] */
-    uint8_t accessSize;                        /*!< Access size [225] */
-    /*uint8_t secureTrimMultiplier;*/          /*!< secure trim multiplier[229]*/
-    /*uint8_t secureEraseMultiplier;*/         /*!< secure erase multiplier[230]*/
-    /*uint8_t secureFeatureSupport;*/          /*!< secure feature support[231]*/
-    /*uint32_t trimMultiplier;*/               /*!< trim multiplier[232]*/
-    uint8_t minReadPerformance8bitAt52MHZDDR;  /*!< Minimum read performance for 8bit at DDR 52MHZ[234]*/
-    uint8_t minWritePerformance8bitAt52MHZDDR; /*!< Minimum write performance for 8bit at DDR 52MHZ[235]*/
-    uint8_t powerClass200MHZVCCQ130VVCC360V;   /*!< power class for 200MHZ, at VCCQ= 1.3V,VCC=3.6V[236]*/
-    uint8_t powerClass200MHZVCCQ195VVCC360V;   /*!< power class for 200MHZ, at VCCQ= 1.95V,VCC=3.6V[237]*/
-    uint8_t powerClass52MHZDDR195V;            /*!< power class for 52MHZ,DDR at Vcc 1.95V[238]*/
-    uint8_t powerClass52MHZDDR360V;            /*!< power class for 52MHZ,DDR at Vcc 3.6V[239]*/
-    /*uint8_t iniTimeoutAP;*/                  /*!< 1st initialization time after partitioning[241]*/
-    /*uint32_t correctPrgSectorNum;*/          /*!< correct prg sectors number[245-242]*/
-    /*uint8_t bkOpsStatus;*/                   /*!< background operations status[246]*/
-    /*uint8_t powerOffNotifyTimeout;*/         /*!< power off notification timeout[247]*/
-    uint32_t genericCMD6Timeout;               /*!< generic CMD6 timeout[248]*/
-    uint32_t cacheSize;                        /*!< cache size[252-249]*/
-    uint8_t powerClass200MHZDDR360V;           /*!< power class for 200MHZ, DDR at VCC=2.6V[253]*/
-    /*uint32_t fwVer[2U];*/                    /*!< fw VERSION [261-254]*/
-    /*uint16_t deviceVer;*/                    /*!< device version[263-262]*/
-    /*uint8_t optimalTrimSize;*/               /*!< optimal trim size[264]*/
-    /*uint8_t optimalWriteSize;*/              /*!< optimal write size[265]*/
-    /*uint8_t optimalReadSize;*/               /*!< optimal read size[266]*/
-    /*uint8_t preEolInfo;*/                    /*!< pre EOL information[267]*/
-    /*uint8_t deviceLifeTimeEstimationA;*/     /*!< device life time estimation typeA[268]*/
-    /*uint8_t deviceLifeTimeEstimationB;*/     /*!< device life time estimation typeB[269]*/
-    /*uint32_t correctPrgFWSectorNum;*/        /*!< number of FW sectors correctly programmed[305-302]*/
-    /*uint32_t ffuArg;*/                       /*!< FFU argument[490-487]*/
-    /*uint8_t operationCodeTimeout;*/          /*!< operation code timeout[491]*/
-    /*uint8_t supportMode;*/                   /*!< support mode [493]*/
-    uint8_t extPartitionSupport;               /*!< extended partition attribute support[494]*/
-    /*uint8_t largeUnitSize;*/                 /*!< large unit size[495]*/
-    /*uint8_t contextManageCap;*/              /*!< context management capability[496]*/
-    /*uint8_t tagResourceSize;*/               /*!< tag resource size[497]*/
-    /*uint8_t tagUnitSize;*/                   /*!< tag unit size[498]*/
-    /*uint8_t maxPackedWriteCmd;*/             /*!< max packed write cmd[500]*/
-    /*uint8_t maxPackedReadCmd;*/              /*!< max packed read cmd[501]*/
-    /*uint8_t hpiFeature;*/                    /*!< HPI feature[503]*/
-    uint8_t supportedCommandSet;               /*!< Supported Command Sets [504] */
-    /*uint8_t extSecurityCmdError;*/           /*!< extended security commands error[505]*/
-} mmc_extended_csd_t;
-
-/*! @brief The bit shift for COMMAND SET field in SWITCH command. */
-#define MMC_SWITCH_COMMAND_SET_SHIFT (0U)
-/*! @brief The bit mask for COMMAND set field in SWITCH command. */
-#define MMC_SWITCH_COMMAND_SET_MASK (0x00000007U)
-/*! @brief The bit shift for VALUE field in SWITCH command */
-#define MMC_SWITCH_VALUE_SHIFT (8U)
-/*! @brief The bit mask for VALUE field in SWITCH command */
-#define MMC_SWITCH_VALUE_MASK (0x0000FF00U)
-/*! @brief The bit shift for BYTE INDEX field in SWITCH command */
-#define MMC_SWITCH_BYTE_INDEX_SHIFT (16U)
-/*! @brief The bit mask for BYTE INDEX field in SWITCH command */
-#define MMC_SWITCH_BYTE_INDEX_MASK (0x00FF0000U)
-/*! @brief The bit shift for ACCESS MODE field in SWITCH command */
-#define MMC_SWITCH_ACCESS_MODE_SHIFT (24U)
-/*! @brief The bit mask for ACCESS MODE field in SWITCH command */
-#define MMC_SWTICH_ACCESS_MODE_MASK (0x03000000U)
-
-/*! @brief MMC Extended CSD configuration. */
-typedef struct _mmc_extended_csd_config
-{
-    mmc_command_set_t commandSet;              /*!< Command set */
-    uint8_t ByteValue;                         /*!< The value to set */
-    uint8_t ByteIndex;                         /*!< The byte index in Extended CSD(mmc_extended_csd_index_t) */
-    mmc_extended_csd_access_mode_t accessMode; /*!< Access mode */
-} mmc_extended_csd_config_t;
-
-/*! @brief MMC card boot configuration definition. */
-typedef struct _mmc_boot_config
-{
-    mmc_boot_mode_t bootMode;                  /*!< mmc boot mode */
-    bool enableBootAck;                        /*!< Enable boot ACK */
-    mmc_boot_partition_enable_t bootPartition; /*!< Boot partition */
-
-    mmc_boot_timing_mode_t bootTimingMode; /*!< boot mode */
-    mmc_data_bus_width_t bootDataBusWidth; /*!< Boot data bus width */
-    bool retainBootbusCondition;           /*!< If retain boot bus width and boot mode conditions */
-
-    bool pwrBootConfigProtection;  /*!< Disable the change of boot configuration register bits from at this point
-                                   until next power cycle or next H/W reset operation */
-    bool premBootConfigProtection; /*!< Disable the change of boot configuration register bits permanently */
-
-    mmc_boot_partition_wp_t bootPartitionWP; /*!< boot partition write protect configurations */
-
-} mmc_boot_config_t;
-
-/* @} */
-
-#endif /* _FSL_SDMMC_SPEC_H_ */

+ 0 - 41
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/ChangeLogKSDK.txt

@@ -1,41 +0,0 @@
-/*!
-@page middleware_log Middleware Change Log
-
-@section host_sdif Host SDIF driver for MCUXpresso SDK
-The current driver version is 2.4.0.
-  - 2.4.0
-    - Improvements
-      - Removed deprecated api in SDIF host driver.
-      - Added SDMMCHOST_ConvertDataToLittleEndian api.
-      - Added capability/maxBlockCount/maxBlockSize in host decriptior.
-      - Added mutual exclusive access for function init/deinit/reset/transfer function.
-      - Fixed violations of MISRA C-2012 rule 10.1.
-
-  - 2.3.1
-    - Improvements
-      - Added host instance capability macro.
-      - Added clear card inserted/removed event when card removed/inserted interrupt generated.
-      - Increased the reset timeout value to fix the data machine still busy after sdif reset issue.
-      - Enabled the error recovery function by adding host reset operations.
-    - Bug Fixes
-      - Fixed violations of MISRA C-2012 rule 11.9, 15.7, 4.7, 16.4, 10.1, 10.3, 10.4, 11.3, 14.4, 10.6, 17.7, 16.1, 16.3.
-
-  - 2.3.0
-    - Improvements
-      - Merged the host controller driver from polling/freertos/interrupt to non_blocking/blocking.
-      - Added SDMMC OSA layer to support muxtex access/event/delay.
-
-
-  - 2.2.14
-    - Bug Fixes
-      - Fixed uninitialized value Coverity issue.
-
-  - 2.2.13
-    - Improvements:
-      - Added host reset after the card being powered on for host controller SDIF to fix the DATA_BUSY issue.
-      - Removed the SDIF_Reset from SDMMCHOST_Reset.
-
-  - 2.0.0
-    - Initial version
-
-*/

+ 0 - 238
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/blocking/fsl_sdmmc_host.c

@@ -1,238 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "fsl_sdmmc_host.h"
-#include "fsl_sdmmc_common.h"
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-#define SDMMCHOST_TRANSFER_COMPLETE_TIMEOUT (~0U)
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-/*!
- * @brief SDMMCHOST error recovery.
- * @param base host base address.
- */
-static void SDMMCHOST_ErrorRecovery(SDIF_Type *base);
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-status_t SDMMCHOST_CardIntInit(sdmmchost_t *host, void *sdioInt)
-{
-    host->cardInt = sdioInt;
-
-    return kStatus_Success;
-}
-
-status_t SDMMCHOST_CardDetectInit(sdmmchost_t *host, void *cd)
-{
-    if (cd == NULL)
-    {
-        return kStatus_Fail;
-    }
-
-    host->cd = cd;
-
-    return kStatus_Success;
-}
-
-uint32_t SDMMCHOST_CardDetectStatus(sdmmchost_t *host)
-{
-    SDIF_Type *base        = host->hostController.base;
-    sd_detect_card_t *sdCD = (sd_detect_card_t *)host->cd;
-
-#if defined(FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD) && FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD
-    if (((host->hostPort == 0U) &&
-         (SDIF_DetectCardInsert(base, sdCD->type == kSD_DetectCardByHostDATA3 ? true : false) == 1U)) ||
-        ((host->hostPort == 1U) &&
-         (SDIF_DetectCard1Insert(base, sdCD->type == kSD_DetectCardByHostDATA3 ? true : false) == 1U)))
-#else
-    if ((host->hostPort == 0U) &&
-        (SDIF_DetectCardInsert(base, sdCD->type == kSD_DetectCardByHostDATA3 ? true : false) == 1U))
-#endif
-    {
-        return kSD_Inserted;
-    }
-
-    return kSD_Removed;
-}
-
-status_t SDMMCHOST_PollingCardDetectStatus(sdmmchost_t *host, uint32_t waitCardStatus, uint32_t timeout)
-{
-    assert(host != NULL);
-    assert(host->cd != NULL);
-
-    sd_detect_card_t *cd        = host->cd;
-    uint32_t cardInsertedStatus = kSD_Removed;
-
-    /* Wait card inserted. */
-    do
-    {
-        cardInsertedStatus = SDMMCHOST_CardDetectStatus(host);
-
-        if ((waitCardStatus == (uint32_t)kSD_Inserted) && (cardInsertedStatus == (uint32_t)kSD_Inserted))
-        {
-            SDMMC_OSADelay(cd->cdDebounce_ms);
-            if (SDMMCHOST_CardDetectStatus(host) == (uint32_t)kSD_Inserted)
-            {
-                break;
-            }
-        }
-
-        if ((cardInsertedStatus == (uint32_t)kSD_Removed) && (waitCardStatus == (uint32_t)kSD_Removed))
-        {
-            break;
-        }
-    } while (true);
-
-    return kStatus_Success;
-}
-
-status_t SDMMCHOST_TransferFunction(sdmmchost_t *host, sdmmchost_transfer_t *content)
-{
-    status_t error = kStatus_Success;
-    sdif_dma_config_t dmaConfig;
-
-    (void)memset(&dmaConfig, 0, sizeof(dmaConfig));
-
-    /* user DMA mode transfer data */
-    if (content->data != NULL)
-    {
-        dmaConfig.enableFixBurstLen     = false;
-        dmaConfig.mode                  = kSDIF_ChainDMAMode;
-        dmaConfig.dmaDesBufferStartAddr = host->dmaDesBuffer;
-        dmaConfig.dmaDesBufferLen       = host->dmaDesBufferWordsNum;
-        dmaConfig.dmaDesSkipLen         = 0U;
-    }
-
-    error = SDIF_TransferBlocking(host->hostController.base, &dmaConfig, content);
-
-    if (error != kStatus_Success)
-    {
-        error = kStatus_Fail;
-        /* host error recovery */
-        SDMMCHOST_ErrorRecovery(host->hostController.base);
-    }
-
-    return error;
-}
-
-static void SDMMCHOST_ErrorRecovery(SDIF_Type *base)
-{
-    (void)SDIF_Reset(base, kSDIF_ResetAll, SDMMCHOST_RESET_TIMEOUT_VALUE);
-    /* the host controller clock will be disabled by the reset operation, so re-send the clock sync command to enable
-    the output clock */
-    sdif_command_t clockSync = {
-        .flags = kSDIF_WaitPreTransferComplete | kSDIF_CmdUpdateClockRegisterOnly, .index = 0U, .argument = 0U};
-    (void)SDIF_SendCommand(base, &clockSync, 0U);
-}
-
-void SDMMCHOST_SetCardPower(sdmmchost_t *host, bool enable)
-{
-    if (host->hostPort == 0U)
-    {
-        SDIF_EnableCardPower(host->hostController.base, enable);
-    }
-#if defined(FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD) && FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD
-    else
-    {
-        SDIF_EnableCard1Power(host->hostController.base, enable);
-    }
-#endif
-
-    if (enable)
-    {
-        /* perform SDIF host controller reset only when DATA BUSY is assert */
-        if ((SDIF_GetControllerStatus(host->hostController.base) & SDIF_STATUS_DATA_BUSY_MASK) != 0U)
-        {
-            (void)SDIF_Reset(host->hostController.base, kSDIF_ResetAll, SDMMCHOST_RESET_TIMEOUT_VALUE);
-        }
-    }
-}
-
-void SDMMCHOST_ConvertDataToLittleEndian(sdmmchost_t *host, uint32_t *data, uint32_t wordSize, uint32_t format)
-{
-    uint32_t temp = 0U;
-
-    if (format == kSDMMC_DataPacketFormatMSBFirst)
-    {
-        for (uint32_t i = 0U; i < wordSize; i++)
-        {
-            temp    = data[i];
-            data[i] = SWAP_WORD_BYTE_SEQUENCE(temp);
-        }
-    }
-}
-
-status_t SDMMCHOST_Init(sdmmchost_t *host)
-{
-    assert(host != NULL);
-
-    sdif_host_t *sdifHost = &(host->hostController);
-
-    /* sdmmc osa init */
-    SDMMC_OSAInit();
-    /* host capability flags */
-    host->capability = (uint32_t)kSDMMCHOST_SupportHighSpeed | (uint32_t)kSDMMCHOST_SupportSuspendResume |
-                       (uint32_t)kSDMMCHOST_SupportVoltage3v3 | (uint32_t)kSDMMCHOST_Support4BitDataWidth |
-                       (uint32_t)kSDMMCHOST_Support8BitDataWidth | (uint32_t)kSDMMCHOST_SupportDetectCardByData3 |
-                       (uint32_t)kSDMMCHOST_SupportDetectCardByCD | (uint32_t)kSDMMCHOST_SupportAutoCmd12;
-    host->maxBlockCount = SDMMCHOST_SUPPORT_MAX_BLOCK_COUNT;
-    host->maxBlockSize  = SDMMCHOST_SUPPORT_MAX_BLOCK_LENGTH;
-    /* Initialize SDIF. */
-    sdifHost->config.responseTimeout       = 0xFFU;
-    sdifHost->config.cardDetDebounce_Clock = 0xFFFFFFU;
-    sdifHost->config.dataTimeout           = 0xFFFFFFU;
-    SDIF_Init(sdifHost->base, &(sdifHost->config));
-
-    return kStatus_Success;
-}
-
-void SDMMCHOST_Reset(sdmmchost_t *host)
-{
-    /* disable all the interrupt */
-    SDIF_DisableInterrupt(host->hostController.base, kSDIF_AllInterruptStatus);
-    /* make sure host controller release all the bus line. */
-    (void)SDIF_Reset(host->hostController.base, kSDIF_ResetAll, 100);
-    /* clear all interrupt/DMA status */
-    SDIF_ClearInterruptStatus(host->hostController.base, kSDIF_AllInterruptStatus);
-    SDIF_ClearInternalDMAStatus(host->hostController.base, kSDIF_DMAAllStatus);
-}
-
-void SDMMCHOST_SetCardBusWidth(sdmmchost_t *host, uint32_t dataBusWidth)
-{
-    if (host->hostPort == 0U)
-    {
-        SDIF_SetCardBusWidth(host->hostController.base, dataBusWidth == (uint32_t)kSDMMC_BusWdith1Bit ?
-                                                            kSDIF_Bus1BitWidth :
-                                                            dataBusWidth == (uint32_t)kSDMMC_BusWdith4Bit ?
-                                                            kSDIF_Bus4BitWidth :
-                                                            kSDIF_Bus8BitWidth);
-    }
-#if defined(FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD) && FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD
-    else
-    {
-        SDIF_SetCard1BusWidth(host->hostController.base, dataBusWidth == (uint32_t)kSDMMC_BusWdith1Bit ?
-                                                             kSDIF_Bus1BitWidth :
-                                                             dataBusWidth == (uint32_t)kSDMMC_BusWdith4Bit ?
-                                                             kSDIF_Bus4BitWidth :
-                                                             kSDIF_Bus8BitWidth);
-    }
-#endif
-}
-
-void SDMMCHOST_Deinit(sdmmchost_t *host)
-{
-    sdif_host_t *sdifHost = &host->hostController;
-    SDIF_Deinit(sdifHost->base);
-}

+ 0 - 405
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/fsl_sdmmc_host.h

@@ -1,405 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _FSL_SDMMC_HOST_H
-#define _FSL_SDMMC_HOST_H
-
-#include "fsl_common.h"
-#include "fsl_sdif.h"
-#include "fsl_sdmmc_osa.h"
-/*!
- * @addtogroup  sdmmchost_sdif SDIF HOST Adapter Driver
- * @ingroup sdmmchost
- * @{
- */
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*! @brief Middleware adapter version. */
-#define FSL_SDMMC_HOST_ADAPTER_VERSION (MAKE_VERSION(2U, 4U, 0U)) /*2.4.0*/
-
-/*! @brief sdmmc host capability */
-enum
-{
-    kSDMMCHOST_SupportHighSpeed         = 1U << 0U,  /*!< high speed capability */
-    kSDMMCHOST_SupportSuspendResume     = 1U << 1U,  /*!< suspend resume capability */
-    kSDMMCHOST_SupportVoltage3v3        = 1U << 2U,  /*!< 3V3 capability */
-    kSDMMCHOST_SupportVoltage3v0        = 1U << 3U,  /*!< 3V0 capability */
-    kSDMMCHOST_SupportVoltage1v8        = 1U << 4U,  /*!< 1V8 capability */
-    kSDMMCHOST_SupportVoltage1v2        = 1U << 5U,  /*!< 1V2 capability */
-    kSDMMCHOST_Support4BitDataWidth     = 1U << 6U,  /*!< 4 bit data width capability */
-    kSDMMCHOST_Support8BitDataWidth     = 1U << 7U,  /*!< 8 bit data width capability */
-    kSDMMCHOST_SupportDDRMode           = 1U << 8U,  /*!< DDR mode capability */
-    kSDMMCHOST_SupportDetectCardByData3 = 1U << 9U,  /*!< data3 detect card capability */
-    kSDMMCHOST_SupportDetectCardByCD    = 1U << 10U, /*!< CD detect card capability */
-    kSDMMCHOST_SupportAutoCmd12         = 1U << 11U, /*!< auto command 12 capability */
-    kSDMMCHOST_SupportSDR104            = 1U << 12U, /*!< SDR104 capability */
-    kSDMMCHOST_SupportSDR50             = 1U << 13U, /*!< SDR50 capability */
-    kSDMMCHOST_SupportHS200             = 1U << 14U, /*!< HS200 capability */
-    kSDMMCHOST_SupportHS400             = 1U << 15U, /*!< HS400 capability */
-};
-
-/*!@brief host capability */
-#define SDMMCHOST_SUPPORT_HIGH_SPEED           (1U)
-#define SDMMCHOST_SUPPORT_SUSPEND_RESUME       (1U)
-#define SDMMCHOST_SUPPORT_VOLTAGE_3V3          (1U)
-#define SDMMCHOST_SUPPORT_VOLTAGE_3V0          (0U)
-#define SDMMCHOST_SUPPORT_VOLTAGE_1V8          (0U)
-#define SDMMCHOST_SUPPORT_VOLTAGE_1V2          (0U)
-#define SDMMCHOST_SUPPORT_4_BIT_WIDTH          (1U)
-#define SDMMCHOST_SUPPORT_8_BIT_WIDTH          (1U)
-#define SDMMCHOST_SUPPORT_DDR50                (0U)
-#define SDMMCHOST_SUPPORT_SDR104               (0U)
-#define SDMMCHOST_SUPPORT_SDR50                (0U)
-#define SDMMCHOST_SUPPORT_HS200                (0U)
-#define SDMMCHOST_SUPPORT_HS400                (0U)
-#define SDMMCHOST_SUPPORT_DETECT_CARD_BY_DATA3 (1U)
-#define SDMMCHOST_SUPPORT_DETECT_CARD_BY_CD    (1U)
-#define SDMMCHOST_SUPPORT_AUTO_CMD12           (1U)
-#define SDMMCHOST_SUPPORT_MAX_BLOCK_LENGTH     (SDIF_BLKSIZ_BLOCK_SIZE_MASK)
-#define SDMMCHOST_SUPPORT_MAX_BLOCK_COUNT      (SDIF_BYTCNT_BYTE_COUNT_MASK / SDIF_BLKSIZ_BLOCK_SIZE_MASK)
-/*! @brief sdmmc host instance capability */
-#define SDMMCHOST_INSTANCE_SUPPORT_8_BIT_WIDTH(host) 1U
-#define SDMMCHOST_INSTANCE_SUPPORT_HS400(host)       0U
-#define SDMMCHOST_INSTANCE_SUPPORT_1V8_SIGNAL(host)  0U
-#define SDMMCHOST_INSTANCE_SUPPORT_HS200(host)       0U
-#define SDMMCHOST_INSTANCE_SUPPORT_SDR104(host)      0U
-#define SDMMCHOST_INSTANCE_SUPPORT_SDR50(host)       0U
-#define SDMMCHOST_INSTANCE_SUPPORT_DDR50(host)       0U
-
-/*!@brief SDMMC host dma descriptor buffer address align size */
-#define SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE (4U)
-/*! @brief SDMMC host reset timoue value */
-#define SDMMCHOST_RESET_TIMEOUT_VALUE (1000000U)
-
-/*! @brief host Endian mode
- * corresponding to driver define
- */
-enum _sdmmchost_endian_mode
-{
-    kSDMMCHOST_EndianModeBig         = 0U, /*!< Big endian mode */
-    kSDMMCHOST_EndianModeHalfWordBig = 1U, /*!< Half word big endian mode */
-    kSDMMCHOST_EndianModeLittle      = 2U, /*!< Little endian mode */
-};
-
-/*!@brief sdmmc host transfer function */
-typedef sdif_transfer_t sdmmchost_transfer_t;
-typedef sdif_command_t sdmmchost_cmd_t;
-typedef sdif_data_t sdmmchost_data_t;
-typedef struct _sdmmchost_ SDMMCHOST_CONFIG;
-typedef SDIF_Type SDMMCHOST_TYPE;
-typedef void sdmmchost_detect_card_t;
-typedef void sdmmchost_boot_config_t;
-
-/*!@brief sdmmc host handler  */
-typedef struct _sdmmchost_
-{
-    sdif_host_t hostController;    /*!< host configuration */
-    uint8_t hostPort;              /*!< host port number, used for one instance support two card */
-    void *dmaDesBuffer;            /*!< DMA descriptor buffer address */
-    uint32_t dmaDesBufferWordsNum; /*!< DMA descriptor buffer size in byte */
-    sdif_handle_t handle;          /*!< host controller handler */
-
-    uint32_t capability;    /*!< host controller capability */
-    uint32_t maxBlockCount; /*!< host controller maximum block count */
-    uint32_t maxBlockSize;  /*!< host controller maximum block size */
-
-    sdmmc_osa_event_t hostEvent; /*!< host event handler */
-    void *cd;                    /*!< card detect */
-    void *cardInt;               /*!< call back function for card interrupt */
-    sdmmc_osa_mutex_t lock;      /*!< host access lock */
-} sdmmchost_t;
-
-/*******************************************************************************
- * API
- ******************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/*!
- * @name SDIF host controller function
- * @{
- */
-
-/*!
- * @brief set data bus width.
- * @param host host handler
- * @param dataBusWidth data bus width
- */
-void SDMMCHOST_SetCardBusWidth(sdmmchost_t *host, uint32_t dataBusWidth);
-
-/*!
- * @brief Send initilization active 80 clocks to card.
- * @param host host handler
- */
-static inline void SDMMCHOST_SendCardActive(sdmmchost_t *host)
-{
-    SDIF_SendCardActive(host->hostController.base, 100U);
-}
-
-/*!
- * @brief Set card bus clock.
- * @param host host handler
- * @param targetClock target clock frequency
- * @retval actual clock frequency can be reach.
- */
-static inline uint32_t SDMMCHOST_SetCardClock(sdmmchost_t *host, uint32_t targetClock)
-{
-    return SDIF_SetCardClock(host->hostController.base, host->hostController.sourceClock_Hz, targetClock);
-}
-
-/*!
- * @brief check card status by DATA0.
- * @param host host handler
- * @retval true is busy, false is idle.
- */
-static inline bool SDMMCHOST_IsCardBusy(sdmmchost_t *host)
-{
-    return (SDIF_GetControllerStatus(host->hostController.base) & SDIF_STATUS_DATA_BUSY_MASK) ==
-                   SDIF_STATUS_DATA_BUSY_MASK ?
-               true :
-               false;
-}
-
-/*!
- * @brief start read boot data.
- * @param host host handler
- * @param hostConfig boot configuration
- * @param cmd boot command
- * @param buffer buffer address
- */
-static inline status_t SDMMCHOST_StartBoot(sdmmchost_t *host,
-                                           sdmmchost_boot_config_t *hostConfig,
-                                           sdmmchost_cmd_t *cmd,
-                                           uint8_t *buffer)
-{
-    /* host not support */
-    return kStatus_Fail;
-}
-
-/*!
- * @brief read boot data.
- * @param host host handler
- * @param hostConfig boot configuration
- * @param buffer buffer address
- */
-static inline status_t SDMMCHOST_ReadBootData(sdmmchost_t *host, sdmmchost_boot_config_t *hostConfig, uint8_t *buffer)
-{
-    /* host not support */
-    return kStatus_Fail;
-}
-
-/*!
- * @brief enable boot mode.
- * @param host host handler
- * @param enable true is enable, false is disable
- */
-static inline void SDMMCHOST_EnableBoot(sdmmchost_t *host, bool enable)
-{
-    /* not support */
-}
-
-/*!
- * @brief enable card interrupt.
- * @param host host handler
- * @param enable true is enable, false is disable.
- */
-static inline void SDMMCHOST_EnableCardInt(sdmmchost_t *host, bool enable)
-{
-    if (enable)
-    {
-        SDIF_EnableInterrupt(host->hostController.base, kSDIF_SDIOInterrupt);
-    }
-    else
-    {
-        SDIF_DisableInterrupt(host->hostController.base, kSDIF_SDIOInterrupt);
-    }
-}
-
-/*!
- * @brief card interrupt function.
- * @param host host handler
- * @param sdioInt card interrupt configuration
- */
-status_t SDMMCHOST_CardIntInit(sdmmchost_t *host, void *sdioInt);
-
-/*!
- * @brief card detect init function.
- * @param host host handler
- * @param cd card detect configuration
- */
-status_t SDMMCHOST_CardDetectInit(sdmmchost_t *host, void *cd);
-
-/*!
- * @brief Detect card insert, only need for SD cases.
- * @param host host handler
- * @param waitCardStatus status which user want to wait
- * @param timeout wait time out.
- * @retval kStatus_Success detect card insert
- * @retval kStatus_Fail card insert event fail
- */
-status_t SDMMCHOST_PollingCardDetectStatus(sdmmchost_t *host, uint32_t waitCardStatus, uint32_t timeout);
-
-/*!
- * @brief card detect status.
- * @param host host handler
- * @retval kSD_Inserted, kSD_Removed
- */
-uint32_t SDMMCHOST_CardDetectStatus(sdmmchost_t *host);
-
-/*!
- * @brief Init host controller.
- *
- * Thread safe function, please note that the function will create the mutex lock dynamically by default,
- * so to avoid the mutex create redundantly, application must follow bellow sequence for card re-initialization
- * @code
- * SDMMCHOST_Deinit(host);
- * SDMMCHOST_Init(host);
- * @endcode
- *
- * @param host host handler
- * @retval kStatus_Success host init success
- * @retval kStatus_Fail event fail
- */
-status_t SDMMCHOST_Init(sdmmchost_t *host);
-
-/*!
- * @brief Deinit host controller.
- *
- * Please note it is a thread safe function.
- *
- * @param host host handler
- */
-void SDMMCHOST_Deinit(sdmmchost_t *host);
-
-/*!
- * @brief host power off card function.
- * @param host host handler
- * @param enable true is power on, false is power down.
- */
-void SDMMCHOST_SetCardPower(sdmmchost_t *host, bool enable);
-
-/*!
- * @brief host transfer function.
- *
- * Please note it is a thread safe function.
- *
- * @param host host handler
- * @param content transfer content.
- */
-status_t SDMMCHOST_TransferFunction(sdmmchost_t *host, sdmmchost_transfer_t *content);
-
-/*!
- * @brief host reset function.
- *
- * Please note it is a thread safe function.
- *
- * @param host host handler
- */
-void SDMMCHOST_Reset(sdmmchost_t *host);
-
-/*!
- * @brief switch to voltage.
- * @param host host handler
- * @param voltage switch to voltage level.
- */
-static inline void SDMMCHOST_SwitchToVoltage(sdmmchost_t *host, uint32_t voltage)
-{
-    /* host not support */
-}
-
-/*!
- * @brief sdmmc host excute tuning.
- *
- * @param host host handler
- * @param tuningCmd tuning command.
- * @param revBuf receive buffer pointer
- * @param blockSize tuning data block size.
- */
-static inline status_t SDMMCHOST_ExecuteTuning(sdmmchost_t *host,
-                                               uint32_t tuningCmd,
-                                               uint32_t *revBuf,
-                                               uint32_t blockSize)
-{
-    /* host not support */
-    return kStatus_Fail;
-}
-
-/*!
- * @brief enable DDR mode.
- * @param host host handler
- * @param enable true is enable, false is disable.
- * @param nibblePos nibble position indictation. 0- the sequence is 'odd high nibble -> even high nibble ->
- * odd low nibble -> even low nibble'; 1- the sequence is 'odd high nibble -> odd low nibble -> even high
- * nibble -> even low nibble'.
- */
-static inline void SDMMCHOST_EnableDDRMode(sdmmchost_t *host, bool enable, uint32_t nibblePos)
-{
-    /* host not support */
-}
-
-/*!
- * @brief enable HS400 mode.
- * @param host host handler
- * @param enable true is enable, false is disable.
- */
-static inline void SDMMCHOST_EnableHS400Mode(sdmmchost_t *host, bool enable)
-{
-    /* host not support */
-}
-
-/*!
- * @brief enable STROBE DLL.
- * @param host host handler
- * @param enable true is enable, false is disable.
- */
-static inline void SDMMCHOST_EnableStrobeDll(sdmmchost_t *host, bool enable)
-{
-    /* host not support */
-}
-
-/*!
- * @brief Get signal line status.
- * @param host host handler
- * @param signalLine signal line type, reference _sdmmc_signal_line
- */
-static inline uint32_t SDMMCHOST_GetSignalLineStatus(sdmmchost_t *host, uint32_t signalLine)
-{
-    /* host not support */
-    return 0U;
-}
-
-/*!
- * @brief force card clock on.
- * @param host host handler
- * @param enable true is enable, false is disable.
- */
-static inline void SDMMCHOST_ForceClockOn(sdmmchost_t *host, bool enable)
-{
-    /* host not support */
-}
-
-/*!
- * @brief sdmmc host convert data sequence to little endian sequence
- *
- * @param host host handler.
- * @param data data buffer address.
- * @param wordSize data buffer size in word.
- * @param format data packet format.
- */
-void SDMMCHOST_ConvertDataToLittleEndian(sdmmchost_t *host, uint32_t *data, uint32_t wordSize, uint32_t format);
-
-/* @} */
-
-#if defined(__cplusplus)
-}
-#endif
-/* @} */
-#endif /* _FSL_SDMMC_HOST_H */

+ 0 - 457
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/host/sdif/non_blocking/fsl_sdmmc_host.c

@@ -1,457 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "fsl_sdmmc_host.h"
-#include "fsl_sdmmc_common.h"
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-#define SDMMCHOST_TRANSFER_COMPLETE_TIMEOUT (~0U)
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-/*!
- * @brief SDMMCHOST detect card insert status by host controller.
- * @param base host base address.
- * @param userData user can register a application card insert callback through userData.
- */
-static void SDMMCHOST_DetectCardInsertByHost(SDIF_Type *base, void *userData);
-
-/*!
- * @brief SDMMCHOST detect card remove status by host controller.
- * @param base host base address.
- * @param userData user can register a application card insert callback through userData.
- */
-static void SDMMCHOST_DetectCardRemoveByHost(SDIF_Type *base, void *userData);
-
-/*!
- * @brief SDMMCHOST transfer complete callback.
- * @param base host base address.
- * @param handle host handle.
- * @param status interrupt status.
- * @param userData user data.
- */
-static void SDMMCHOST_TransferCompleteCallback(SDIF_Type *base, void *handle, status_t status, void *userData);
-
-/*!
- * @brief SDMMCHOST error recovery.
- * @param base host base address.
- */
-static void SDMMCHOST_ErrorRecovery(SDIF_Type *base);
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-static void SDMMCHOST_DetectCardInsertByHost(SDIF_Type *base, void *userData)
-{
-    sd_detect_card_t *cd = NULL;
-
-    (void)SDMMC_OSAEventSet(&(((sdmmchost_t *)userData)->hostEvent), SDMMC_OSA_EVENT_CARD_INSERTED);
-    (void)SDMMC_OSAEventClear(&(((sdmmchost_t *)userData)->hostEvent), SDMMC_OSA_EVENT_CARD_REMOVED);
-
-    if (userData != NULL)
-    {
-        cd = (sd_detect_card_t *)(((sdmmchost_t *)userData)->cd);
-        if (cd != NULL)
-        {
-            if (cd->callback != NULL)
-            {
-                cd->callback(true, cd->userData);
-            }
-        }
-    }
-}
-
-static void SDMMCHOST_DetectCardRemoveByHost(SDIF_Type *base, void *userData)
-{
-    sd_detect_card_t *cd = NULL;
-
-    (void)SDMMC_OSAEventSet(&(((sdmmchost_t *)userData)->hostEvent), SDMMC_OSA_EVENT_CARD_REMOVED);
-    (void)SDMMC_OSAEventClear(&(((sdmmchost_t *)userData)->hostEvent), SDMMC_OSA_EVENT_CARD_INSERTED);
-
-    if (userData != NULL)
-    {
-        cd = (sd_detect_card_t *)(((sdmmchost_t *)userData)->cd);
-        if (cd != NULL)
-        {
-            if (cd->callback != NULL)
-            {
-                cd->callback(false, cd->userData);
-            }
-        }
-    }
-}
-
-static void SDMMCHOST_CardInterrupt(SDIF_Type *base, void *userData)
-{
-    sdio_card_int_t *cardInt = NULL;
-
-    /* application callback */
-    if (userData != NULL)
-    {
-        cardInt = ((sdmmchost_t *)userData)->cardInt;
-        if ((cardInt != NULL) && (cardInt->cardInterrupt != NULL))
-        {
-            cardInt->cardInterrupt(cardInt->userData);
-        }
-    }
-}
-
-status_t SDMMCHOST_CardIntInit(sdmmchost_t *host, void *sdioInt)
-{
-    host->cardInt                       = sdioInt;
-    host->handle.callback.SDIOInterrupt = SDMMCHOST_CardInterrupt;
-    SDMMCHOST_EnableCardInt(host, true);
-
-    return kStatus_Success;
-}
-
-status_t SDMMCHOST_CardDetectInit(sdmmchost_t *host, void *cd)
-{
-    SDIF_Type *base        = host->hostController.base;
-    sd_detect_card_t *sdCD = (sd_detect_card_t *)cd;
-    if (cd == NULL)
-    {
-        return kStatus_Fail;
-    }
-
-    host->cd = cd;
-
-    /* enable card detect interrupt */
-    SDIF_EnableInterrupt(base, kSDIF_CardDetect);
-
-    if (SDMMCHOST_CardDetectStatus(host) == (uint32_t)kSD_Inserted)
-    {
-        (void)SDMMC_OSAEventSet(&(host->hostEvent), SDMMC_OSA_EVENT_CARD_INSERTED);
-        /* notify application about the card insertion status */
-        if (sdCD->callback != NULL)
-        {
-            sdCD->callback(true, sdCD->userData);
-        }
-    }
-    else
-    {
-        (void)SDMMC_OSAEventSet(&(host->hostEvent), SDMMC_OSA_EVENT_CARD_REMOVED);
-    }
-
-    return kStatus_Success;
-}
-
-uint32_t SDMMCHOST_CardDetectStatus(sdmmchost_t *host)
-{
-    SDIF_Type *base        = host->hostController.base;
-    sd_detect_card_t *sdCD = (sd_detect_card_t *)host->cd;
-
-#if defined(FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD) && FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD
-    if (((host->hostPort == 0U) &&
-         (SDIF_DetectCardInsert(base, sdCD->type == kSD_DetectCardByHostDATA3 ? true : false) == 1U)) ||
-        ((host->hostPort == 1U) &&
-         (SDIF_DetectCard1Insert(base, sdCD->type == kSD_DetectCardByHostDATA3 ? true : false) == 1U)))
-#else
-    if ((host->hostPort == 0U) &&
-        (SDIF_DetectCardInsert(base, sdCD->type == kSD_DetectCardByHostDATA3 ? true : false) == 1U))
-#endif
-    {
-        return kSD_Inserted;
-    }
-
-    return kSD_Removed;
-}
-
-status_t SDMMCHOST_PollingCardDetectStatus(sdmmchost_t *host, uint32_t waitCardStatus, uint32_t timeout)
-{
-    assert(host != NULL);
-    assert(host->cd != NULL);
-
-    sd_detect_card_t *cd = host->cd;
-    uint32_t event       = 0U;
-
-    (void)SDMMC_OSAEventGet(&(host->hostEvent), SDMMC_OSA_EVENT_CARD_INSERTED | SDMMC_OSA_EVENT_CARD_REMOVED, &event);
-    if ((((event & SDMMC_OSA_EVENT_CARD_INSERTED) == SDMMC_OSA_EVENT_CARD_INSERTED) &&
-         (waitCardStatus == (uint32_t)kSD_Inserted)) ||
-        (((event & SDMMC_OSA_EVENT_CARD_REMOVED) == SDMMC_OSA_EVENT_CARD_REMOVED) &&
-         (waitCardStatus == (uint32_t)kSD_Removed)))
-    {
-        return kStatus_Success;
-    }
-
-    /* Wait card inserted. */
-    do
-    {
-        if (SDMMC_OSAEventWait(&(host->hostEvent), SDMMC_OSA_EVENT_CARD_INSERTED | SDMMC_OSA_EVENT_CARD_REMOVED,
-                               timeout, &event) != kStatus_Success)
-        {
-            return kStatus_Fail;
-        }
-        else
-        {
-            if ((waitCardStatus == (uint32_t)kSD_Inserted) &&
-                ((event & SDMMC_OSA_EVENT_CARD_INSERTED) == SDMMC_OSA_EVENT_CARD_INSERTED))
-            {
-                SDMMC_OSADelay(cd->cdDebounce_ms);
-                if (SDMMCHOST_CardDetectStatus(host) == (uint32_t)kSD_Inserted)
-                {
-                    break;
-                }
-            }
-
-            if (((event & SDMMC_OSA_EVENT_CARD_REMOVED) == SDMMC_OSA_EVENT_CARD_REMOVED) &&
-                (waitCardStatus == (uint32_t)kSD_Removed))
-            {
-                break;
-            }
-        }
-    } while (true);
-
-    return kStatus_Success;
-}
-
-static void SDMMCHOST_TransferCompleteCallback(SDIF_Type *base, void *handle, status_t status, void *userData)
-{
-    uint32_t eventStatus = 0U;
-
-    if (status == kStatus_SDIF_DataTransferFail)
-    {
-        eventStatus = SDMMC_OSA_EVENT_TRANSFER_DATA_FAIL;
-    }
-    else if (status == kStatus_SDIF_DataTransferSuccess)
-    {
-        eventStatus = SDMMC_OSA_EVENT_TRANSFER_DATA_SUCCESS;
-    }
-    else if (status == kStatus_SDIF_SendCmdFail)
-    {
-        eventStatus = SDMMC_OSA_EVENT_TRANSFER_CMD_FAIL;
-    }
-    else
-    {
-        eventStatus = SDMMC_OSA_EVENT_TRANSFER_CMD_SUCCESS;
-    }
-
-    (void)SDMMC_OSAEventSet(&(((sdmmchost_t *)userData)->hostEvent), eventStatus);
-}
-
-status_t SDMMCHOST_TransferFunction(sdmmchost_t *host, sdmmchost_transfer_t *content)
-{
-    status_t error = kStatus_Success;
-    uint32_t event = 0U;
-    sdif_dma_config_t dmaConfig;
-
-    SDMMC_OSAMutexLock(&host->lock, osaWaitForever_c);
-
-    /* clear redundant transfer event flag */
-    (void)SDMMC_OSAEventClear(&(host->hostEvent),
-                              SDMMC_OSA_EVENT_TRANSFER_CMD_SUCCESS | SDMMC_OSA_EVENT_TRANSFER_CMD_FAIL |
-                                  SDMMC_OSA_EVENT_TRANSFER_DATA_SUCCESS | SDMMC_OSA_EVENT_TRANSFER_DATA_FAIL);
-
-    /* user DMA mode transfer data */
-    if (content->data != NULL)
-    {
-        (void)memset(&dmaConfig, 0, sizeof(dmaConfig));
-
-        dmaConfig.enableFixBurstLen     = false;
-        dmaConfig.mode                  = kSDIF_DualDMAMode;
-        dmaConfig.dmaDesBufferStartAddr = host->dmaDesBuffer;
-        dmaConfig.dmaDesBufferLen       = host->dmaDesBufferWordsNum;
-        dmaConfig.dmaDesSkipLen         = 0U;
-    }
-
-    do
-    {
-        error = SDIF_TransferNonBlocking(host->hostController.base, &host->handle, &dmaConfig, content);
-    } while (error == kStatus_SDIF_SyncCmdTimeout);
-
-    if (error == kStatus_Success)
-    {
-        /* wait command event */
-        if ((kStatus_Fail ==
-             SDMMC_OSAEventWait(&(host->hostEvent),
-                                SDMMC_OSA_EVENT_TRANSFER_CMD_SUCCESS | SDMMC_OSA_EVENT_TRANSFER_CMD_FAIL |
-                                    SDMMC_OSA_EVENT_TRANSFER_DATA_SUCCESS | SDMMC_OSA_EVENT_TRANSFER_DATA_FAIL,
-                                SDMMCHOST_TRANSFER_COMPLETE_TIMEOUT, &event)) ||
-            ((event & SDMMC_OSA_EVENT_TRANSFER_CMD_FAIL) != 0U))
-        {
-            error = kStatus_Fail;
-        }
-        else
-        {
-            if (content->data != NULL)
-            {
-                if ((event & SDMMC_OSA_EVENT_TRANSFER_DATA_SUCCESS) == 0U)
-                {
-                    if (((event & SDMMC_OSA_EVENT_TRANSFER_DATA_FAIL) != 0U) ||
-                        (kStatus_Fail == SDMMC_OSAEventWait(
-                                             &(host->hostEvent),
-                                             SDMMC_OSA_EVENT_TRANSFER_DATA_SUCCESS | SDMMC_OSA_EVENT_TRANSFER_DATA_FAIL,
-                                             SDMMCHOST_TRANSFER_COMPLETE_TIMEOUT, &event) ||
-                         ((event & SDMMC_OSA_EVENT_TRANSFER_DATA_FAIL) != 0U)))
-                    {
-                        error = kStatus_Fail;
-                    }
-                }
-            }
-        }
-    }
-    /*
-     * error = kStatus_SDIF_DescriptorBufferLenError means that the DMA descriptor buffer not len enough for current
-     * transfer, application should assign a bigger descriptor memory space.
-     */
-    if (error != kStatus_Success)
-    {
-        error = kStatus_Fail;
-        /* host error recovery */
-        SDMMCHOST_ErrorRecovery(host->hostController.base);
-    }
-
-    SDMMC_OSAMutexUnlock(&host->lock);
-
-    return error;
-}
-
-static void SDMMCHOST_ErrorRecovery(SDIF_Type *base)
-{
-    (void)SDIF_Reset(base, kSDIF_ResetAll, SDMMCHOST_RESET_TIMEOUT_VALUE);
-
-    /* the host controller clock will be disabled by the reset operation, so re-send the clock sync command to enable
-    the output clock */
-    sdif_command_t clockSync = {
-        .flags = kSDIF_WaitPreTransferComplete | kSDIF_CmdUpdateClockRegisterOnly, .index = 0U, .argument = 0U};
-    (void)SDIF_SendCommand(base, &clockSync, 0U);
-}
-
-void SDMMCHOST_SetCardPower(sdmmchost_t *host, bool enable)
-{
-    if (host->hostPort == 0U)
-    {
-        SDIF_EnableCardPower(host->hostController.base, enable);
-    }
-#if defined(FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD) && FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD
-    else
-    {
-        SDIF_EnableCard1Power(host->hostController.base, enable);
-    }
-#endif
-
-    if (enable)
-    {
-        /* perform SDIF host controller reset only when DATA BUSY is assert */
-        if ((SDIF_GetControllerStatus(host->hostController.base) & SDIF_STATUS_DATA_BUSY_MASK) != 0U)
-        {
-            (void)SDIF_Reset(host->hostController.base, kSDIF_ResetAll, SDMMCHOST_RESET_TIMEOUT_VALUE);
-        }
-    }
-}
-
-void SDMMCHOST_ConvertDataToLittleEndian(sdmmchost_t *host, uint32_t *data, uint32_t wordSize, uint32_t format)
-{
-    uint32_t temp = 0U;
-
-    if (format == kSDMMC_DataPacketFormatMSBFirst)
-    {
-        for (uint32_t i = 0U; i < wordSize; i++)
-        {
-            temp    = data[i];
-            data[i] = SWAP_WORD_BYTE_SEQUENCE(temp);
-        }
-    }
-}
-
-status_t SDMMCHOST_Init(sdmmchost_t *host)
-{
-    assert(host != NULL);
-
-    sdif_transfer_callback_t sdifCallback = {0};
-    sdif_host_t *sdifHost                 = &(host->hostController);
-    status_t error                        = kStatus_Success;
-
-    /* host capability flags */
-    host->capability = (uint32_t)kSDMMCHOST_SupportHighSpeed | (uint32_t)kSDMMCHOST_SupportSuspendResume |
-                       (uint32_t)kSDMMCHOST_SupportVoltage3v3 | (uint32_t)kSDMMCHOST_Support4BitDataWidth |
-                       (uint32_t)kSDMMCHOST_Support8BitDataWidth | (uint32_t)kSDMMCHOST_SupportDetectCardByData3 |
-                       (uint32_t)kSDMMCHOST_SupportDetectCardByCD | (uint32_t)kSDMMCHOST_SupportAutoCmd12;
-    host->maxBlockCount = SDMMCHOST_SUPPORT_MAX_BLOCK_COUNT;
-    host->maxBlockSize  = SDMMCHOST_SUPPORT_MAX_BLOCK_LENGTH;
-
-    /* sdmmc osa init */
-    SDMMC_OSAInit();
-
-    SDMMC_OSAMutexCreate(&host->lock);
-    SDMMC_OSAMutexLock(&host->lock, osaWaitForever_c);
-
-    /* Initialize SDIF. */
-    sdifHost->config.responseTimeout       = 0xFFU;
-    sdifHost->config.cardDetDebounce_Clock = 0xFFFFFFU;
-    sdifHost->config.dataTimeout           = 0xFFFFFFU;
-    SDIF_Init(sdifHost->base, &(sdifHost->config));
-
-    /* Create handle for SDIF driver */
-    sdifCallback.TransferComplete = SDMMCHOST_TransferCompleteCallback;
-    sdifCallback.cardInserted     = SDMMCHOST_DetectCardInsertByHost;
-    sdifCallback.cardRemoved      = SDMMCHOST_DetectCardRemoveByHost;
-    SDIF_TransferCreateHandle(sdifHost->base, &host->handle, &sdifCallback, host);
-
-    /* Create transfer event. */
-    if (kStatus_Success != SDMMC_OSAEventCreate(&(host->hostEvent)))
-    {
-        error = kStatus_Fail;
-    }
-
-    SDMMC_OSAMutexUnlock(&host->lock);
-
-    return error;
-}
-
-void SDMMCHOST_Reset(sdmmchost_t *host)
-{
-    SDMMC_OSAMutexLock(&host->lock, osaWaitForever_c);
-
-    /* disable all the interrupt */
-    SDIF_DisableInterrupt(host->hostController.base, kSDIF_AllInterruptStatus);
-
-    /* make sure host controller release all the bus line. */
-    (void)SDIF_Reset(host->hostController.base, kSDIF_ResetAll, SDMMCHOST_RESET_TIMEOUT_VALUE);
-
-    /* clear all interrupt/DMA status */
-    SDIF_ClearInterruptStatus(host->hostController.base, kSDIF_AllInterruptStatus);
-    SDIF_ClearInternalDMAStatus(host->hostController.base, kSDIF_DMAAllStatus);
-
-    SDMMC_OSAMutexUnlock(&host->lock);
-}
-
-void SDMMCHOST_SetCardBusWidth(sdmmchost_t *host, uint32_t dataBusWidth)
-{
-    if (host->hostPort == 0U)
-    {
-        SDIF_SetCardBusWidth(host->hostController.base, dataBusWidth == (uint32_t)kSDMMC_BusWdith1Bit ?
-                                                            kSDIF_Bus1BitWidth :
-                                                            dataBusWidth == (uint32_t)kSDMMC_BusWdith4Bit ?
-                                                            kSDIF_Bus4BitWidth :
-                                                            kSDIF_Bus8BitWidth);
-    }
-#if defined(FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD) && FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD
-    else
-    {
-        SDIF_SetCard1BusWidth(host->hostController.base, dataBusWidth == (uint32_t)kSDMMC_BusWdith1Bit ?
-                                                             kSDIF_Bus1BitWidth :
-                                                             dataBusWidth == (uint32_t)kSDMMC_BusWdith4Bit ?
-                                                             kSDIF_Bus4BitWidth :
-                                                             kSDIF_Bus8BitWidth);
-    }
-#endif
-}
-
-void SDMMCHOST_Deinit(sdmmchost_t *host)
-{
-    SDMMC_OSAMutexLock(&host->lock, osaWaitForever_c);
-    sdif_host_t *sdifHost = &host->hostController;
-    SDIF_Deinit(sdifHost->base);
-    (void)SDMMC_OSAEventDestroy(&(host->hostEvent));
-    SDMMC_OSAMutexDestroy(&host->lock);
-}

+ 0 - 113
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/mmc/ChangeLogKSDK.txt

@@ -1,113 +0,0 @@
-/*!
-@page middleware_log Middleware Change Log
-
-@section mmc MMC Card driver for MCUXpresso SDK
-  The current driver version is 2.5.0.
-
-  - 2.5.0
-    - Improvements
-      - Added api MMC_SetSleepAwake to support enter/exit sleep state.
-      - Added new api MMC_PollingCardStatusBusy for application polling card status.
-      - Removed deprecated api in mmc driver and mark MMC_HostReset as deprecated.
-      - Improved the read/write/erase function flow.
-      - Added mutual exclusive access for init/deinit/read/write/erase function.
-      - Fixed violations of MISRA C-2012 rule 4.7, 17.7, 10.7, 10.4, 13.5, 14.4, 10.6.
-
-  - 2.4.1
-    - Improvements
-      - Improved the voltage window argument of CMD1 according to host capabilty instead of use card ocr directly.
-      - Added host HS200/HS400/8bit bus width capability validation during card initialization.
-      - Used cache line size align buffer for MMC relate api.
-      - Increased the CMD13 timeout count to avoid polling CMD13 time out issue.
-    - Bug Fixes
-      - Fixed violations of MISRA C-2012 rule 11.9, 15.7, 4.7, 16.4, 10.1, 10.3, 10.4, 11.3, 14.4, 10.6, 17.7, 16.1, 16.3.
-
-  - 2.4.0
-    - Improvements
-      - Added new apis MMC_EnableCacheControl/MMC_FlushCache to support cache feature.
-
-  - 2.3.1
-    - Improvements
-      - Removed the dead loop while polling DAT0 and CMD13 instead of using timeout mechanism.
-      - Added card state check before switching to HS400 to improve the emmc initialization stability.
-      - Removed the redundant operation of memset internal buffer in MMC_WrtiteBlocks function.
-    - Bug Fixes
-      - Fixed the sandisk emmc always busy while sending CMD1 without supported voltage provide in argument.
-
-  - 2.3.0
-    - Improvements
-      - Deprecated api MMC_PowerOnCard/MMC_PowerOffCard by api MMC_SetCardPower.
-      - Added internalBuffer in mmc_card_t and removed rawCid/rawCsd/rawExtendedCsd.
-      - Added retuning support during data transfer under HS200 mode.
-      - Increased the read/write blocks failed retry times for stability.
-      - Added delay while retry the CMD1 for stability.
-      - Added legacy card support, the card not support CMD6, CMD8.
-
-  - 2.2.13
-    - Improvements
-      - Used the boot mode value instead of boot mode mask value as the parameter of MMC_SetBootConfig to improve user experience.
-      - Removed dynamic voltage switch feature for mmc, according to JEDEC standard, the voltage should be fixed after power up.
-
-  - 2.2.12
-    - Improvement
-      - Increased the CMD1 retry times in the MMC card driver to improve driver compatibility.
-    - Bug Fixes
-      - Fixed the build warning by changing the old style function declaration static
-        status_t inline to static inline status_t(found by adding -Wold-style-declaration in armgcc build flag).
-      - Fixed the fall through build warning by adding SUPPRESS_FALL_THROUGH_WARNING() in mmc driver.
-
-  - 2.2.7
-    - Bug Fixes
-      - Fixed MDK 66-D warning.
-
-  - 2.2.6
-    - Improvements
-      - Saved MMC OCR registers while sending CMD1 with argument 0.
-
-    - Bug Fixes
-      - Added MMC_PowerOn function in which there is delay function after powerup sdcard. Otherwise, the
-        card initialization by fail.
-
-  - 2.2.5
-    - Improvements
-      - Added SDMMC_ENABLE_SOFTWARE_TUNING to enable/disable software tuning and it is disabled by default.
-
-  - 2.2.4
-    - Bug Fixes
-      - Fixed DDR mode data sequence miss issue, which is caused by NIBBLE_POS.
-
-    - Improvements
-      - Increased g_sdmmc 512byte to improve the performance when application use a non-word align data buffer address.
-      - Used OCR access mode bits to determine the mmccard high capacity flag.
-
-  - 2.2.3
-    - Bug Fixes
-      - Added response check for send operation condition command. If not checked, the card may occasionally init fail.
-
-  - 2.2.1
-    - Improvements
-      - Improved MMC Boot feature.
-
-  - 2.2.0
-    - Improvements
-      - Optimized tuning/mmc switch voltage/mmc select power class/mmc select timing function.
-      - Added strobe dll for mmc HS400 mode.
-      - Added write complete wait operation for MMC_Write to fix command timeout issue.
-
-  - 2.1.2
-    - Improvements
-      - Improved SDMMC to support eMMC v5.0.
-    - Bug Fixes
-      - Fixed incorrect comparison between count and length in MMC_ReadBlocks/MMC_WriteBlocks.
-
-  - 2.1.1
-    - Bug Fixes
-      - Fixed the block range boundary error when transferring data to MMC card.
-
-  - 2.1.0
-    - Improvements
-      - Optimized the function of setting maximum data bus width for MMC card.
-
-  - 2.0.0
-    - Initial version
-*/

+ 0 - 2998
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/mmc/fsl_mmc.c

@@ -1,2998 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <string.h>
-#include "fsl_mmc.h"
-
-/*******************************************************************************
- * Definitons
- ******************************************************************************/
-/*! @brief The divide value used to avoid float point calculation when calculate max speed in normal mode. */
-#define DIVIDER_IN_TRANSFER_SPEED (10U)
-/*! @brief MMC CMD1 retry times */
-#ifndef MMC_CMD1_RETRY_TIMES
-#define MMC_CMD1_RETRY_TIMES (10000U)
-#endif
-#ifndef MMC_CMD13_RETRY_TIMES
-#define MMC_CMD13_RETRY_TIMES (1000000U)
-#endif
-#ifndef MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT
-#define MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT (10000U)
-#endif
-/*!@brief power reset delay */
-#define MMC_POWER_RESET_DELAY (500U)
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-/*!
- * @brief Send SELECT_CARD command to set the card enter or exit transfer state.
- *
- * @param card Card descriptor.
- * @param isSelected True to enter transfer state.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static inline status_t MMC_SelectCard(mmc_card_t *card, bool isSelected);
-
-/*!
- * @brief Send SET_BLOCK_COUNT command.
- *
- * @param card Card descriptor.
- * @param blockCount Block count.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static inline status_t MMC_SetBlockCount(mmc_card_t *card, uint32_t blockCount);
-
-/*!
- * @brief Send GO_IDLE command to reset all cards to idle state
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static inline status_t MMC_GoIdle(mmc_card_t *card);
-
-/*!
- * @brief Send STOP_TRANSMISSION command to card to stop ongoing data transferring.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_StopTransmission(mmc_card_t *card);
-
-/*!
- * @brief Send SET_BLOCK_SIZE command to set the block length in bytes for MMC cards.
- *
- * @param card Card descriptor.
- * @param blockSize Block size.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static inline status_t MMC_SetBlockSize(mmc_card_t *card, uint32_t blockSize);
-
-/*!
- * @brief Send SEND_OPERATION_CONDITION command to validate if the card support host's voltage window
- *
- * @param card Card descriptor.
- * @param arg Command argument.
- * @retval kStatus_SDMMC_TransferFailed Transfers failed.
- * @retval kStatus_Timeout Operation timeout.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SendOperationCondition(mmc_card_t *card, uint32_t arg);
-
-/*!
- * @brief Send SET_RCA command to set the relative address of the card.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SetRelativeAddress(mmc_card_t *card);
-
-/*!
- * @brief Decode CSD register content.
- *
- * @param card Card descriptor.
- * @param rawCsd raw CSD register content.
- */
-static void MMC_DecodeCsd(mmc_card_t *card, uint32_t *rawCsd);
-
-/*!
- * @brief Set the card to max transfer speed in non-high speed mode.
- *
- * @param card Card descriptor.
- */
-static void MMC_SetMaxFrequency(mmc_card_t *card);
-
-/*!
- * @brief Set erase unit size of the card
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_ConfigureExtendedCsdFailed Configure Extended CSD failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SetMaxEraseUnitSize(mmc_card_t *card);
-
-/*!
- * @brief Send SWITCH command to set the specific byte in Extended CSD.
- *
- * Example:
-   @code
-   mmc_extended_csd_config_t config;
-   config.accessMode = kMMC_ExtendedCsdAccessModeSetBits;
-   config.ByteIndex = 1U;
-   config.ByteValue = 0x033U;
-   config.commandSet = kMMC_CommandSetStandard;
-   MMC_SetExtendedCsdConfig(card, &config);
-   @endcode
- *
- * @param card Card descriptor.
- * @param config Configuration for Extended CSD.
- * @param timeout switch command timeout value.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_WaitWriteCompleteFailed Wait write complete failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SetExtendedCsdConfig(mmc_card_t *card, const mmc_extended_csd_config_t *config, uint32_t timeout);
-
-/*!
- * @brief Decode the Extended CSD register
- *
- * @param card Card descriptor.
- * @param rawExtendedCsd Raw extended CSD register content.
- */
-static void MMC_DecodeExtendedCsd(mmc_card_t *card, uint32_t *rawExtendedCsd);
-
-/*!
- * @brief Send SEND_EXTENDED_CSD command to get the content of the Extended CSD register
- * Allow read the special byte index value if targetAddr is not NULL
- * @param card Card descriptor.
- * @param targetAddr Pointer to store the target byte value.
- * @param byteIndex Target byte index.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SendExtendedCsd(mmc_card_t *card, uint8_t *targetAddr, uint32_t byteIndex);
-
-/*!
- * @brief Set the power class of the card at specific bus width and host intended voltage window.
- *
- * @param card Card descriptor.
- * @return The power class switch status.
- */
-static status_t MMC_SetPowerClass(mmc_card_t *card);
-
-/*!
- * @brief Send test pattern to get the functional pin in the MMC bus
- *
- * @param card Card descriptor.
- * @param blockSize Test pattern block size.
- * @param pattern Test pattern data buffer.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SendTestPattern(mmc_card_t *card, uint32_t blockSize, uint32_t *pattern);
-
-/*!
- * @brief Receive test pattern reversed by the card.
- *
- * @param card Card descriptor.
- * @param blockSize Test pattern block size.
- * @param pattern Test pattern data buffer.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_ReceiveTestPattern(mmc_card_t *card, uint32_t blockSize, uint32_t *pattern);
-
-/*!
- * @brief Bus test procedure to get the functional data pin in the bus
- *
- * @param card Card descriptor.
- * @param width Data bus width.
- * @retval kStatus_SDMMC_SendTestPatternFailed Send test pattern failed.
- * @retval kStatus_SDMMC_ReceiveTestPatternFailed Receive test pattern failed.
- * @retval kStatus_Fail Test failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_TestDataBusWidth(mmc_card_t *card, mmc_data_bus_width_t width);
-
-/*!
- * @brief Send SET_BUS_WIDTH command to set the bus width.
- *
- * @param card Card descriptor.
- * @param width Data bus width.
- * @retval kStatus_SDMMC_ConfigureExtendedCsdFailed Configure extended CSD failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SetDataBusWidth(mmc_card_t *card, mmc_data_bus_width_t width);
-
-/*!
- * @brief Set max the bus width automatically
- *
- * @param card Card descriptor.
- * @param targetTiming switch target timing
- * @retval kStatus_SDMMC_SetDataBusWidthFailed switch fail.
- * @retval kStatus_Success switch success.
- */
-static status_t MMC_SetMaxDataBusWidth(mmc_card_t *card, mmc_high_speed_timing_t targetTiming);
-
-/*!
- * @brief Switch the card to high speed mode
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_ConfigureExtendedCsdFailed Configure extended CSD failed.
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support high speed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SelectBusTiming(mmc_card_t *card);
-
-/*!
- * @brief select card HS_TIMING value and card driver strength
- *
- * @param card Card descriptor.
- * @param timing Timing interface value.
- * @param driverStrength driver strength value.
- * @retval kStatus_Success switch success.
- * @retval kStatus_SDMMC_ConfigureExtendedCsdFailed , config extend csd register fail.
- */
-static status_t MMC_SwitchHSTiming(mmc_card_t *card, uint8_t timing, uint8_t driverStrength);
-
-/*!
- * @brief switch to HS400 mode.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_ConfigureExtendedCsdFailed Configure extended CSD failed.
- * @retval kStatus_SDMMC_SwitchBusTimingFailed switch bus timing fail.
- * @retval kStatus_SDMMC_SetDataBusWidthFailed switch bus width fail.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SwitchToHS400(mmc_card_t *card);
-
-/*!
- * @brief switch to HS200 mode.
- *
- * @param card Card descriptor.
- * @param freq Target frequency.
- * @retval kStatus_SDMMC_ConfigureExtendedCsdFailed Configure extended CSD failed.
- * @retval kStatus_SDMMC_TuningFail tuning fail.
- * @retval kStatus_SDMMC_SetDataBusWidthFailed switch bus width fail.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SwitchToHS200(mmc_card_t *card, uint32_t freq);
-
-/*!
- * @brief switch to HS400 mode.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_ConfigureExtendedCsdFailed Configure extended CSD failed.
- * @retval kStatus_SDMMC_SetDataBusWidthFailed switch bus width fail.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SwitchToHighSpeed(mmc_card_t *card);
-
-/*!
- * @brief Decode CID register
- *
- * @param card Card descriptor.
- * @param rawCid Raw CID register content.
- */
-static void MMC_DecodeCid(mmc_card_t *card, uint32_t *rawCid);
-
-/*!
- * @brief Send ALL_SEND_CID command
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_AllSendCid(mmc_card_t *card);
-
-/*!
- * @brief Send SEND_CSD command to get CSD from card
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_SendCsd(mmc_card_t *card);
-
-/*!
- * @brief Check if the block range accessed is within current partition.
- *
- * @param card Card descriptor.
- * @param startBlock Start block to access.
- * @param blockCount Block count to access.
- * @retval kStatus_InvalidArgument Invalid argument.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_CheckBlockRange(mmc_card_t *card, uint32_t startBlock, uint32_t blockCount);
-
-/*!
- * @brief Check if the erase group range accessed is within current partition.
- *
- * @param card Card descriptor.
- * @param startGroup Start group to access.
- * @param endGroup End group to access.
- * @retval kStatus_InvalidArgument Invalid argument.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_CheckEraseGroupRange(mmc_card_t *card, uint32_t startGroup, uint32_t endGroup);
-
-/*!
- * @brief MMC excute tuning function.
- *
- * @param card Card descriptor.
- * @retval kStatus_Success Operate successfully.
- * @retval kStatus_SDMMC_TuningFail tuning fail.
- * @retval kStatus_SDMMC_TransferFailed transfer fail
- */
-static inline status_t MMC_ExecuteTuning(mmc_card_t *card);
-/*!
- * @brief Read data from specific MMC card
- *
- * @param card Card descriptor.
- * @param buffer Buffer to save received data.
- * @param startBlock Start block to read.
- * @param blockSize Block size.
- * @param blockCount Block count to read.
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support.
- * @retval kStatus_SDMMC_WaitWriteCompleteFailed Wait write complete failed.
- * @retval kStatus_SDMMC_SetBlockCountFailed Set block count failed.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_StopTransmissionFailed Stop transmission failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_Read(
-    mmc_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockSize, uint32_t blockCount);
-
-/*!
- * @brief Write data from specific MMC card
- *
- * @param card Card descriptor.
- * @param buffer Buffer to hold the data to write.
- * @param startBlock Start block to write.
- * @param blockSize Block size.
- * @param blockCount Block count to write.
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support.
- * @retval kStatus_SDMMC_SetBlockCountFailed Set block count failed.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_StopTransmissionFailed Stop transmission failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_Write(
-    mmc_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockSize, uint32_t blockCount);
-
-/*!
- * @brief MMC card erase function
- *
- * @param card Card descriptor.
- * @param startGroupAddress start erase group address.
- * @param endGroupAddress end erase group address.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t MMC_Erase(mmc_card_t *card, uint32_t startGroupAddress, uint32_t endGroupAddress);
-
-/*!
- * @brief card transfer function wrapper
- * This function is used to do tuning before transfer if the cmd won't casue re-tuning
- * request, then you can call host transfer function directly
- * @param card Card descriptor.
- * @param content Transfer content.
- * @param retry Retry times.
- * @retval kStatus_SDMMC_TransferFailed transfer fail
- * @retval kStatus_SDMMC_TuningFail tuning fail
- * @retval kStatus_Success transfer success
- */
-static status_t MMC_Transfer(mmc_card_t *card, sdmmchost_transfer_t *content, uint32_t retry);
-
-/*!
- * @brief card validate operation voltage
- * This function is used to validate the operation voltage bettwen host and card
- *
- * @param card Card descriptor.
- * @param opcode Retry times.
- * @retval kStatus_Fail the operation voltage condition doesn't match between card and host
- * @retval kStatus_Success voltage validate successfully
- */
-static status_t MMC_ValidateOperationVoltage(mmc_card_t *card, uint32_t *opcode);
-
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-/* Frequency unit defined in TRANSFER SPEED field in CSD */
-static const uint32_t g_transerSpeedFrequencyUnit[] = {100000U, 1000000U, 10000000U, 100000000U};
-/* The multiplying value defined in TRANSFER SPEED field in CSD */
-static const uint32_t g_transerSpeedMultiplierFactor[] = {0U,  10U, 12U, 13U, 15U, 20U, 26U, 30U,
-                                                          35U, 40U, 45U, 52U, 55U, 60U, 70U, 80U};
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-static inline status_t MMC_SelectCard(mmc_card_t *card, bool isSelected)
-{
-    assert(card != NULL);
-
-    return SDMMC_SelectCard(card->host, card->relativeAddress, isSelected);
-}
-
-static inline status_t MMC_SetBlockCount(mmc_card_t *card, uint32_t blockCount)
-{
-    assert(card != NULL);
-
-    return SDMMC_SetBlockCount(card->host, blockCount);
-}
-
-static inline status_t MMC_GoIdle(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    return SDMMC_GoIdle(card->host);
-}
-
-static inline status_t MMC_SetBlockSize(mmc_card_t *card, uint32_t blockSize)
-{
-    assert(card != NULL);
-
-    return SDMMC_SetBlockSize(card->host, blockSize);
-}
-
-static status_t MMC_ExecuteTuning(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t blockSize = 0U;
-
-    if (card->busWidth == kMMC_DataBusWidth4bit)
-    {
-        blockSize = 64U;
-    }
-    else if (card->busWidth == kMMC_DataBusWidth8bit)
-    {
-        blockSize = 128U;
-    }
-    else
-    {
-        /* do not need tuning in this situation */
-        return kStatus_Success;
-    }
-
-    return SDMMCHOST_ExecuteTuning(card->host, (uint32_t)kMMC_SendTuningBlock,
-                                   (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer),
-                                   blockSize);
-}
-
-static status_t MMC_Transfer(mmc_card_t *card, sdmmchost_transfer_t *content, uint32_t retry)
-{
-    assert(content != NULL);
-    status_t error;
-    uint32_t retuningCount = 3U;
-
-    do
-    {
-        error = SDMMCHOST_TransferFunction(card->host, content);
-
-        if (error == kStatus_Success)
-        {
-            break;
-        }
-
-        if (((retry == 0U) && (content->data != NULL)) || (error == kStatus_SDMMC_ReTuningRequest))
-        {
-            /* abort previous transfer firstly */
-            (void)MMC_StopTransmission(card);
-
-            if (card->busTiming == kMMC_HighSpeed200Timing)
-            {
-                if (--retuningCount == 0U)
-                {
-                    break;
-                }
-                /* perform retuning */
-                if (MMC_ExecuteTuning(card) != kStatus_Success)
-                {
-                    error = kStatus_SDMMC_TuningFail;
-                    SDMMC_LOG("\r\nError: retuning failed.");
-                    break;
-                }
-                else
-                {
-                    SDMMC_LOG("\r\nlog: retuning successfully.");
-                    continue;
-                }
-            }
-        }
-
-        if (retry != 0U)
-        {
-            retry--;
-        }
-        else
-        {
-            break;
-        }
-
-    } while (true);
-
-    return error;
-}
-
-static status_t MMC_SendStatus(mmc_card_t *card, uint32_t *status)
-{
-    assert(card != NULL);
-    status_t error               = kStatus_Success;
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    uint32_t retry               = 10;
-
-    command.index        = (uint32_t)kSDMMC_SendStatus;
-    command.argument     = card->relativeAddress << 16U;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-
-    while (retry != 0U)
-    {
-        error = MMC_Transfer(card, &content, 2U);
-        if ((--retry == 0U) && (error != kStatus_Success))
-        {
-            return kStatus_SDMMC_TransferFailed;
-        }
-
-        if (kStatus_Success == error)
-        {
-            break;
-        }
-    }
-
-    *status = command.response[0U];
-
-    return error;
-}
-
-status_t MMC_PollingCardStatusBusy(mmc_card_t *card, bool checkStatus, uint32_t timeoutMs)
-{
-    assert(card != NULL);
-
-    uint32_t statusTimeoutUs = timeoutMs * 1000U;
-    bool cardBusy            = false;
-    status_t error           = kStatus_SDMMC_CardStatusBusy;
-    uint32_t status          = 0U;
-
-    do
-    {
-        cardBusy = SDMMCHOST_IsCardBusy(card->host);
-
-        if (cardBusy == false)
-        {
-            if (checkStatus)
-            {
-                error = MMC_SendStatus(card, &status);
-                if (kStatus_Success == error)
-                {
-                    /* check the response error */
-                    if (0U != (status & (SDMMC_R1_ALL_ERROR_FLAG | SDMMC_MASK(kSDMMC_R1SwitchErrorFlag))))
-                    {
-                        SDMMC_LOG("\r\nError: CMD13 report switch error %x.", status);
-
-                        error = kStatus_SDMMC_SwitchFailed;
-                    }
-                    else if ((0U != (status & SDMMC_MASK(kSDMMC_R1ReadyForDataFlag))) &&
-                             (SDMMC_R1_CURRENT_STATE(status) != (uint32_t)kSDMMC_R1StateProgram))
-                    {
-                        error = kStatus_SDMMC_CardStatusIdle;
-                        break;
-                    }
-                    else
-                    {
-                        SDMMC_LOG("\r\nWarning: CMD13 report busy %x.", status);
-                        error = kStatus_SDMMC_CardStatusBusy;
-                    }
-                }
-                else
-                {
-                    error = kStatus_SDMMC_TransferFailed;
-                    break;
-                }
-            }
-            else
-            {
-                error = kStatus_SDMMC_CardStatusIdle;
-                break;
-            }
-        }
-
-        if (statusTimeoutUs != 0U)
-        {
-            /* Delay 125us to throttle the polling rate */
-            statusTimeoutUs -= SDMMC_OSADelayUs(125U);
-        }
-
-    } while (statusTimeoutUs != 0U);
-
-    return error;
-}
-
-static status_t MMC_StopTransmission(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index              = (uint32_t)kSDMMC_StopTransmission;
-    command.argument           = 0U;
-    command.type               = kCARD_CommandTypeAbort;
-    command.responseType       = kCARD_ResponseTypeR1b;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SendOperationCondition(mmc_card_t *card, uint32_t arg)
-{
-    assert(card != NULL);
-
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_transfer_t content = {0};
-    status_t error;
-    uint32_t i = MMC_CMD1_RETRY_TIMES;
-
-    /* Send CMD1 with the intended voltage range in the argument(either 0x00FF8000 or 0x00000080) */
-    command.index        = (uint32_t)kMMC_SendOperationCondition;
-    command.argument     = arg;
-    command.responseType = kCARD_ResponseTypeR3;
-
-    content.command = &command;
-    content.data    = NULL;
-    do
-    {
-        error = SDMMCHOST_TransferFunction(card->host, &content);
-
-        if (error == kStatus_Success)
-        {
-            /* record OCR register */
-            card->ocr = command.response[0U];
-
-            if ((arg == 0U) && (command.response[0U] != 0U))
-            {
-                error = kStatus_Success;
-            }
-            /* Repeat CMD1 until the busy bit is cleared. */
-            else if (0U == (command.response[0U] & MMC_OCR_BUSY_MASK))
-            {
-                error = kStatus_Timeout;
-            }
-            else
-            {
-                error = kStatus_Success;
-                if (((card->ocr & MMC_OCR_ACCESS_MODE_MASK) >> MMC_OCR_ACCESS_MODE_SHIFT) ==
-                    (uint32_t)kMMC_AccessModeSector)
-                {
-                    card->flags |= (uint32_t)kMMC_SupportHighCapacityFlag;
-                }
-            }
-        }
-
-        SDMMC_OSADelay(10U);
-
-    } while ((0U != i--) && (error != kStatus_Success));
-
-    return error;
-}
-
-static status_t MMC_SetRelativeAddress(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_transfer_t content = {0};
-    status_t error               = kStatus_Success;
-
-    /* Send CMD3 with a chosen relative address, with value greater than 1 */
-    command.index        = (uint32_t)kMMC_SetRelativeAddress;
-    command.argument     = (MMC_DEFAULT_RELATIVE_ADDRESS << 16U);
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success == error) || (0U == ((command.response[0U]) & SDMMC_R1_ALL_ERROR_FLAG)))
-    {
-        card->relativeAddress = MMC_DEFAULT_RELATIVE_ADDRESS;
-        return kStatus_Success;
-    }
-
-    return kStatus_SDMMC_TransferFailed;
-}
-
-static void MMC_DecodeCsd(mmc_card_t *card, uint32_t *rawCsd)
-{
-    assert(card != NULL);
-    assert(rawCsd != NULL);
-
-    mmc_csd_t *csd;
-    uint32_t multiplier;
-
-    csd                             = &(card->csd);
-    csd->csdStructureVersion        = (uint8_t)((rawCsd[3U] & 0xC0000000U) >> 30U);
-    csd->systemSpecificationVersion = (uint8_t)((rawCsd[3U] & 0x3C000000U) >> 26U);
-    csd->dataReadAccessTime1        = (uint8_t)((rawCsd[3U] & 0xFF0000U) >> 16U);
-    csd->dataReadAccessTime2        = (uint8_t)((rawCsd[3U] & 0xFF00U) >> 8U);
-    csd->transferSpeed              = (uint8_t)(rawCsd[3U] & 0xFFU);
-    csd->cardCommandClass           = (uint16_t)((rawCsd[2U] & 0xFFF00000U) >> 20U);
-    /* Max block length read/write one time */
-    csd->readBlockLength = (uint8_t)((rawCsd[2U] & 0xF0000U) >> 16U);
-    if ((rawCsd[2U] & 0x8000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdReadBlockPartialFlag;
-    }
-    if ((rawCsd[2U] & 0x4000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdWriteBlockMisalignFlag;
-    }
-    if ((rawCsd[2U] & 0x2000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdReadBlockMisalignFlag;
-    }
-    if ((rawCsd[2U] & 0x1000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdDsrImplementedFlag;
-    }
-    csd->deviceSize               = (uint16_t)(((rawCsd[2U] & 0x3FFU) << 2U) + ((rawCsd[1U] & 0xC0000000U) >> 30U));
-    csd->readCurrentVddMin        = (uint8_t)((rawCsd[1U] & 0x38000000U) >> 27U);
-    csd->readCurrentVddMax        = (uint8_t)((rawCsd[1U] & 0x07000000U) >> 24U);
-    csd->writeCurrentVddMin       = (uint8_t)((rawCsd[1U] & 0x00E00000U) >> 21U);
-    csd->writeCurrentVddMax       = (uint8_t)((rawCsd[1U] & 0x001C0000U) >> 18U);
-    csd->deviceSizeMultiplier     = (uint8_t)((rawCsd[1U] & 0x00038000U) >> 15U);
-    csd->eraseGroupSize           = (uint8_t)((rawCsd[1U] & 0x00007C00U) >> 10U);
-    csd->eraseGroupSizeMultiplier = (uint8_t)((rawCsd[1U] & 0x000003E0U) >> 5U);
-    csd->writeProtectGroupSize    = (uint8_t)(rawCsd[1U] & 0x0000001FU);
-    if ((rawCsd[0U] & 0x80000000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdWriteProtectGroupEnabledFlag;
-    }
-    csd->defaultEcc          = (uint8_t)((rawCsd[0U] & 0x60000000U) >> 29U);
-    csd->writeSpeedFactor    = (uint8_t)((rawCsd[0U] & 0x1C000000U) >> 26U);
-    csd->maxWriteBlockLength = (uint8_t)((rawCsd[0U] & 0x03C00000U) >> 22U);
-    if ((rawCsd[0U] & 0x00200000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdWriteBlockPartialFlag;
-    }
-    if ((rawCsd[0U] & 0x00010000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_ContentProtectApplicationFlag;
-    }
-    if ((rawCsd[0U] & 0x00008000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdFileFormatGroupFlag;
-    }
-    if ((rawCsd[0U] & 0x00004000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdCopyFlag;
-    }
-    if ((rawCsd[0U] & 0x00002000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdPermanentWriteProtectFlag;
-    }
-    if ((rawCsd[0U] & 0x00001000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kMMC_CsdTemporaryWriteProtectFlag;
-    }
-    csd->fileFormat = (uint8_t)((rawCsd[0U] & 0x00000C00U) >> 10U);
-    csd->eccCode    = (uint8_t)((rawCsd[0U] & 0x00000300U) >> 8U);
-
-    /* Calculate the device total block count. */
-    /* For the card capacity of witch higher than 2GB, the maximum possible value should be set to this register
-    is 0xFFF. */
-    if (card->csd.deviceSize != 0xFFFU)
-    {
-        multiplier                = (2UL << (card->csd.deviceSizeMultiplier + 2U - 1U));
-        card->userPartitionBlocks = (((card->csd.deviceSize + 1UL) * multiplier) / FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-    }
-
-    card->blockSize = FSL_SDMMC_DEFAULT_BLOCK_SIZE;
-}
-
-static void MMC_SetMaxFrequency(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t frequencyUnit;
-    uint32_t multiplierFactor;
-    uint32_t maxBusClock_Hz;
-
-    /* g_fsdhcCommandUnitInTranSpeed and g_transerSpeedMultiplierFactor are used to calculate the max speed in normal
-    mode not high speed mode.
-    For cards supporting version 4.0, 4.1, and 4.2 of the specification, the value shall be 20MHz(0x2A).
-    For cards supporting version 4.3, the value shall be 26 MHz (0x32H). In High speed mode, the max
-    frequency is decided by CARD_TYPE in Extended CSD. */
-    frequencyUnit     = g_transerSpeedFrequencyUnit[READ_MMC_TRANSFER_SPEED_FREQUENCY_UNIT(card->csd)];
-    multiplierFactor  = g_transerSpeedMultiplierFactor[READ_MMC_TRANSFER_SPEED_MULTIPLIER(card->csd)];
-    maxBusClock_Hz    = (frequencyUnit * multiplierFactor) / DIVIDER_IN_TRANSFER_SPEED;
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, maxBusClock_Hz);
-}
-
-static status_t MMC_SetMaxEraseUnitSize(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t erase_group_size;
-    uint32_t erase_group_multiplier;
-    mmc_extended_csd_config_t extendedCsdconfig;
-
-    /* Legacy mmc card , do not support the command */
-    if ((card->csd.systemSpecificationVersion == (uint32_t)kMMC_SpecificationVersion3) &&
-        (card->csd.csdStructureVersion == (uint32_t)kMMC_CsdStrucureVersion12))
-    {
-        return kStatus_Success;
-    }
-
-    if (((0U == (card->flags & (uint32_t)kMMC_SupportHighCapacityFlag)) ||
-         (card->extendedCsd.highCapacityEraseUnitSize == 0U)) ||
-        (card->extendedCsd.highCapacityEraseTimeout == 0U))
-    {
-        erase_group_size       = card->csd.eraseGroupSize;
-        erase_group_multiplier = card->csd.eraseGroupSizeMultiplier;
-        card->eraseGroupBlocks = ((erase_group_size + 1U) * (erase_group_multiplier + 1U));
-    }
-    else
-    {
-        /* Erase Unit Size = 512Kbyte * HC_ERASE_GRP_SIZE. Block size is 512 bytes. */
-        card->eraseGroupBlocks = (card->extendedCsd.highCapacityEraseUnitSize * 1024UL);
-        /* Enable high capacity erase unit size. */
-        extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeSetBits;
-        extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexEraseGroupDefinition;
-        extendedCsdconfig.ByteValue  = 0x01U; /* The high capacity erase unit size enable bit is bit 0 */
-        extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-        if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-        {
-            return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SetExtendedCsdConfig(mmc_card_t *card, const mmc_extended_csd_config_t *config, uint32_t timeout)
-{
-    assert(card != NULL);
-    assert(config != NULL);
-
-    status_t error               = kStatus_Success;
-    uint32_t parameter           = 0U;
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_transfer_t content = {0};
-    uint32_t timeoutMS           = timeout == 0U ? card->extendedCsd.genericCMD6Timeout : timeout;
-
-    parameter |= ((uint32_t)(config->commandSet) << MMC_SWITCH_COMMAND_SET_SHIFT);
-    parameter |= ((uint32_t)(config->ByteValue) << MMC_SWITCH_VALUE_SHIFT);
-    parameter |= ((uint32_t)(config->ByteIndex) << MMC_SWITCH_BYTE_INDEX_SHIFT);
-    parameter |= ((uint32_t)(config->accessMode) << MMC_SWITCH_ACCESS_MODE_SHIFT);
-    command.index        = (uint32_t)kMMC_Switch;
-    command.argument     = parameter;
-    command.responseType = kCARD_ResponseTypeR1b; /* Send switch command to set the pointed byte in Extended CSD. */
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG | SDMMC_MASK(kSDMMC_R1SwitchErrorFlag);
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = MMC_Transfer(card, &content, 2U);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* Wait for the card write process complete because of that card read process and write process use one buffer. */
-    error = MMC_PollingCardStatusBusy(card, true, timeoutMS == 0U ? MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT : timeoutMS);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static void MMC_DecodeExtendedCsd(mmc_card_t *card, uint32_t *rawExtendedCsd)
-{
-    assert(card != NULL);
-    assert(rawExtendedCsd != NULL);
-
-    uint8_t *buffer                 = (uint8_t *)rawExtendedCsd;
-    mmc_extended_csd_t *extendedCsd = &(card->extendedCsd);
-
-    /* Extended CSD is transferred as a data block from least byte indexed 0. */
-    extendedCsd->bootPartitionWP                 = buffer[173U];
-    extendedCsd->bootWPStatus                    = buffer[174U];
-    extendedCsd->highDensityEraseGroupDefinition = buffer[175U];
-    extendedCsd->bootDataBusConditions           = buffer[177U];
-    extendedCsd->bootConfigProtect               = buffer[178U];
-    extendedCsd->partitionConfig                 = buffer[179U];
-    extendedCsd->eraseMemoryContent              = buffer[181U];
-    extendedCsd->dataBusWidth                    = buffer[183U];
-    extendedCsd->highSpeedTiming                 = buffer[185U];
-    extendedCsd->powerClass                      = buffer[187U];
-    extendedCsd->commandSetRevision              = buffer[189U];
-    extendedCsd->commandSet                      = buffer[191U];
-    extendedCsd->extendecCsdVersion              = buffer[192U];
-    extendedCsd->csdStructureVersion             = buffer[194U];
-    extendedCsd->partitionAttribute              = buffer[156U];
-    extendedCsd->extPartitionSupport             = buffer[494U];
-    extendedCsd->cardType                        = buffer[196U];
-    /* This field define the type of the card. The only currently valid values for this field are 0x01 and 0x03. */
-    card->flags |= extendedCsd->cardType;
-
-    extendedCsd->ioDriverStrength = buffer[197U];
-
-    extendedCsd->partitionSwitchTimeout                    = buffer[199U];
-    extendedCsd->powerClass52MHz195V                       = buffer[200U];
-    extendedCsd->powerClass26MHz195V                       = buffer[201U];
-    extendedCsd->powerClass52MHz360V                       = buffer[202U];
-    extendedCsd->powerClass26MHz360V                       = buffer[203U];
-    extendedCsd->powerClass200MHZVCCQ130VVCC360V           = buffer[236U];
-    extendedCsd->powerClass200MHZVCCQ195VVCC360V           = buffer[237U];
-    extendedCsd->powerClass52MHZDDR195V                    = buffer[238U];
-    extendedCsd->powerClass52MHZDDR360V                    = buffer[239U];
-    extendedCsd->powerClass200MHZDDR360V                   = buffer[253U];
-    extendedCsd->minimumReadPerformance4Bit26MHz           = buffer[205U];
-    extendedCsd->minimumWritePerformance4Bit26MHz          = buffer[206U];
-    extendedCsd->minimumReadPerformance8Bit26MHz4Bit52MHz  = buffer[207U];
-    extendedCsd->minimumWritePerformance8Bit26MHz4Bit52MHz = buffer[208U];
-    extendedCsd->minimumReadPerformance8Bit52MHz           = buffer[209U];
-    extendedCsd->minimumWritePerformance8Bit52MHz          = buffer[210U];
-    extendedCsd->minReadPerformance8bitAt52MHZDDR          = buffer[234U];
-    extendedCsd->minWritePerformance8bitAt52MHZDDR         = buffer[235U];
-    /* Get user partition size. */
-    extendedCsd->sectorCount = ((((uint32_t)buffer[215U]) << 24U) + (((uint32_t)buffer[214U]) << 16U) +
-                                (((uint32_t)buffer[213U]) << 8U) + (uint32_t)buffer[212U]);
-    if ((card->flags & (uint32_t)kMMC_SupportHighCapacityFlag) != 0U)
-    {
-        card->userPartitionBlocks = card->extendedCsd.sectorCount;
-    }
-
-    extendedCsd->sleepAwakeTimeout                 = buffer[217U];
-    extendedCsd->sleepCurrentVCCQ                  = buffer[219U];
-    extendedCsd->sleepCurrentVCC                   = buffer[220U];
-    extendedCsd->highCapacityWriteProtectGroupSize = buffer[221U];
-    extendedCsd->reliableWriteSectorCount          = buffer[222U];
-    extendedCsd->highCapacityEraseTimeout          = buffer[223U];
-    extendedCsd->highCapacityEraseUnitSize         = buffer[224U];
-    extendedCsd->accessSize                        = buffer[225U];
-
-    /* Get boot partition size: 128KB * BOOT_SIZE_MULT*/
-    card->bootPartitionBlocks = ((128U * 1024U * buffer[226U]) / FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-
-    /* support HS400 data strobe */
-    if (buffer[184] == 1U)
-    {
-        card->flags |= (uint32_t)kMMC_SupportEnhanceHS400StrobeFlag;
-    }
-
-    /* Check if card support boot mode. */
-    if ((buffer[228U] & 0x1U) != 0U)
-    {
-        card->flags |= (uint32_t)kMMC_SupportAlternateBootFlag;
-    }
-    else if ((buffer[228U] & 0x2U) != 0U)
-    {
-        card->flags |= (uint32_t)kMMC_SupportDDRBootFlag;
-    }
-    else if ((buffer[228U] & 0x4U) != 0U)
-    {
-        card->flags |= (uint32_t)kMMC_SupportHighSpeedBootFlag;
-    }
-    else
-    {
-        /* empty with intentional */
-    }
-    /* cache size unit 1kb */
-    extendedCsd->cacheSize = (((uint32_t)buffer[252U]) << 24) | (((uint32_t)buffer[251U]) << 16) |
-                             (((uint32_t)buffer[250U]) << 8) | (((uint32_t)buffer[249U]));
-
-    extendedCsd->genericCMD6Timeout  = buffer[248U] * 10UL;
-    extendedCsd->supportedCommandSet = buffer[504U];
-}
-
-static status_t MMC_SendExtendedCsd(mmc_card_t *card, uint8_t *targetAddr, uint32_t byteIndex)
-{
-    assert(card != NULL);
-
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_data_t data        = {0};
-    uint32_t *alignBuffer        = (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    status_t error               = kStatus_Success;
-
-    /* Legacy mmc card , do not support the command */
-    if ((card->csd.systemSpecificationVersion == (uint32_t)kMMC_SpecificationVersion3) &&
-        (card->csd.csdStructureVersion == (uint32_t)kMMC_CsdStrucureVersion12))
-    {
-        return kStatus_Success;
-    }
-
-    (void)memset(alignBuffer, 0, MMC_EXTENDED_CSD_BYTES);
-
-    command.index        = (uint32_t)kMMC_SendExtendedCsd;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    data.blockCount = 1U;
-    data.blockSize  = MMC_EXTENDED_CSD_BYTES;
-    data.rxData     = alignBuffer;
-
-    content.command = &command;
-    content.data    = &data;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success == error) && (0U == (command.response[0U] & SDMMC_R1_ALL_ERROR_FLAG)))
-    {
-        SDMMCHOST_ConvertDataToLittleEndian(card->host, alignBuffer, MMC_EXTENDED_CSD_BYTES / 4U,
-                                            kSDMMC_DataPacketFormatLSBFirst);
-        if (targetAddr != NULL)
-        {
-            *targetAddr = (uint8_t)alignBuffer[byteIndex];
-        }
-        else
-        {
-            MMC_DecodeExtendedCsd(card, alignBuffer);
-        }
-
-        return kStatus_Success;
-    }
-
-    return kStatus_SDMMC_TransferFailed;
-}
-
-static status_t MMC_SetPowerClass(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    uint8_t mask = 0, shift = 0U;
-    uint8_t powerClass = 0;
-    mmc_extended_csd_config_t extendedCsdconfig;
-
-    /* Legacy mmc card , do not support the command */
-    if ((card->csd.systemSpecificationVersion == (uint32_t)kMMC_SpecificationVersion3) &&
-        (card->csd.csdStructureVersion == (uint32_t)kMMC_CsdStrucureVersion12))
-    {
-        return kStatus_Success;
-    }
-
-    if ((card->busWidth == kMMC_DataBusWidth4bit) || (card->busWidth == kMMC_DataBusWidth4bitDDR))
-    {
-        mask  = MMC_POWER_CLASS_4BIT_MASK; /* The mask of 4 bit bus width's power class */
-        shift = 0U;
-    }
-    else if ((card->busWidth == kMMC_DataBusWidth8bit) || (card->busWidth == kMMC_DataBusWidth8bitDDR))
-    {
-        mask  = MMC_POWER_CLASS_8BIT_MASK; /* The mask of 8 bit bus width's power class */
-        shift = 4U;
-    }
-    else
-    {
-        return kStatus_Success;
-    }
-
-    switch (card->hostVoltageWindowVCC)
-    {
-        case kMMC_VoltageWindows270to360:
-
-            if (card->busTiming == kMMC_HighSpeed200Timing)
-            {
-                if (card->hostVoltageWindowVCCQ == kMMC_VoltageWindow170to195)
-                {
-                    powerClass = ((card->extendedCsd.powerClass200MHZVCCQ195VVCC360V) & mask);
-                }
-                else if (card->hostVoltageWindowVCCQ == kMMC_VoltageWindow120)
-                {
-                    powerClass = ((card->extendedCsd.powerClass200MHZVCCQ130VVCC360V) & mask);
-                }
-                else
-                {
-                    /* intentional empty */
-                }
-            }
-            else if (card->busTiming == kMMC_HighSpeed400Timing)
-            {
-                powerClass = ((card->extendedCsd.powerClass200MHZDDR360V) & mask);
-            }
-            else if ((card->busTiming == kMMC_HighSpeedTiming) && (card->busWidth > kMMC_DataBusWidth8bit))
-            {
-                powerClass = ((card->extendedCsd.powerClass52MHZDDR360V) & mask);
-            }
-            else if ((card->busTiming == kMMC_HighSpeedTiming) && (card->busClock_Hz > MMC_CLOCK_26MHZ))
-            {
-                powerClass = ((card->extendedCsd.powerClass52MHz360V) & mask);
-            }
-            else if (card->busTiming == kMMC_HighSpeedTiming)
-            {
-                powerClass = ((card->extendedCsd.powerClass26MHz360V) & mask);
-            }
-            else
-            {
-                /* intentional empty */
-            }
-
-            break;
-
-        case kMMC_VoltageWindow170to195:
-
-            if ((card->busTiming == kMMC_HighSpeedTiming) && (card->busClock_Hz <= MMC_CLOCK_26MHZ))
-            {
-                powerClass = ((card->extendedCsd.powerClass26MHz195V) & mask);
-            }
-            else if ((card->busTiming == kMMC_HighSpeedTiming) && (card->busClock_Hz > MMC_CLOCK_26MHZ))
-            {
-                powerClass = ((card->extendedCsd.powerClass52MHz195V) & mask);
-            }
-            else if ((card->busTiming == kMMC_HighSpeedTiming) && (card->busWidth > kMMC_DataBusWidth8bit))
-            {
-                powerClass = ((card->extendedCsd.powerClass52MHZDDR195V) & mask);
-            }
-            else
-            {
-                /* intentional empty */
-            }
-
-            break;
-        default:
-            powerClass = 0;
-            break;
-    }
-
-    /* due to 8bit power class position [7:4] */
-    powerClass >>= shift;
-
-    if (powerClass > 0U)
-    {
-        extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-        extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexPowerClass;
-        extendedCsdconfig.ByteValue  = powerClass;
-        extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-        if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-        {
-            return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-        }
-        /* restore power class */
-        card->extendedCsd.powerClass = powerClass;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SendTestPattern(mmc_card_t *card, uint32_t blockSize, uint32_t *pattern)
-{
-    assert(card != NULL);
-    assert(blockSize <= FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-    assert(pattern != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kMMC_SendingBusTest;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    /* Ignore errors in bus test procedure to improve chances that the test will work. */
-    data.enableIgnoreError = true;
-    data.blockCount        = 1U;
-    data.blockSize         = blockSize;
-    data.txData            = pattern;
-
-    content.command = &command;
-    content.data    = &data;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success != error) || ((command.response[0U] & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_ReceiveTestPattern(mmc_card_t *card, uint32_t blockSize, uint32_t *pattern)
-{
-    assert(card != NULL);
-    assert(blockSize <= FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-    assert(pattern != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kMMC_BusTestRead;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    /* Ignore errors in bus test procedure to improve chances that the test will work. */
-    data.enableIgnoreError = true;
-    data.blockCount        = 1U;
-    data.blockSize         = blockSize;
-    data.rxData            = pattern;
-
-    content.command = &command;
-    content.data    = &data;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success != error) || (((command.response[0U]) & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_TestDataBusWidth(mmc_card_t *card, mmc_data_bus_width_t width)
-{
-    assert(card != NULL);
-
-    uint32_t blockSize       = 0U;
-    uint32_t tempsendPattern = 0U;
-    uint32_t *tempPattern    = (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    uint32_t xorMask         = 0U;
-    uint32_t xorResult       = 0U;
-
-    /* For 8 data lines the data block would be (MSB to LSB): 0x0000_0000_0000_AA55,
-    For 4 data lines the data block would be (MSB to LSB): 0x0000_005A,
-    For only 1 data line the data block would be: 0x80 */
-    switch (width)
-    {
-        case kMMC_DataBusWidth8bit:
-        case kMMC_DataBusWidth8bitDDR:
-            blockSize       = 8U;
-            tempPattern[0U] = 0xAA55U;
-            xorMask         = 0xFFFFU;
-            xorResult       = 0xFFFFU;
-            break;
-        case kMMC_DataBusWidth4bit:
-        case kMMC_DataBusWidth4bitDDR:
-            blockSize       = 4U;
-            tempPattern[0U] = 0x5AU;
-            xorMask         = 0xFFU;
-            xorResult       = 0xFFU;
-            break;
-        default:
-            blockSize       = 4U;
-            tempPattern[0U] = 0x80U;
-            xorMask         = 0xFFU;
-            xorResult       = 0xC0U;
-            break;
-    }
-
-    SDMMCHOST_ConvertDataToLittleEndian(card->host, &tempPattern[0], 1U, kSDMMC_DataPacketFormatLSBFirst);
-    SDMMCHOST_ConvertDataToLittleEndian(card->host, &xorMask, 1U, kSDMMC_DataPacketFormatLSBFirst);
-    SDMMCHOST_ConvertDataToLittleEndian(card->host, &xorResult, 1U, kSDMMC_DataPacketFormatLSBFirst);
-
-    (void)MMC_SendTestPattern(card, blockSize, tempPattern);
-    /* restore the send pattern */
-    tempsendPattern = tempPattern[0U];
-    /* reset the global buffer */
-    tempPattern[0U] = 0U;
-
-    (void)MMC_ReceiveTestPattern(card, blockSize, tempPattern);
-
-    /* XOR the send pattern and receive pattern */
-    if (((tempPattern[0U] ^ tempsendPattern) & xorMask) != xorResult)
-    {
-        return kStatus_Fail;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SetDataBusWidth(mmc_card_t *card, mmc_data_bus_width_t width)
-{
-    assert(card != NULL);
-
-    mmc_extended_csd_config_t extendedCsdconfig;
-
-    /* Set data bus width */
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexBusWidth;
-    extendedCsdconfig.ByteValue  = (uint8_t)width;
-    extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-    if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-    {
-        return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-    /* restore data bus width */
-    card->extendedCsd.dataBusWidth = (uint8_t)width;
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SetMaxDataBusWidth(mmc_card_t *card, mmc_high_speed_timing_t targetTiming)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Fail;
-
-    do
-    {
-        if (card->busWidth == kMMC_DataBusWidth1bit)
-        {
-            card->busWidth = kMMC_DataBusWidth8bitDDR;
-        }
-
-        if (card->busWidth == kMMC_DataBusWidth8bitDDR)
-        {
-            if (((card->host->capability &
-                  ((uint32_t)kSDMMCHOST_Support8BitDataWidth | (uint32_t)kSDMMCHOST_SupportDDRMode)) ==
-                 ((uint32_t)kSDMMCHOST_Support8BitDataWidth | (uint32_t)kSDMMCHOST_SupportDDRMode)) &&
-                (0U != (card->flags & ((uint32_t)kMMC_SupportHighSpeedDDR52MHZ180V300VFlag |
-                                       (uint32_t)kMMC_SupportHighSpeedDDR52MHZ120VFlag))) &&
-                ((targetTiming == kMMC_HighSpeedTiming) || (targetTiming == kMMC_HighSpeed400Timing)) &&
-                ((card->usrParam.capability & (uint32_t)kSDMMC_Support8BitWidth) != 0U))
-            {
-                SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith8Bit);
-                if (kStatus_Success == MMC_TestDataBusWidth(card, kMMC_DataBusWidth8bitDDR))
-                {
-                    if (kStatus_Success == MMC_SetDataBusWidth(card, kMMC_DataBusWidth8bitDDR))
-                    {
-                        error          = kStatus_Success;
-                        card->busWidth = kMMC_DataBusWidth8bitDDR;
-                        break;
-                    }
-                }
-
-                /* HS400 mode only support 8bit data bus */
-                if (card->busTiming == kMMC_HighSpeed400Timing)
-                {
-                    return kStatus_SDMMC_SetDataBusWidthFailed;
-                }
-            }
-            card->busWidth = kMMC_DataBusWidth4bitDDR;
-        }
-
-        if (card->busWidth == kMMC_DataBusWidth4bitDDR)
-        {
-            if (((card->host->capability &
-                  ((uint32_t)kSDMMCHOST_Support4BitDataWidth | (uint32_t)kSDMMCHOST_SupportDDRMode)) ==
-                 ((uint32_t)kSDMMCHOST_Support4BitDataWidth | (uint32_t)kSDMMCHOST_SupportDDRMode)) &&
-                (0U != (card->flags & ((uint32_t)kMMC_SupportHighSpeedDDR52MHZ180V300VFlag |
-                                       (uint32_t)kMMC_SupportHighSpeedDDR52MHZ120VFlag))) &&
-                ((targetTiming == kMMC_HighSpeedTiming) || (targetTiming == kMMC_HighSpeed400Timing)))
-            {
-                SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith4Bit);
-                if (kStatus_Success == MMC_TestDataBusWidth(card, kMMC_DataBusWidth4bitDDR))
-                {
-                    if (kStatus_Success == MMC_SetDataBusWidth(card, kMMC_DataBusWidth4bitDDR))
-                    {
-                        error          = kStatus_Success;
-                        card->busWidth = kMMC_DataBusWidth4bitDDR;
-                        break;
-                    }
-                }
-            }
-            card->busWidth = kMMC_DataBusWidth8bit;
-        }
-
-        if (card->busWidth == kMMC_DataBusWidth8bit)
-        {
-            if (((card->host->capability & (uint32_t)kSDMMCHOST_Support8BitDataWidth) != 0U) &&
-                ((targetTiming == kMMC_HighSpeedTiming) || (targetTiming == kMMC_HighSpeed200Timing)) &&
-                ((card->usrParam.capability & (uint32_t)kSDMMC_Support8BitWidth) != 0U))
-            {
-                SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith8Bit);
-                if (kStatus_Success == MMC_TestDataBusWidth(card, kMMC_DataBusWidth8bit))
-                {
-                    if (kStatus_Success == MMC_SetDataBusWidth(card, kMMC_DataBusWidth8bit))
-                    {
-                        error          = kStatus_Success;
-                        card->busWidth = kMMC_DataBusWidth8bit;
-                        break;
-                    }
-                }
-            }
-            card->busWidth = kMMC_DataBusWidth4bit;
-        }
-
-        if (card->busWidth == kMMC_DataBusWidth4bit)
-        {
-            if (((card->host->capability & (uint32_t)kSDMMCHOST_Support8BitDataWidth) != 0U) &&
-                ((targetTiming == kMMC_HighSpeedTiming) || (targetTiming == kMMC_HighSpeed200Timing)))
-            {
-                SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith4Bit);
-                if (kStatus_Success == MMC_TestDataBusWidth(card, kMMC_DataBusWidth4bit))
-                {
-                    if (kStatus_Success == MMC_SetDataBusWidth(card, kMMC_DataBusWidth4bit))
-                    {
-                        error          = kStatus_Success;
-                        card->busWidth = kMMC_DataBusWidth4bit;
-                        break;
-                    }
-                }
-                /* HS200 mode only support 4bit/8bit data bus */
-                if (targetTiming == kMMC_HighSpeed200Timing)
-                {
-                    return kStatus_SDMMC_SetDataBusWidthFailed;
-                }
-            }
-        }
-
-    } while (false);
-
-    if (error == kStatus_Fail)
-    {
-        /* Card's data bus width will be default 1 bit mode. */
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith1Bit);
-        card->busWidth = kMMC_DataBusWidth1bit;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SwitchHSTiming(mmc_card_t *card, uint8_t timing, uint8_t driverStrength)
-{
-    assert(card != NULL);
-
-    uint8_t hsTiming = 0;
-
-    mmc_extended_csd_config_t extendedCsdconfig;
-
-    /* check the target driver strength support or not */
-    if (((card->extendedCsd.ioDriverStrength & (1U << driverStrength)) == 0U) &&
-        (card->extendedCsd.extendecCsdVersion >= (uint8_t)kMMC_ExtendedCsdRevision17))
-    {
-        return kStatus_SDMMC_NotSupportYet;
-    }
-    /* calucate the register value */
-    hsTiming = (timing & 0xFU) | (uint8_t)(driverStrength << 4U);
-
-    /* Switch to high speed timing. */
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexHighSpeedTiming;
-    extendedCsdconfig.ByteValue  = hsTiming;
-    extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-    if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-    {
-        return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-
-    card->extendedCsd.highSpeedTiming = hsTiming;
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SwitchToHighSpeed(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t freq = 0U;
-
-    if (kStatus_Success != MMC_SwitchHSTiming(card, (uint8_t)kMMC_HighSpeedTiming, kMMC_DriverStrength0))
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-
-    if ((card->flags & (uint32_t)kMMC_SupportHighSpeed52MHZFlag) != 0U)
-    {
-        freq = FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, MMC_CLOCK_52MHZ);
-    }
-    else if ((card->flags & (uint32_t)kMMC_SupportHighSpeed26MHZFlag) != 0U)
-    {
-        freq = FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, MMC_CLOCK_26MHZ);
-    }
-    else
-    {
-        /* Intentional empty */
-    }
-
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, freq);
-    /* config io speed and strength */
-    if (card->usrParam.ioStrength != NULL)
-    {
-        card->usrParam.ioStrength(MMC_CLOCK_52MHZ);
-    }
-    /* Set card data width, it is nessesary to config the the data bus here, to meet emmc5.0 specification,
-     * when you are working in DDR mode , HS_TIMING must set before set bus width
-     */
-    if (MMC_SetMaxDataBusWidth(card, kMMC_HighSpeedTiming) != kStatus_Success)
-    {
-        return kStatus_SDMMC_SetDataBusWidthFailed;
-    }
-
-    if ((card->busWidth == kMMC_DataBusWidth4bitDDR) || (card->busWidth == kMMC_DataBusWidth8bitDDR))
-    {
-        SDMMCHOST_EnableDDRMode(card->host, true, 0U);
-    }
-
-    card->busTiming = kMMC_HighSpeedTiming;
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SwitchToHS200(mmc_card_t *card, uint32_t freq)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Fail;
-
-    if ((card->hostVoltageWindowVCCQ != kMMC_VoltageWindow170to195) &&
-        (card->hostVoltageWindowVCCQ != kMMC_VoltageWindow120))
-    {
-        return kStatus_SDMMC_InvalidVoltage;
-    }
-
-    /* select bus width before select bus timing for HS200 mode */
-    if (MMC_SetMaxDataBusWidth(card, kMMC_HighSpeed200Timing) != kStatus_Success)
-    {
-        return kStatus_SDMMC_SetDataBusWidthFailed;
-    }
-
-    /* switch to HS200 mode */
-    if (kStatus_Success != MMC_SwitchHSTiming(card, (uint8_t)kMMC_HighSpeed200Timing, kMMC_DriverStrength0))
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, freq);
-    /* config io speed and strength */
-    if (card->usrParam.ioStrength != NULL)
-    {
-        card->usrParam.ioStrength(freq);
-    }
-
-    /* excute tuning for HS200 */
-    if (MMC_ExecuteTuning(card) != kStatus_Success)
-    {
-        return kStatus_SDMMC_TuningFail;
-    }
-
-    card->busTiming = kMMC_HighSpeed200Timing;
-
-    error = MMC_PollingCardStatusBusy(card, true, MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SwitchToHS400(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t status    = 0U;
-    uint32_t hs400Freq = FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, MMC_CLOCK_HS400);
-    status_t error     = kStatus_Fail;
-
-    if ((card->hostVoltageWindowVCCQ != kMMC_VoltageWindow170to195) &&
-        (card->hostVoltageWindowVCCQ != kMMC_VoltageWindow120))
-    {
-        return kStatus_SDMMC_InvalidVoltage;
-    }
-
-    if (card->host->hostController.sourceClock_Hz < MMC_CLOCK_HS400)
-    {
-        hs400Freq = card->host->hostController.sourceClock_Hz;
-    }
-
-    if ((card->host->hostController.sourceClock_Hz > MMC_CLOCK_HS400) &&
-        (card->host->hostController.sourceClock_Hz % MMC_CLOCK_HS400 != 0U))
-    {
-        hs400Freq = card->host->hostController.sourceClock_Hz /
-                    (card->host->hostController.sourceClock_Hz / MMC_CLOCK_HS400 + 1U);
-    }
-    /* HS400 mode support 8 bit data bus only */
-    card->busWidth = kMMC_DataBusWidth8bit;
-    /* switch to HS200 perform tuning */
-    if (kStatus_Success != MMC_SwitchToHS200(card, hs400Freq / 2U))
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-
-    /* check data bus width is 8 bit , otherwise return false*/
-    if (card->busWidth != kMMC_DataBusWidth8bit)
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-
-    /*
-     * For the issue found in stress test of repeat emmc initialization operation, after HS200 switch complete, the emmc
-     * status not correct for switching to high speed, normally the emmc should stay in TRAN state, but sometimes the
-     * emmc status is in DATA state which will cause switch to High speed failed. when such issue happen, software will
-     * try to use CMD12 to reset the emmc status to TRAN before switch to high speed for HS400.
-     */
-    error = MMC_SendStatus(card, &status);
-    if (error != kStatus_Success)
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-
-    if (SDMMC_R1_CURRENT_STATE(status) == (uint32_t)kSDMMC_R1StateSendData)
-    {
-        SDMMC_LOG("status uncorrect for switching to High speed timing, try use CMD12 to get back to TRAN state\r\n");
-        /* try to get back to transfer state before switch to High speed */
-        (void)MMC_StopTransmission(card);
-    }
-
-    /*switch to high speed*/
-    if (kStatus_Success != MMC_SwitchHSTiming(card, (uint8_t)kMMC_HighSpeedTiming, kMMC_DriverStrength0))
-    {
-        return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-
-    /* switch to high speed first */
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, MMC_CLOCK_52MHZ);
-    /* config io strength */
-    if (card->usrParam.ioStrength != NULL)
-    {
-        card->usrParam.ioStrength(MMC_CLOCK_52MHZ);
-    }
-
-    card->busTiming = kMMC_HighSpeed400Timing;
-    /* switch to 8 bit DDR data bus width */
-    if (kStatus_Success != MMC_SetDataBusWidth(card, kMMC_DataBusWidth8bitDDR))
-    {
-        return kStatus_SDMMC_SetDataBusWidthFailed;
-    }
-    /* switch to HS400 */
-    if (kStatus_Success != MMC_SwitchHSTiming(card, (uint8_t)kMMC_HighSpeed400Timing, kMMC_DriverStrength0))
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-    /* config to target freq */
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, hs400Freq / 2U);
-    /* config io speed and strength */
-    if (card->usrParam.ioStrength != NULL)
-    {
-        card->usrParam.ioStrength(MMC_CLOCK_HS200);
-    }
-    /* enable HS400 mode */
-    SDMMCHOST_EnableHS400Mode(card->host, true);
-    /* enable DDR mode */
-    SDMMCHOST_EnableDDRMode(card->host, true, 0U);
-    /* config strobe DLL*/
-    SDMMCHOST_EnableStrobeDll(card->host, true);
-
-    return kStatus_Success;
-}
-
-static status_t MMC_SelectBusTiming(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    /* Legacy mmc card , do not support the command */
-    if ((card->csd.systemSpecificationVersion == (uint8_t)kMMC_SpecificationVersion3) &&
-        (card->csd.csdStructureVersion == (uint8_t)kMMC_CsdStrucureVersion12))
-    {
-        return kStatus_Success;
-    }
-
-    do
-    {
-        if (card->busTiming == kMMC_HighSpeedTimingNone)
-        {
-            /* if timing not specified, probe card capability from HS400 mode */
-            card->busTiming = kMMC_HighSpeed400Timing;
-        }
-
-        if (card->busTiming == kMMC_EnhanceHighSpeed400Timing)
-        {
-            return kStatus_SDMMC_NotSupportYet;
-        }
-
-        if (card->busTiming == kMMC_HighSpeed400Timing)
-        {
-            if (((card->host->capability & (uint32_t)kSDMMCHOST_SupportHS400) != 0U) &&
-                ((card->hostVoltageWindowVCCQ == kMMC_VoltageWindow170to195) ||
-                 (card->hostVoltageWindowVCCQ == kMMC_VoltageWindow120)) &&
-                ((card->flags &
-                  ((uint32_t)kMMC_SupportHS400DDR200MHZ180VFlag | (uint32_t)kMMC_SupportHS400DDR200MHZ120VFlag)) != 0U))
-            {
-                /* switch to HS400 */
-                if (kStatus_Success != MMC_SwitchToHS400(card))
-                {
-                    return kStatus_SDMMC_SwitchBusTimingFailed;
-                }
-                break;
-            }
-
-            card->busTiming = kMMC_HighSpeed200Timing;
-        }
-
-        if (card->busTiming == kMMC_HighSpeed200Timing)
-        {
-            if (((card->host->capability & (uint32_t)kSDMMCHOST_SupportHS200) != 0U) &&
-                ((card->hostVoltageWindowVCCQ == kMMC_VoltageWindow170to195) ||
-                 (card->hostVoltageWindowVCCQ == kMMC_VoltageWindow120)) &&
-                (0U != (card->flags &
-                        ((uint32_t)kMMC_SupportHS200200MHZ180VFlag | (uint32_t)kMMC_SupportHS200200MHZ120VFlag))))
-            {
-                if (kStatus_Success !=
-                    MMC_SwitchToHS200(card, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, MMC_CLOCK_HS200)))
-                {
-                    return kStatus_SDMMC_SwitchBusTimingFailed;
-                }
-                break;
-            }
-
-            card->busTiming = kMMC_HighSpeedTiming;
-        }
-
-        if (card->busTiming == kMMC_HighSpeedTiming)
-        {
-            if (kStatus_Success != MMC_SwitchToHighSpeed(card))
-            {
-                return kStatus_SDMMC_SwitchBusTimingFailed;
-            }
-            break;
-        }
-    } while (false);
-
-    return kStatus_Success;
-}
-
-static void MMC_DecodeCid(mmc_card_t *card, uint32_t *rawCid)
-{
-    assert(card != NULL);
-    assert(rawCid != NULL);
-
-    mmc_cid_t *cid;
-
-    cid                 = &(card->cid);
-    cid->manufacturerID = (uint8_t)((rawCid[3U] & 0xFF000000U) >> 24U);
-    cid->applicationID  = (uint16_t)((rawCid[3U] & 0xFFFF00U) >> 8U);
-
-    cid->productName[0U] = (uint8_t)((rawCid[3U] & 0xFFU));
-    cid->productName[1U] = (uint8_t)((rawCid[2U] & 0xFF000000U) >> 24U);
-    cid->productName[2U] = (uint8_t)((rawCid[2U] & 0xFF0000U) >> 16U);
-    cid->productName[3U] = (uint8_t)((rawCid[2U] & 0xFF00U) >> 8U);
-    cid->productName[4U] = (uint8_t)((rawCid[2U] & 0xFFU));
-
-    cid->productVersion = (uint8_t)((rawCid[1U] & 0xFF000000U) >> 24U);
-
-    cid->productSerialNumber = (uint32_t)((rawCid[1U] & 0xFFFFFFU) << 8U);
-    cid->productSerialNumber |= (uint32_t)((rawCid[0U] & 0xFF000000U) >> 24U);
-
-    cid->manufacturerData = (uint8_t)((rawCid[0U] & 0xFFF00U) >> 8U);
-}
-
-static status_t MMC_AllSendCid(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDMMC_AllSendCid;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR2;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success == error)
-    {
-        (void)memcpy(card->internalBuffer, (uint8_t *)command.response, 16U);
-        MMC_DecodeCid(card, command.response);
-
-        return kStatus_Success;
-    }
-
-    return kStatus_SDMMC_TransferFailed;
-}
-
-static status_t MMC_SendCsd(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_transfer_t content = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDMMC_SendCsd;
-    command.argument     = (card->relativeAddress << 16U);
-    command.responseType = kCARD_ResponseTypeR2;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success == error)
-    {
-        (void)memcpy(card->internalBuffer, (uint8_t *)command.response, 16U);
-        /* The response is from bit 127:8 in R2, corresponding to command.response[3][31:0] to
-        command.response[0U][31:8]. */
-        MMC_DecodeCsd(card, (uint32_t *)(uint32_t)card->internalBuffer);
-
-        return kStatus_Success;
-    }
-
-    return kStatus_SDMMC_TransferFailed;
-}
-
-static status_t MMC_CheckBlockRange(mmc_card_t *card, uint32_t startBlock, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(blockCount != 0U);
-
-    status_t error = kStatus_Success;
-    uint32_t partitionBlocks;
-
-    switch (card->currentPartition)
-    {
-        case kMMC_AccessPartitionUserAera:
-        {
-            partitionBlocks = card->userPartitionBlocks;
-            break;
-        }
-        case kMMC_AccessPartitionBoot1:
-        case kMMC_AccessPartitionBoot2:
-        {
-            /* Boot partition 1 and partition 2 have the same partition size. */
-            partitionBlocks = card->bootPartitionBlocks;
-            break;
-        }
-        default:
-            error = kStatus_InvalidArgument;
-            break;
-    }
-    /* Check if the block range accessed is within current partition's block boundary. */
-    if ((error == kStatus_Success) && ((startBlock + blockCount) > partitionBlocks))
-    {
-        error = kStatus_InvalidArgument;
-    }
-
-    return error;
-}
-
-static status_t MMC_CheckEraseGroupRange(mmc_card_t *card, uint32_t startGroup, uint32_t endGroup)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-    uint32_t partitionBlocks;
-    uint32_t eraseGroupBoundary;
-
-    switch (card->currentPartition)
-    {
-        case kMMC_AccessPartitionUserAera:
-        {
-            partitionBlocks = card->userPartitionBlocks;
-            break;
-        }
-        case kMMC_AccessPartitionBoot1:
-        case kMMC_AccessPartitionBoot2:
-        {
-            /* Boot partition 1 and partition 2 have the same partition size. */
-            partitionBlocks = card->bootPartitionBlocks;
-            break;
-        }
-        default:
-            error = kStatus_InvalidArgument;
-            break;
-    }
-
-    if (error == kStatus_Success)
-    {
-        /* Check if current partition's total block count is integer multiples of the erase group size. */
-        if ((partitionBlocks % card->eraseGroupBlocks) == 0U)
-        {
-            eraseGroupBoundary = (partitionBlocks / card->eraseGroupBlocks);
-        }
-        else
-        {
-            /* Card will ignore the unavailable blocks within the last erase group automatically. */
-            eraseGroupBoundary = (partitionBlocks / card->eraseGroupBlocks + 1U);
-        }
-
-        /* Check if the group range accessed is within current partition's erase group boundary. */
-        if ((startGroup > eraseGroupBoundary) || (endGroup > eraseGroupBoundary))
-        {
-            error = kStatus_InvalidArgument;
-        }
-    }
-
-    return error;
-}
-
-static status_t MMC_Read(
-    mmc_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockSize, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-    assert(blockSize != 0U);
-    assert(blockSize == FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    sdmmchost_transfer_t content = {0};
-    status_t error;
-
-    if ((((card->flags & (uint32_t)kMMC_SupportHighCapacityFlag) != 0U) && (blockSize != 512U)) ||
-        (blockSize > card->blockSize) || (blockSize > card->host->maxBlockSize) || (0U != (blockSize % 4U)))
-    {
-        return kStatus_SDMMC_CardNotSupport;
-    }
-
-    error = MMC_PollingCardStatusBusy(card, true, MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        SDMMC_LOG("Error : read failed with wrong card status\r\n");
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    data.blockSize           = blockSize;
-    data.blockCount          = blockCount;
-    data.rxData              = (uint32_t *)(uint32_t)buffer;
-    data.enableAutoCommand12 = true;
-    command.index            = (uint32_t)kSDMMC_ReadMultipleBlock;
-    if (data.blockCount == 1U)
-    {
-        command.index = (uint32_t)kSDMMC_ReadSingleBlock;
-    }
-    else
-    {
-        if (card->enablePreDefinedBlockCount)
-        {
-            data.enableAutoCommand12 = false;
-            /* If enabled the pre-define count read/write feature of the card, need to set block count firstly. */
-            if (kStatus_Success != MMC_SetBlockCount(card, blockCount))
-            {
-                return kStatus_SDMMC_SetBlockCountFailed;
-            }
-        }
-    }
-    command.argument = startBlock;
-    if (0U == (card->flags & (uint32_t)kMMC_SupportHighCapacityFlag))
-    {
-        command.argument *= data.blockSize;
-    }
-    command.responseType       = kCARD_ResponseTypeR1;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = &data;
-
-    /* should check tuning error during every transfer */
-    error = MMC_Transfer(card, &content, 3U);
-    if (kStatus_Success != error)
-    {
-        return error;
-    }
-
-    /* When host's AUTO_COMMAND12 feature isn't enabled and PRE_DEFINED_COUNT command isn't enabled in multiple
-    blocks transmission, sends STOP_TRANSMISSION command. */
-    if ((blockCount > 1U) && (!(data.enableAutoCommand12)) && (!card->enablePreDefinedBlockCount))
-    {
-        if (kStatus_Success != MMC_StopTransmission(card))
-        {
-            return kStatus_SDMMC_StopTransmissionFailed;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_Write(
-    mmc_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockSize, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-    assert(blockSize != 0U);
-    assert(blockSize == FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    sdmmchost_transfer_t content = {0};
-    status_t error;
-
-    /* Check address range */
-    if ((((card->flags & (uint32_t)kMMC_SupportHighCapacityFlag) != 0U) && (blockSize != 512U)) ||
-        (blockSize > card->blockSize) || (blockSize > card->host->maxBlockSize) || (0U != (blockSize % 4U)))
-    {
-        return kStatus_SDMMC_CardNotSupport;
-    }
-
-    /* send CMD13 to make sure card is ready for data */
-    error = MMC_PollingCardStatusBusy(card, true, MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        SDMMC_LOG("Error : write card busy with wrong card status\r\n");
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    data.blockSize           = blockSize;
-    data.blockCount          = blockCount;
-    data.txData              = (const uint32_t *)(uint32_t)buffer;
-    data.enableAutoCommand12 = true;
-
-    command.index = (uint32_t)kSDMMC_WriteMultipleBlock;
-    if (data.blockCount == 1U)
-    {
-        command.index = (uint32_t)kSDMMC_WriteSingleBlock;
-    }
-    else
-    {
-        if (card->enablePreDefinedBlockCount)
-        {
-            data.enableAutoCommand12 = false;
-            /* If enabled the pre-define count read/write featue of the card, need to set block count firstly */
-            if (kStatus_Success != MMC_SetBlockCount(card, blockCount))
-            {
-                return kStatus_SDMMC_SetBlockCountFailed;
-            }
-        }
-    }
-    command.argument = startBlock;
-    if (0U == (card->flags & (uint32_t)kMMC_SupportHighCapacityFlag))
-    {
-        command.argument *= blockSize;
-    }
-    command.responseType       = kCARD_ResponseTypeR1;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = &data;
-
-    /* should check tuning error during every transfer */
-    error = MMC_Transfer(card, &content, 3U);
-    if (kStatus_Success != error)
-    {
-        return error;
-    }
-
-    /* When host's AUTO_COMMAND12 feature isn't enabled and PRE_DEFINED_COUNT command isn't enabled in multiple
-    blocks transmission, sends STOP_TRANSMISSION command. */
-    if ((blockCount > 1U) && (!(data.enableAutoCommand12)) && (!card->enablePreDefinedBlockCount))
-    {
-        if (kStatus_Success != MMC_StopTransmission(card))
-        {
-            return kStatus_SDMMC_StopTransmissionFailed;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_ValidateOperationVoltage(mmc_card_t *card, uint32_t *opcode)
-{
-    status_t status = kStatus_Fail;
-
-    if (card->hostVoltageWindowVCC == kMMC_VoltageWindow170to195)
-    {
-        if ((card->ocr & MMC_OCR_V170TO195_MASK) != 0U)
-        {
-            *opcode |= MMC_OCR_V170TO195_MASK;
-            status = kStatus_Success;
-        }
-    }
-    else if (card->hostVoltageWindowVCC == kMMC_VoltageWindows270to360)
-    {
-        if ((card->ocr & MMC_OCR_V270TO360_MASK) != 0U)
-        {
-            *opcode |= MMC_OCR_V270TO360_MASK;
-            status = kStatus_Success;
-        }
-    }
-    else
-    {
-        /* Intentional empty */
-    }
-
-    return status;
-}
-
-static status_t mmccard_init(mmc_card_t *card)
-{
-    assert(card != NULL);
-    assert((card->hostVoltageWindowVCC != kMMC_VoltageWindowNone) &&
-           (card->hostVoltageWindowVCC != kMMC_VoltageWindow120));
-    assert(card->hostVoltageWindowVCCQ != kMMC_VoltageWindowNone);
-
-    uint32_t opcode = 0U;
-    status_t error  = kStatus_Success;
-
-    if (!card->isHostReady)
-    {
-        return kStatus_SDMMC_HostNotReady;
-    }
-    /* set DATA bus width */
-    SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith1Bit);
-    /* Set clock to 400KHz. */
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, SDMMC_CLOCK_400KHZ);
-
-    error = MMC_GoIdle(card);
-    /* Send CMD0 to reset the bus */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_GoIdleFailed;
-    }
-
-    /* Hand-shaking with card to validata the voltage range Host first sending its expected
-       information.*/
-    error = MMC_SendOperationCondition(card, 0U);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_HandShakeOperationConditionFailed;
-    }
-
-    error = MMC_ValidateOperationVoltage(card, &opcode);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_InvalidVoltage;
-    }
-
-    /* Get host's access mode. */
-    opcode |= (card->host->maxBlockSize >= FSL_SDMMC_DEFAULT_BLOCK_SIZE ?
-                   (uint32_t)kMMC_AccessModeSector << MMC_OCR_ACCESS_MODE_SHIFT :
-                   (uint32_t)kMMC_AccessModeByte << MMC_OCR_ACCESS_MODE_SHIFT);
-
-    error = MMC_SendOperationCondition(card, opcode);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_HandShakeOperationConditionFailed;
-    }
-
-    /* Get card CID */
-    error = MMC_AllSendCid(card);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_AllSendCidFailed;
-    }
-
-    error = MMC_SetRelativeAddress(card);
-    /* Set the card relative address */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SetRelativeAddressFailed;
-    }
-
-    error = MMC_SendCsd(card);
-    /* Get the CSD register content */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SendCsdFailed;
-    }
-
-    /* Set to maximum speed in normal mode. */
-    MMC_SetMaxFrequency(card);
-
-    /* Send CMD7 with the card's relative address to place the card in transfer state. Puts current selected card in
-    transfer state. */
-    error = MMC_SelectCard(card, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SelectCardFailed;
-    }
-
-    /* Get Extended CSD register content. */
-    error = MMC_SendExtendedCsd(card, NULL, 0U);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SendExtendedCsdFailed;
-    }
-
-    error = MMC_SetMaxEraseUnitSize(card);
-    /* Set to max erase unit size */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_EnableHighCapacityEraseFailed;
-    }
-
-    error = MMC_SetBlockSize(card, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-    /* set block size */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SetCardBlockSizeFailed;
-    }
-
-    error = MMC_SelectBusTiming(card);
-    /* switch to host support speed mode, then switch MMC data bus width and select power class */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-
-    error = MMC_SetPowerClass(card);
-    /* switch power class */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SetPowerClassFail;
-    }
-
-    /* trying to enable the cache */
-    (void)MMC_EnableCacheControl(card, true);
-
-    /* Set card default to access non-boot partition */
-    card->currentPartition = kMMC_AccessPartitionUserAera;
-
-    return kStatus_Success;
-}
-
-status_t MMC_CardInit(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-    /* create mutex lock */
-    (void)SDMMC_OSAMutexCreate(&card->lock);
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    error = mmccard_init(card);
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-void MMC_CardDeinit(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    (void)MMC_SelectCard(card, false);
-
-    (void)SDMMC_OSAMutexDestroy(&card->lock);
-}
-
-status_t MMC_HostInit(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    if (!card->isHostReady)
-    {
-        if (SDMMCHOST_Init(card->host) != kStatus_Success)
-        {
-            return kStatus_Fail;
-        }
-    }
-
-    /* set the host status flag, after the card re-plug in, don't need init host again */
-    card->isHostReady = true;
-
-    return kStatus_Success;
-}
-
-void MMC_HostDeinit(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    SDMMCHOST_Deinit(card->host);
-    /* should re-init host */
-    card->isHostReady = false;
-}
-
-void MMC_HostReset(SDMMCHOST_CONFIG *host)
-{
-    SDMMCHOST_Reset(host);
-}
-
-void MMC_HostDoReset(mmc_card_t *card)
-{
-    SDMMCHOST_Reset(card->host);
-}
-
-void MMC_SetCardPower(mmc_card_t *card, bool enable)
-{
-    SDMMCHOST_SetCardPower(card->host, enable);
-    SDMMC_OSADelay(MMC_POWER_RESET_DELAY);
-}
-
-status_t MMC_Init(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-
-    if (!card->isHostReady)
-    {
-        if (MMC_HostInit(card) != kStatus_Success)
-        {
-            error = kStatus_SDMMC_HostNotReady;
-        }
-    }
-    else
-    {
-        /* reset the host */
-        MMC_HostDoReset(card);
-    }
-
-    if (error == kStatus_Success)
-    {
-        /* reset card power */
-        MMC_SetCardPower(card, false);
-        MMC_SetCardPower(card, true);
-
-        error = MMC_CardInit(card);
-        if (error != kStatus_Success)
-        {
-            error = kStatus_SDMMC_CardInitFailed;
-        }
-    }
-
-    return error;
-}
-
-void MMC_Deinit(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    MMC_CardDeinit(card);
-    MMC_HostDeinit(card);
-}
-
-bool MMC_CheckReadOnly(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    return (((card->csd.flags & (uint16_t)kMMC_CsdPermanentWriteProtectFlag) != 0U) ||
-            ((card->csd.flags & (uint16_t)kMMC_CsdTemporaryWriteProtectFlag) != 0U));
-}
-
-status_t MMC_SelectPartition(mmc_card_t *card, mmc_access_partition_t partitionNumber)
-{
-    assert(card != NULL);
-
-    uint8_t bootConfig;
-    mmc_extended_csd_config_t extendedCsdconfig;
-    status_t error = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    bootConfig = card->extendedCsd.partitionConfig;
-    bootConfig &= ~(uint8_t)MMC_PARTITION_CONFIG_PARTITION_ACCESS_MASK;
-    bootConfig |= ((uint8_t)partitionNumber << MMC_PARTITION_CONFIG_PARTITION_ACCESS_SHIFT);
-
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexPartitionConfig;
-    extendedCsdconfig.ByteValue  = bootConfig;
-    extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-    if (kStatus_Success !=
-        MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, (uint32_t)card->extendedCsd.partitionSwitchTimeout * 10U))
-    {
-        error = kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-    else
-    {
-        /* Save current configuration. */
-        card->extendedCsd.partitionConfig = bootConfig;
-        card->currentPartition            = partitionNumber;
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t MMC_ReadBlocks(mmc_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-
-    uint32_t blockCountOneTime; /* The block count can be erased in one time sending READ_BLOCKS command. */
-    uint32_t blockDone;         /* The blocks has been read. */
-    uint32_t blockLeft;         /* Left blocks to be read. */
-    uint8_t *nextBuffer;
-    bool dataAddrAlign   = true;
-    uint8_t *alignBuffer = (uint8_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    status_t error       = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    blockLeft = blockCount;
-    blockDone = 0U;
-    error     = MMC_CheckBlockRange(card, startBlock, blockCount);
-    if (kStatus_Success != error)
-    {
-        error = kStatus_InvalidArgument;
-    }
-    else
-    {
-        while (blockLeft != 0U)
-        {
-            nextBuffer = (uint8_t *)((uint32_t)buffer + blockDone * FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-            if (!card->noInteralAlign && (!dataAddrAlign || ((((uint32_t)nextBuffer) & (sizeof(uint32_t) - 1U)) != 0U)))
-            {
-                blockLeft--;
-                blockCountOneTime = 1U;
-                (void)memset(alignBuffer, 0, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-                dataAddrAlign = false;
-            }
-            else
-            {
-                if (blockLeft > card->host->maxBlockCount)
-                {
-                    blockLeft         = (blockLeft - card->host->maxBlockCount);
-                    blockCountOneTime = card->host->maxBlockCount;
-                }
-                else
-                {
-                    blockCountOneTime = blockLeft;
-                    blockLeft         = 0U;
-                }
-            }
-
-            error = MMC_Read(card, dataAddrAlign ? nextBuffer : (uint8_t *)alignBuffer, (startBlock + blockDone),
-                             FSL_SDMMC_DEFAULT_BLOCK_SIZE, blockCountOneTime);
-            if (kStatus_Success != error)
-            {
-                error = kStatus_SDMMC_TransferFailed;
-                break;
-            }
-
-            blockDone += blockCountOneTime;
-
-            if (!card->noInteralAlign && (!dataAddrAlign))
-            {
-                (void)memcpy(nextBuffer, alignBuffer, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-            }
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t MMC_WriteBlocks(mmc_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-
-    uint32_t blockCountOneTime;
-    uint32_t blockLeft;
-    uint32_t blockDone;
-    const uint8_t *nextBuffer;
-    bool dataAddrAlign   = true;
-    uint8_t *alignBuffer = (uint8_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    status_t error       = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    blockLeft = blockCount;
-    blockDone = 0U;
-
-    error = MMC_CheckBlockRange(card, startBlock, blockCount);
-    if (kStatus_Success != error)
-    {
-        error = kStatus_InvalidArgument;
-    }
-    else
-    {
-        while (blockLeft != 0U)
-        {
-            nextBuffer = (uint8_t *)((uint32_t)buffer + blockDone * FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-            if (!card->noInteralAlign && (!dataAddrAlign || (0U != (((uint32_t)nextBuffer) & (sizeof(uint32_t) - 1U)))))
-            {
-                blockLeft--;
-                blockCountOneTime = 1U;
-                (void)memcpy(alignBuffer, nextBuffer, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-                dataAddrAlign = false;
-            }
-            else
-            {
-                if (blockLeft > card->host->maxBlockCount)
-                {
-                    blockLeft         = (blockLeft - card->host->maxBlockCount);
-                    blockCountOneTime = card->host->maxBlockCount;
-                }
-                else
-                {
-                    blockCountOneTime = blockLeft;
-                    blockLeft         = 0U;
-                }
-            }
-            error = MMC_Write(card, dataAddrAlign ? nextBuffer : (uint8_t *)alignBuffer, (startBlock + blockDone),
-                              FSL_SDMMC_DEFAULT_BLOCK_SIZE, blockCountOneTime);
-            if (kStatus_Success != error)
-            {
-                error = kStatus_SDMMC_TransferFailed;
-                break;
-            }
-
-            blockDone += blockCountOneTime;
-            if (!card->noInteralAlign && (!dataAddrAlign))
-            {
-                (void)memset(alignBuffer, 0, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-            }
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t MMC_EnableCacheControl(mmc_card_t *card, bool enable)
-{
-    assert(card != NULL);
-
-    uint8_t cacheCtrl = 0;
-
-    mmc_extended_csd_config_t extendedCsdconfig;
-
-    /* check the target driver strength support or not */
-    if (card->extendedCsd.cacheSize == 0U)
-    {
-        SDMMC_LOG("The cache is not supported by the mmc device\r\n");
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    if (enable)
-    {
-        cacheCtrl = MMC_CACHE_CONTROL_ENABLE;
-    }
-
-    /* Switch to high speed timing. */
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexCacheControl;
-    extendedCsdconfig.ByteValue  = cacheCtrl;
-    extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-    if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-    {
-        SDMMC_LOG("cache enabled failed\r\n");
-        return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-
-    card->extendedCsd.cacheCtrl = cacheCtrl;
-
-    return kStatus_Success;
-}
-
-status_t MMC_FlushCache(mmc_card_t *card)
-{
-    assert(card != NULL);
-
-    mmc_extended_csd_config_t extendedCsdconfig;
-    status_t error = kStatus_Success;
-
-    /* check the target driver strength support or not */
-    if ((card->extendedCsd.cacheSize == 0U) || (card->extendedCsd.cacheCtrl != MMC_CACHE_CONTROL_ENABLE))
-    {
-        SDMMC_LOG("The cache is not supported or not enabled, please check\r\n");
-        error = kStatus_SDMMC_NotSupportYet;
-    }
-    else
-    {
-        /* Switch to high speed timing. */
-        extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-        extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexFlushCache;
-        extendedCsdconfig.ByteValue  = MMC_CACHE_TRIGGER_FLUSH;
-        extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-        if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-        {
-            SDMMC_LOG("cache flush failed\r\n");
-            error = kStatus_SDMMC_ConfigureExtendedCsdFailed;
-        }
-    }
-
-    return error;
-}
-
-status_t MMC_SetSleepAwake(mmc_card_t *card, mmc_sleep_awake_t state)
-{
-    assert(card != NULL);
-    status_t error = kStatus_Success;
-
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_transfer_t content = {0};
-
-    if (card->extendedCsd.extendecCsdVersion <=
-        (uint32_t)kMMC_ExtendedCsdRevision13) /* V4.3 or above version card support boot mode */
-    {
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    error = MMC_PollingCardStatusBusy(card, false, MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    /* deselect the card before enter into sleep state */
-    if (state == kMMC_Sleep)
-    {
-        if (MMC_SelectCard(card, false) != kStatus_Success)
-        {
-            return kStatus_SDMMC_DeselectCardFailed;
-        }
-    }
-
-    command.index        = (uint32_t)kMMC_SleepAwake;
-    command.argument     = ((uint32_t)state << 15U) | (card->relativeAddress << 16U);
-    command.responseType = kCARD_ResponseTypeR1b;
-
-    content.command = &command;
-    content.data    = NULL;
-
-    error = MMC_Transfer(card, &content, 0U);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* Sleep awake timeout value 100ns * 2^sleepAwakeTimeout */
-    error = MMC_PollingCardStatusBusy(card, false, (1UL << card->extendedCsd.sleepAwakeTimeout) / 10000U);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    /* select the card after wake up */
-    if (state == kMMC_Awake)
-    {
-        if (MMC_SelectCard(card, true) != kStatus_Success)
-        {
-            return kStatus_SDMMC_SelectCardFailed;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-static status_t MMC_Erase(mmc_card_t *card, uint32_t startGroupAddress, uint32_t endGroupAddress)
-{
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_transfer_t content = {0};
-    status_t error               = kStatus_Success;
-
-    /* Set the start erase group address */
-    command.index              = (uint32_t)kMMC_EraseGroupStart;
-    command.argument           = startGroupAddress;
-    command.responseType       = kCARD_ResponseTypeR1;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = MMC_Transfer(card, &content, 0U);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* Set the end erase group address */
-    command.index    = (uint32_t)kMMC_EraseGroupEnd;
-    command.argument = endGroupAddress;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = MMC_Transfer(card, &content, 0U);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* Start the erase process */
-    command.index              = (uint32_t)kSDMMC_Erase;
-    command.argument           = 0U;
-    command.responseType       = kCARD_ResponseTypeR1b;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = MMC_Transfer(card, &content, 0U);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t MMC_EraseGroups(mmc_card_t *card, uint32_t startGroup, uint32_t endGroup)
-{
-    assert(card != NULL);
-
-    uint32_t startGroupAddress;
-    uint32_t endGroupAddress;
-    status_t error        = kStatus_Success;
-    uint32_t eraseTimeout = MMC_CARD_ACCESS_WAIT_IDLE_TIMEOUT;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    error = MMC_CheckEraseGroupRange(card, startGroup, endGroup);
-    if (kStatus_Success != error)
-    {
-        error = kStatus_InvalidArgument;
-    }
-    else
-    {
-        error = MMC_PollingCardStatusBusy(card, true, 0U);
-        if (error != kStatus_SDMMC_CardStatusIdle)
-        {
-            error = kStatus_SDMMC_PollingCardIdleFailed;
-        }
-    }
-
-    if (error == kStatus_SDMMC_CardStatusIdle)
-    {
-        /* Calculate the start group address and end group address */
-        startGroupAddress = startGroup;
-        endGroupAddress   = endGroup;
-        if ((card->flags & (uint32_t)kMMC_SupportHighCapacityFlag) != 0U)
-        {
-            /* The implementation of a higher than 2GB of density of memory will not be backwards compatible with the
-            lower densities.First of all the address argument for higher than 2GB of density of memory is changed to
-            be sector address (512B sectors) instead of byte address */
-            startGroupAddress = (startGroupAddress * (card->eraseGroupBlocks));
-            endGroupAddress   = (endGroupAddress * (card->eraseGroupBlocks));
-        }
-        else
-        {
-            /* The address unit is byte when card capacity is lower than 2GB */
-            startGroupAddress = (startGroupAddress * (card->eraseGroupBlocks) * FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-            endGroupAddress   = (endGroupAddress * (card->eraseGroupBlocks) * FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-        }
-
-        error = MMC_Erase(card, startGroupAddress, endGroupAddress);
-        if (error == kStatus_Success)
-        {
-            if ((0U != (card->flags & (uint32_t)kMMC_SupportHighCapacityFlag)) &&
-                (card->extendedCsd.highCapacityEraseTimeout != 0U))
-            {
-                eraseTimeout =
-                    (uint32_t)card->extendedCsd.highCapacityEraseTimeout * 300U * (endGroup - startGroup + 1U);
-            }
-
-            error = MMC_PollingCardStatusBusy(card, true, eraseTimeout);
-            if (kStatus_SDMMC_CardStatusIdle != error)
-            {
-                error = kStatus_SDMMC_PollingCardIdleFailed;
-            }
-            else
-            {
-                error = kStatus_Success;
-            }
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t MMC_SetBootConfigWP(mmc_card_t *card, uint8_t wp)
-{
-    assert(card != NULL);
-
-    mmc_extended_csd_config_t extendedCsdconfig;
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexBootConfigWP;
-    extendedCsdconfig.ByteValue  = wp;
-    extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-    if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-    {
-        return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-
-    card->extendedCsd.bootConfigProtect = wp;
-
-    return kStatus_Success;
-}
-
-status_t MMC_SetBootPartitionWP(mmc_card_t *card, mmc_boot_partition_wp_t bootPartitionWP)
-{
-    assert(card != NULL);
-
-    mmc_extended_csd_config_t extendedCsdconfig;
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexBootPartitionWP;
-    extendedCsdconfig.ByteValue  = (uint8_t)bootPartitionWP;
-    extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-    if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-    {
-        return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-
-    card->extendedCsd.bootPartitionWP = (uint8_t)bootPartitionWP;
-
-    return kStatus_Success;
-}
-
-status_t MMC_SetBootConfig(mmc_card_t *card, const mmc_boot_config_t *config)
-{
-    assert(card != NULL);
-    assert(config != NULL);
-
-    uint8_t bootParameter;
-    uint8_t bootBusWidth = (uint8_t)config->bootDataBusWidth;
-    mmc_extended_csd_config_t extendedCsdconfig;
-
-    if (card->extendedCsd.extendecCsdVersion <=
-        (uint32_t)kMMC_ExtendedCsdRevision13) /* V4.3 or above version card support boot mode */
-    {
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    /* Set the BOOT_CONFIG field of Extended CSD */
-    bootParameter = card->extendedCsd.partitionConfig;
-    bootParameter &=
-        ~((uint8_t)MMC_PARTITION_CONFIG_BOOT_ACK_MASK | (uint8_t)MMC_PARTITION_CONFIG_PARTITION_ENABLE_MASK);
-    bootParameter |= ((config->enableBootAck ? 1U : 0U) << MMC_PARTITION_CONFIG_BOOT_ACK_SHIFT);
-    bootParameter |= ((uint8_t)(config->bootPartition) << MMC_PARTITION_CONFIG_PARTITION_ENABLE_SHIFT);
-
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexPartitionConfig;
-    extendedCsdconfig.ByteValue  = bootParameter;
-    extendedCsdconfig.commandSet = kMMC_CommandSetStandard;
-    if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-    {
-        return kStatus_SDMMC_ConfigureExtendedCsdFailed;
-    }
-
-    card->extendedCsd.partitionConfig = bootParameter;
-
-    /* data bus remapping */
-    if (bootBusWidth == (uint8_t)kMMC_DataBusWidth1bit)
-    {
-        bootBusWidth = 0U;
-    }
-    else if ((bootBusWidth == (uint8_t)kMMC_DataBusWidth4bit) || (bootBusWidth == (uint8_t)kMMC_DataBusWidth4bitDDR))
-    {
-        bootBusWidth = 1U;
-    }
-    else
-    {
-        bootBusWidth = 2U;
-    }
-
-    /*Set BOOT_BUS_CONDITIONS in Extended CSD */
-    bootParameter = card->extendedCsd.bootDataBusConditions;
-    bootParameter &= (uint8_t) ~(MMC_BOOT_BUS_CONDITION_RESET_BUS_CONDITION_MASK |
-                                 MMC_BOOT_BUS_CONDITION_BUS_WIDTH_MASK | MMC_BOOT_BUS_CONDITION_BOOT_MODE_MASK);
-    bootParameter |=
-        (uint8_t)((config->retainBootbusCondition ? 1U : 0U) << MMC_BOOT_BUS_CONDITION_RESET_BUS_CONDITION_SHIFT);
-    bootParameter |= bootBusWidth << MMC_BOOT_BUS_CONDITION_BUS_WIDTH_SHIFT;
-    bootParameter |= ((uint8_t)(config->bootTimingMode) << MMC_BOOT_BUS_CONDITION_BOOT_MODE_SHIFT) &
-                     MMC_BOOT_BUS_CONDITION_BOOT_MODE_MASK;
-
-    extendedCsdconfig.accessMode = kMMC_ExtendedCsdAccessModeWriteBits;
-    extendedCsdconfig.ByteIndex  = (uint8_t)kMMC_ExtendedCsdIndexBootBusConditions;
-    extendedCsdconfig.ByteValue  = bootParameter;
-    if (kStatus_Success != MMC_SetExtendedCsdConfig(card, &extendedCsdconfig, 0U))
-    {
-        return kStatus_SDMMC_ConfigureBootFailed;
-    }
-
-    card->extendedCsd.bootDataBusConditions = bootParameter;
-    /* check and configure the boot config write protect */
-    bootParameter = (uint8_t)config->pwrBootConfigProtection | (((uint8_t)config->premBootConfigProtection) << 4U);
-    if (bootParameter != (card->extendedCsd.bootConfigProtect))
-    {
-        if (kStatus_Success != MMC_SetBootConfigWP(card, bootParameter))
-        {
-            return kStatus_SDMMC_ConfigureBootFailed;
-        }
-    }
-    /* check and configure the boot partition write protect */
-    if (card->extendedCsd.bootPartitionWP != (uint8_t)(config->bootPartitionWP))
-    {
-        if (kStatus_Success != MMC_SetBootPartitionWP(card, config->bootPartitionWP))
-        {
-            return kStatus_SDMMC_ConfigureBootFailed;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-status_t MMC_StartBoot(mmc_card_t *card,
-                       const mmc_boot_config_t *mmcConfig,
-                       uint8_t *buffer,
-                       sdmmchost_boot_config_t *hostConfig)
-{
-    assert(card != NULL);
-    assert(mmcConfig != NULL);
-    assert(buffer != NULL);
-
-    sdmmchost_cmd_t command = {0};
-    uint32_t tempClock      = 0U;
-
-    if (!card->isHostReady)
-    {
-        return kStatus_Fail;
-    }
-
-    /* send card active */
-    SDMMCHOST_SendCardActive(card->host);
-    /* enable MMC boot */
-    SDMMCHOST_EnableBoot(card->host, true);
-
-    if (mmcConfig->bootTimingMode == kMMC_BootModeSDRWithDefaultTiming)
-    {
-        /* Set clock to 400KHz. */
-        tempClock = SDMMC_CLOCK_400KHZ;
-    }
-    else
-    {
-        /* Set clock to 52MHZ. */
-        tempClock = MMC_CLOCK_52MHZ;
-    }
-    (void)SDMMCHOST_SetCardClock(card->host, tempClock);
-
-    if (((card->host->capability & (uint32_t)kSDMMCHOST_SupportDDRMode) != 0U) &&
-        (mmcConfig->bootTimingMode == kMMC_BootModeDDRTiming))
-    {
-        /* enable DDR mode */
-        SDMMCHOST_EnableDDRMode(card->host, true, 0U);
-    }
-
-    /* data bus remapping */
-    if (mmcConfig->bootDataBusWidth == kMMC_DataBusWidth1bit)
-    {
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith1Bit);
-    }
-    else if ((mmcConfig->bootDataBusWidth == kMMC_DataBusWidth4bit) ||
-             (mmcConfig->bootDataBusWidth == kMMC_DataBusWidth4bitDDR))
-    {
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith4Bit);
-    }
-    else
-    {
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith8Bit);
-    }
-
-    if (kMMC_BootModeAlternative == mmcConfig->bootMode)
-    {
-        /* alternative boot mode */
-        command.argument = 0xFFFFFFFAU;
-    }
-
-    command.index = (uint32_t)kSDMMC_GoIdleState;
-
-    /* should check tuning error during every transfer*/
-    if (kStatus_Success != SDMMCHOST_StartBoot(card->host, hostConfig, &command, buffer))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t MMC_ReadBootData(mmc_card_t *card, uint8_t *buffer, sdmmchost_boot_config_t *hostConfig)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-
-    /* should check tuning error during every transfer*/
-    if (kStatus_Success != SDMMCHOST_ReadBootData(card->host, hostConfig, buffer))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t MMC_StopBoot(mmc_card_t *card, uint32_t bootMode)
-{
-    assert(card != NULL);
-    /* Disable boot mode */
-    if ((uint32_t)kMMC_BootModeAlternative == bootMode)
-    {
-        /* Send CMD0 to reset the bus */
-        if (kStatus_Success != MMC_GoIdle(card))
-        {
-            return kStatus_SDMMC_GoIdleFailed;
-        }
-    }
-    /* disable MMC boot */
-    SDMMCHOST_EnableBoot(card->host, false);
-
-    return kStatus_Success;
-}

+ 0 - 445
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/mmc/fsl_mmc.h

@@ -1,445 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2021 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _FSL_MMC_H_
-#define _FSL_MMC_H_
-
-#include "fsl_sdmmc_common.h"
-
-/*!
- * @addtogroup mmccard MMC Card Driver
- * @ingroup card
- * @{
- */
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*! @brief Middleware mmc version. */
-#define FSL_MMC_DRIVER_VERSION (MAKE_VERSION(2U, 5U, 0U)) /*2.5.0*/
-
-/*! @brief MMC card flags
- * @anchor _mmc_card_flag
- */
-enum
-{
-    kMMC_SupportHighSpeed26MHZFlag            = (1U << 0U),  /*!< Support high speed 26MHZ */
-    kMMC_SupportHighSpeed52MHZFlag            = (1U << 1U),  /*!< Support high speed 52MHZ */
-    kMMC_SupportHighSpeedDDR52MHZ180V300VFlag = (1 << 2U),   /*!< ddr 52MHZ 1.8V or 3.0V */
-    kMMC_SupportHighSpeedDDR52MHZ120VFlag     = (1 << 3U),   /*!< DDR 52MHZ 1.2V */
-    kMMC_SupportHS200200MHZ180VFlag           = (1 << 4U),   /*!< HS200 ,200MHZ,1.8V */
-    kMMC_SupportHS200200MHZ120VFlag           = (1 << 5U),   /*!< HS200, 200MHZ, 1.2V */
-    kMMC_SupportHS400DDR200MHZ180VFlag        = (1 << 6U),   /*!< HS400, DDR, 200MHZ,1.8V */
-    kMMC_SupportHS400DDR200MHZ120VFlag        = (1 << 7U),   /*!< HS400, DDR, 200MHZ,1.2V */
-    kMMC_SupportHighCapacityFlag              = (1U << 8U),  /*!< Support high capacity */
-    kMMC_SupportAlternateBootFlag             = (1U << 9U),  /*!< Support alternate boot */
-    kMMC_SupportDDRBootFlag                   = (1U << 10U), /*!< support DDR boot flag*/
-    kMMC_SupportHighSpeedBootFlag             = (1U << 11U), /*!< support high speed boot flag */
-    kMMC_SupportEnhanceHS400StrobeFlag        = (1U << 12U), /*!< support enhance HS400 strobe */
-};
-
-/*! @brief mmccard sleep/awake state */
-typedef enum _mmc_sleep_awake
-{
-    kMMC_Sleep = 1U, /*!< MMC card sleep */
-    kMMC_Awake = 0U, /*!< MMC card awake */
-} mmc_sleep_awake_t;
-
-/*! @brief card io strength control */
-typedef void (*mmc_io_strength_t)(uint32_t busFreq);
-
-/*! @brief card user parameter */
-typedef struct _mmc_usr_param
-{
-    mmc_io_strength_t ioStrength; /*!< switch sd io strength */
-    uint32_t maxFreq;             /*!< board support maximum frequency */
-    uint32_t capability;          /*!< board capability flag */
-} mmc_usr_param_t;
-
-/*!
- * @brief mmc card state
- *
- * Defines the card structure including the necessary fields to identify and describe the card.
- */
-typedef struct _mmc_card
-{
-    sdmmchost_t *host;        /*!< Host information */
-    mmc_usr_param_t usrParam; /*!< user parameter */
-
-    bool isHostReady;         /*!< Use this flag to indicate if host re-init needed or not*/
-    bool noInteralAlign;      /*!< Use this flag to disable sdmmc align. If disabled, sdmmc will not make sure the
-                    data buffer address is word align, otherwise all the transfer are aligned to low level driver. */
-    uint32_t busClock_Hz;     /*!< MMC bus clock united in Hz */
-    uint32_t relativeAddress; /*!< Relative address of the card */
-    bool enablePreDefinedBlockCount; /*!< Enable PRE-DEFINED block count when read/write */
-    uint32_t flags;                  /*!< Capability flag in @ref _mmc_card_flag */
-
-    uint8_t internalBuffer[FSL_SDMMC_CARD_INTERNAL_BUFFER_SIZE]; /*!< raw buffer used for mmc driver internal  */
-    uint32_t ocr;                                                /*!< Raw OCR content */
-    mmc_cid_t cid;                                               /*!< CID */
-    mmc_csd_t csd;                                               /*!< CSD */
-    mmc_extended_csd_t extendedCsd;                              /*!< Extended CSD */
-    uint32_t blockSize;                                          /*!< Card block size */
-    uint32_t userPartitionBlocks;                                /*!< Card total block number in user partition */
-    uint32_t bootPartitionBlocks;                                /*!< Boot partition size united as block size */
-    uint32_t eraseGroupBlocks;                                   /*!< Erase group size united as block size */
-    mmc_access_partition_t currentPartition;                     /*!< Current access partition */
-    mmc_voltage_window_t hostVoltageWindowVCCQ; /*!< application must set this value according to board specific */
-    mmc_voltage_window_t hostVoltageWindowVCC;  /*!< application must set this value according to board specific */
-    mmc_high_speed_timing_t busTiming;          /*!< indicates the current work timing mode*/
-    mmc_data_bus_width_t busWidth;              /*!< indicates the current work bus width */
-    sdmmc_osa_mutex_t lock;                     /*!< card access lock */
-} mmc_card_t;
-
-/*************************************************************************************************
- * API
- ************************************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/*!
- * @name MMCCARD Function
- * @{
- */
-
-/*!
- * @brief Initializes the MMC card and host.
- *
- * @param card Card descriptor.
- *
- * Thread safe function, please note that the function will create the mutex lock dynamically by default,
- * so to avoid the mutex to be created redundantly, application must follow bellow sequence for card re-initialization:
- * @code
-   MMC_Deinit(card);
-   MMC_Init(card);
- * @endcode
- *
- * @retval #kStatus_SDMMC_HostNotReady Host is not ready.
- * @retval #kStatus_SDMMC_GoIdleFailed Going idle failed.
- * @retval #kStatus_SDMMC_HandShakeOperationConditionFailed Sending operation condition failed.
- * @retval #kStatus_SDMMC_AllSendCidFailed Sending CID failed.
- * @retval #kStatus_SDMMC_SetRelativeAddressFailed Setging relative address failed.
- * @retval #kStatus_SDMMC_SendCsdFailed Sending CSD failed.
- * @retval #kStatus_SDMMC_CardNotSupport Card not support.
- * @retval #kStatus_SDMMC_SelectCardFailed Sending SELECT_CARD command failed.
- * @retval #kStatus_SDMMC_SendExtendedCsdFailed Sending EXT_CSD failed.
- * @retval #kStatus_SDMMC_SetDataBusWidthFailed Setting bus width failed.
- * @retval #kStatus_SDMMC_SwitchBusTimingFailed Switching high speed failed.
- * @retval #kStatus_SDMMC_SetCardBlockSizeFailed Setting card block size failed.
- * @retval #kStatus_SDMMC_SetPowerClassFail Setting card power class failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_Init(mmc_card_t *card);
-
-/*!
- * @brief Deinitializes the card and host.
- *
- * @note It is a thread safe function.
- *
- * @param card Card descriptor.
- */
-void MMC_Deinit(mmc_card_t *card);
-
-/*!
- * @brief Initializes the card.
- *
- * Thread safe function, please note that the function will create the mutex lock dynamically by default,
- * so to avoid the mutex to be created redundantly, application must follow bellow sequence for card re-initialization:
- * @code
-   MMC_CardDeinit(card);
-   MMC_CardInit(card);
- * @endcode
- *
- * @param card Card descriptor.
- *
- * @retval #kStatus_SDMMC_HostNotReady Host is not ready.
- * @retval #kStatus_SDMMC_GoIdleFailed Going idle failed.
- * @retval #kStatus_SDMMC_HandShakeOperationConditionFailed Sending operation condition failed.
- * @retval #kStatus_SDMMC_AllSendCidFailed Sending CID failed.
- * @retval #kStatus_SDMMC_SetRelativeAddressFailed Setting relative address failed.
- * @retval #kStatus_SDMMC_SendCsdFailed Sending CSD failed.
- * @retval #kStatus_SDMMC_CardNotSupport Card not support.
- * @retval #kStatus_SDMMC_SelectCardFailed Sending SELECT_CARD command failed.
- * @retval #kStatus_SDMMC_SendExtendedCsdFailed Sending EXT_CSD failed.
- * @retval #kStatus_SDMMC_SetDataBusWidthFailed Setting bus width failed.
- * @retval #kStatus_SDMMC_SwitchBusTimingFailed Switching high speed failed.
- * @retval #kStatus_SDMMC_SetCardBlockSizeFailed Setting card block size failed.
- * @retval #kStatus_SDMMC_SetPowerClassFail Setting card power class failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_CardInit(mmc_card_t *card);
-
-/*!
- * @brief Deinitializes the card.
- *
- * @note It is a thread safe function.
- *
- * @param card Card descriptor.
- */
-void MMC_CardDeinit(mmc_card_t *card);
-
-/*!
- * @brief initialize the host.
- *
- * This function deinitializes the specific host.
- *
- * @param card Card descriptor.
- */
-status_t MMC_HostInit(mmc_card_t *card);
-
-/*!
- * @brief Deinitializes the host.
- *
- * This function deinitializes the host.
- *
- * @param card Card descriptor.
- */
-void MMC_HostDeinit(mmc_card_t *card);
-
-/*!
- * @brief Resets the host.
- *
- * This function resets the specific host.
- *
- * @param card Card descriptor.
- */
-void MMC_HostDoReset(mmc_card_t *card);
-
-/*!
- * @brief Resets the host.
- *
- * @deprecated Do not use this function.  It has been superceded by @ref MMC_HostDoReset.
- * This function resets the specific host.
- *
- * @param host Host descriptor.
- */
-void MMC_HostReset(SDMMCHOST_CONFIG *host);
-
-/*!
- * @brief Sets card power.
- *
- * @param card Card descriptor.
- * @param enable True is powering on, false is powering off.
- */
-void MMC_SetCardPower(mmc_card_t *card, bool enable);
-
-/*!
- * @brief Checks if the card is read-only.
- *
- * @param card Card descriptor.
- * @retval true Card is read only.
- * @retval false Card isn't read only.
- */
-bool MMC_CheckReadOnly(mmc_card_t *card);
-
-/*!
- * @brief Reads data blocks from the card.
- *
- * @note It is a thread safe function.
- *
- * @param card Card descriptor.
- * @param buffer The buffer to save data.
- * @param startBlock The start block index.
- * @param blockCount The number of blocks to read.
- * @retval #kStatus_InvalidArgument Invalid argument.
- * @retval #kStatus_SDMMC_CardNotSupport Card not support.
- * @retval #kStatus_SDMMC_SetBlockCountFailed Setting block count failed.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_SDMMC_StopTransmissionFailed Stopping transmission failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_ReadBlocks(mmc_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockCount);
-
-/*!
- * @brief Writes data blocks to the card.
- *
- * @note
- * 1. It is a thread safe function.
- * 2. It is an async write function which means that the card status may still be busy after the function returns.
- * Application can call function MMC_PollingCardStatusBusy to wait for the card status to be idle after the write
- * operation.
- *
- * @param card Card descriptor.
- * @param buffer The buffer to save data blocks.
- * @param startBlock Start block number to write.
- * @param blockCount Block count.
- * @retval #kStatus_InvalidArgument Invalid argument.
- * @retval #kStatus_SDMMC_NotSupportYet Not support now.
- * @retval #kStatus_SDMMC_SetBlockCountFailed Setting block count failed.
- * @retval #kStatus_SDMMC_WaitWriteCompleteFailed Sending status failed.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_SDMMC_StopTransmissionFailed Stop transmission failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_WriteBlocks(mmc_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockCount);
-
-/*!
- * @brief Erases groups of the card.
- *
- * The erase command is best used to erase the entire device or a partition.
- * Erase group is the smallest erase unit in MMC card. The erase range is [startGroup, endGroup].
- *
- * @note
- * 1. It is a thread safe function.
- * 2. This function always polls card busy status according to the timeout value defined in the card register after
- * all the erase command sent out.
- *
- * @param  card Card descriptor.
- * @param  startGroup Start group number.
- * @param  endGroup End group number.
- * @retval #kStatus_InvalidArgument Invalid argument.
- * @retval #kStatus_SDMMC_WaitWriteCompleteFailed Send status failed.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_EraseGroups(mmc_card_t *card, uint32_t startGroup, uint32_t endGroup);
-
-/*!
- * @brief Selects the partition to access.
- *
- * @note It is a thread safe function.
- *
- * @param card Card descriptor.
- * @param partitionNumber The partition number.
- * @retval #kStatus_SDMMC_ConfigureExtendedCsdFailed Configuring EXT_CSD failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_SelectPartition(mmc_card_t *card, mmc_access_partition_t partitionNumber);
-
-/*!
- * @brief Configures the boot activity of the card.
- *
- * @param card Card descriptor.
- * @param config Boot configuration structure.
- * @retval #kStatus_SDMMC_NotSupportYet Not support now.
- * @retval #kStatus_SDMMC_ConfigureExtendedCsdFailed Configuring EXT_CSD failed.
- * @retval #kStatus_SDMMC_ConfigureBootFailed Configuring boot failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_SetBootConfig(mmc_card_t *card, const mmc_boot_config_t *config);
-
-/*!
- * @brief MMC card start boot.
- *
- * @param card Card descriptor.
- * @param mmcConfig The mmc Boot configuration structure.
- * @param buffer Address to receive data.
- * @param hostConfig Host boot configurations.
- * @retval #kStatus_Fail Failed.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_SDMMC_GoIdleFailed Resetting card failed.
- * @retval #kStatus_Success Operation succeeded.
- */
-status_t MMC_StartBoot(mmc_card_t *card,
-                       const mmc_boot_config_t *mmcConfig,
-                       uint8_t *buffer,
-                       sdmmchost_boot_config_t *hostConfig);
-
-/*!
- * @brief MMC card set boot configuration write protect.
- *
- * @param card Card descriptor.
- * @param wp Write protect value.
- */
-status_t MMC_SetBootConfigWP(mmc_card_t *card, uint8_t wp);
-
-/*!
- * @brief MMC card continuous read boot data.
- *
- * @param card Card descriptor.
- * @param buffer Buffer address.
- * @param hostConfig Host boot configurations.
- */
-status_t MMC_ReadBootData(mmc_card_t *card, uint8_t *buffer, sdmmchost_boot_config_t *hostConfig);
-
-/*!
- * @brief MMC card stop boot mode.
- *
- * @param card Card descriptor.
- * @param bootMode Boot mode.
- */
-status_t MMC_StopBoot(mmc_card_t *card, uint32_t bootMode);
-
-/*!
- * @brief MMC card set boot partition write protect.
- *
- * @param card Card descriptor.
- * @param bootPartitionWP Boot partition write protect value.
- */
-status_t MMC_SetBootPartitionWP(mmc_card_t *card, mmc_boot_partition_wp_t bootPartitionWP);
-
-/*!
- * @brief MMC card cache control function.
- *
- * The mmc device's cache is enabled by the driver by default.
- * The cache should in typical case reduce the access time (compared to an access to the main nonvolatile storage) for
- * both write and read.
- *
- * @param card Card descriptor.
- * @param enable True is enabling the cache, false is disabling the cache.
- */
-status_t MMC_EnableCacheControl(mmc_card_t *card, bool enable);
-
-/*!
- * @brief MMC card cache flush function.
- *
- * A Flush operation refers to the requirement, from the host to the device, to write the cached data to the nonvolatile
- * memory. Prior to a flush, the device may autonomously write data to the nonvolatile memory, but after the flush
- * operation all data in the volatile area must be written to nonvolatile memory. There is no requirement for flush due
- * to switching between the partitions. (Note: This also implies that the cache data shall not be lost when switching
- * between partitions). Cached data may be lost in SLEEP state, so host should flush the cache before placing the device
- * into SLEEP state.
- *
- * @param card Card descriptor.
- */
-status_t MMC_FlushCache(mmc_card_t *card);
-
-/*!
- * @brief MMC sets card sleep awake state.
- *
- * The Sleep/Awake command is used to initiate the state transition between Standby state and Sleep state.
- * The memory device indicates the transition phase busy by pulling down the DAT0 line.
- * The Sleep/Standby state is reached when the memory device stops pulling down the DAT0 line, then the function
- * returns.
- *
- * @param card Card descriptor.
- * @param state The sleep/awake command argument, refer to @ref mmc_sleep_awake_t.
- *
- * @retval kStatus_SDMMC_NotSupportYet Indicates the memory device doesn't support the Sleep/Awake command.
- * @retval kStatus_SDMMC_TransferFailed Indicates command transferred fail.
- * @retval kStatus_SDMMC_PollingCardIdleFailed Indicates polling DAT0 busy timeout.
- * @retval kStatus_SDMMC_DeselectCardFailed Indicates deselect card command failed.
- * @retval kStatus_SDMMC_SelectCardFailed Indicates select card command failed.
- * @retval kStatus_Success Indicates the card state switched successfully.
- */
-status_t MMC_SetSleepAwake(mmc_card_t *card, mmc_sleep_awake_t state);
-
-/*!
- * @brief Polling card idle status.
- *
- * This function can be used to poll the status from busy to idle, the function will return with the card
- * status being idle or timeout or command failed.
- *
- * @param card Card descriptor.
- * @param checkStatus True is send CMD and read DAT0 status to check card status, false is read DAT0 status only.
- * @param timeoutMs Polling card status timeout value.
- *
- * @retval kStatus_SDMMC_CardStatusIdle Card is idle.
- * @retval kStatus_SDMMC_CardStatusBusy Card is busy.
- * @retval kStatus_SDMMC_TransferFailed Command tranfer failed.
- * @retval kStatus_SDMMC_SwitchFailed Status command reports switch error.
- */
-status_t MMC_PollingCardStatusBusy(mmc_card_t *card, bool checkStatus, uint32_t timeoutMs);
-
-/* @} */
-#if defined(__cplusplus)
-}
-#endif
-/*! @} */
-#endif /* _FSL_MMC_H_*/

+ 0 - 275
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/osa/fsl_sdmmc_osa.c

@@ -1,275 +0,0 @@
-/*
- * Copyright 2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "fsl_sdmmc_osa.h"
-
-/*******************************************************************************
- * Definitons
- ******************************************************************************/
-
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-/*!
- * brief Initialize OSA.
- */
-void SDMMC_OSAInit(void)
-{
-    /* Intentional empty */
-}
-
-/*!
- * brief OSA Create event.
- * param event handle.
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventCreate(void *eventHandle)
-{
-    assert(eventHandle != NULL);
-
-#if defined(SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE) && SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-    (void)OSA_SemaphoreCreate(&(((sdmmc_osa_event_t *)eventHandle)->handle), 0U);
-#else
-    (void)OSA_EventCreate(&(((sdmmc_osa_event_t *)eventHandle)->handle), true);
-#endif
-
-    return kStatus_Success;
-}
-
-/*!
- * brief Wait event.
- *
- * param eventHandle The event type
- * param eventType Timeout time in milliseconds.
- * param timeoutMilliseconds timeout value in ms.
- * param event event flags.
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventWait(void *eventHandle, uint32_t eventType, uint32_t timeoutMilliseconds, uint32_t *event)
-{
-    assert(eventHandle != NULL);
-
-    osa_status_t status = KOSA_StatusError;
-
-#if defined(SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE) && SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-    while (true)
-    {
-        status = OSA_SemaphoreWait(&(((sdmmc_osa_event_t *)eventHandle)->handle), timeoutMilliseconds);
-        if (KOSA_StatusTimeout == status)
-        {
-            break;
-        }
-
-        if (KOSA_StatusSuccess == status)
-        {
-            (void)SDMMC_OSAEventGet(eventHandle, eventType, event);
-            if ((*event & eventType) != 0U)
-            {
-                return kStatus_Success;
-            }
-        }
-    }
-
-#else
-    while (true)
-    {
-        status = OSA_EventWait(&(((sdmmc_osa_event_t *)eventHandle)->handle), eventType, 0, timeoutMilliseconds, event);
-        if ((KOSA_StatusSuccess == status) || (KOSA_StatusTimeout == status))
-        {
-            break;
-        }
-    }
-
-    if (KOSA_StatusSuccess == status)
-    {
-        return kStatus_Success;
-    }
-#endif
-
-    return kStatus_Fail;
-}
-
-/*!
- * brief set event.
- * param event event handle.
- * param eventType The event type
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventSet(void *eventHandle, uint32_t eventType)
-{
-    assert(eventHandle != NULL);
-
-#if defined(SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE) && SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-    OSA_SR_ALLOC();
-    OSA_ENTER_CRITICAL();
-    ((sdmmc_osa_event_t *)eventHandle)->eventFlag |= eventType;
-    OSA_EXIT_CRITICAL();
-
-    (void)OSA_SemaphorePost(&(((sdmmc_osa_event_t *)eventHandle)->handle));
-#else
-    (void)OSA_EventSet(&(((sdmmc_osa_event_t *)eventHandle)->handle), eventType);
-#endif
-
-    return kStatus_Success;
-}
-
-/*!
- * brief Get event flag.
- * param eventHandle event handle.
- * param eventType The event type
- * param flag pointer to store event value.
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventGet(void *eventHandle, uint32_t eventType, uint32_t *flag)
-{
-    assert(eventHandle != NULL);
-    assert(flag != NULL);
-
-#if defined(SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE) && SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-    *flag = ((sdmmc_osa_event_t *)eventHandle)->eventFlag;
-#else
-    (void)OSA_EventGet(&(((sdmmc_osa_event_t *)eventHandle)->handle), eventType, flag);
-#endif
-
-    return kStatus_Success;
-}
-
-/*!
- * brief clear event flag.
- * param eventHandle event handle.
- * param eventType The event type
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventClear(void *eventHandle, uint32_t eventType)
-{
-    assert(eventHandle != NULL);
-
-#if defined(SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE) && SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-    OSA_SR_ALLOC();
-    OSA_ENTER_CRITICAL();
-    ((sdmmc_osa_event_t *)eventHandle)->eventFlag &= ~eventType;
-    OSA_EXIT_CRITICAL();
-#else
-    (void)OSA_EventClear(&(((sdmmc_osa_event_t *)eventHandle)->handle), eventType);
-#endif
-
-    return kStatus_Success;
-}
-
-/*!
- * brief Delete event.
- * param event The event handle.
- */
-status_t SDMMC_OSAEventDestroy(void *eventHandle)
-{
-    assert(eventHandle != NULL);
-
-#if defined(SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE) && SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-    (void)OSA_SemaphoreDestroy(&(((sdmmc_osa_event_t *)eventHandle)->handle));
-#else
-    (void)OSA_EventDestroy(&(((sdmmc_osa_event_t *)eventHandle)->handle));
-#endif
-
-    return kStatus_Success;
-}
-
-/*!
- * brief Create a mutex.
- * param mutexHandle mutex handle.
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAMutexCreate(void *mutexHandle)
-{
-    assert(mutexHandle != NULL);
-
-    (void)OSA_MutexCreate(&((sdmmc_osa_mutex_t *)mutexHandle)->handle);
-
-    return kStatus_Success;
-}
-
-/*!
- * brief set event.
- * param mutexHandle mutex handle.
- * param millisec The maximum number of milliseconds to wait for the mutex.
- *                 If the mutex is locked, Pass the value osaWaitForever_c will
- *                 wait indefinitely, pass 0 will return KOSA_StatusTimeout
- *                 immediately.
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAMutexLock(void *mutexHandle, uint32_t millisec)
-{
-    assert(mutexHandle != NULL);
-
-    (void)OSA_MutexLock(&((sdmmc_osa_mutex_t *)mutexHandle)->handle, millisec);
-
-    return kStatus_Success;
-}
-
-/*!
- * brief Get event flag.
- * param mutexHandle mutex handle.
- * retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAMutexUnlock(void *mutexHandle)
-{
-    assert(mutexHandle != NULL);
-
-    (void)OSA_MutexUnlock(&((sdmmc_osa_mutex_t *)mutexHandle)->handle);
-
-    return kStatus_Success;
-}
-
-/*!
- * brief Delete mutex.
- * param mutexHandle The mutex handle.
- */
-status_t SDMMC_OSAMutexDestroy(void *mutexHandle)
-{
-    assert(mutexHandle != NULL);
-
-    (void)OSA_MutexDestroy(&((sdmmc_osa_mutex_t *)mutexHandle)->handle);
-
-    return kStatus_Success;
-}
-
-/*!
- * brief sdmmc delay.
- * param milliseconds time to delay
- */
-void SDMMC_OSADelay(uint32_t milliseconds)
-{
-#if (defined FSL_OSA_BM_TIMER_CONFIG) && (FSL_OSA_BM_TIMER_CONFIG == FSL_OSA_BM_TIMER_NONE)
-    SDK_DelayAtLeastUs(milliseconds * 1000U, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
-#else
-    OSA_TimeDelay(milliseconds);
-#endif
-}
-
-/*!
- * brief sdmmc delay us.
- * param microseconds time to delay
- * return actual delayed microseconds
- */
-uint32_t SDMMC_OSADelayUs(uint32_t microseconds)
-{
-#if (defined FSL_OSA_BM_TIMER_CONFIG) && (FSL_OSA_BM_TIMER_CONFIG == FSL_OSA_BM_TIMER_NONE)
-    SDK_DelayAtLeastUs(microseconds, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
-    return microseconds;
-#else
-    uint32_t milliseconds = microseconds / 1000U + ((microseconds % 1000U) == 0U ? 0U : 1U);
-    OSA_TimeDelay(milliseconds);
-    return milliseconds * 1000U;
-#endif
-}

+ 0 - 170
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/osa/fsl_sdmmc_osa.h

@@ -1,170 +0,0 @@
-/*
- * Copyright 2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _FSL_SDMMC_OSA_H_
-#define _FSL_SDMMC_OSA_H_
-
-#include "fsl_common.h"
-#include "fsl_os_abstraction.h"
-
-/*!
- * @addtogroup sdmmc_osa SDMMC OSA
- * @ingroup card
- * @{
- */
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*!@brief transfer event */
-#define SDMMC_OSA_EVENT_TRANSFER_CMD_SUCCESS  (1UL << 0U)
-#define SDMMC_OSA_EVENT_TRANSFER_CMD_FAIL     (1UL << 1U)
-#define SDMMC_OSA_EVENT_TRANSFER_DATA_SUCCESS (1UL << 2U)
-#define SDMMC_OSA_EVENT_TRANSFER_DATA_FAIL    (1UL << 3U)
-#define SDMMC_OSA_EVENT_TRANSFER_DMA_COMPLETE (1UL << 4U)
-
-/*!@brief card detect event, start from index 8 */
-#define SDMMC_OSA_EVENT_CARD_INSERTED (1UL << 8U)
-#define SDMMC_OSA_EVENT_CARD_REMOVED  (1UL << 9U)
-
-/*!@brief enable semphore by default */
-#ifndef SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-#define SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE 1
-#endif
-
-/*!@brief sdmmc osa event */
-typedef struct _sdmmc_osa_event
-{
-#if defined(SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE) && SDMMC_OSA_POLLING_EVENT_BY_SEMPHORE
-    volatile uint32_t eventFlag;
-    OSA_SEMAPHORE_HANDLE_DEFINE(handle);
-#else
-    OSA_EVENT_HANDLE_DEFINE(handle);
-#endif
-} sdmmc_osa_event_t;
-
-/*!@brief sdmmc osa mutex */
-typedef struct _sdmmc_osa_mutex
-{
-    OSA_MUTEX_HANDLE_DEFINE(handle);
-} sdmmc_osa_mutex_t;
-/*******************************************************************************
- * API
- ******************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/*!
- * @name sdmmc osa Function
- * @{
- */
-
-/*!
- * @brief Initialize OSA.
- */
-void SDMMC_OSAInit(void);
-
-/*!
- * @brief OSA Create event.
- * @param eventHandle event handle.
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventCreate(void *eventHandle);
-
-/*!
- * @brief Wait event.
- *
- * @param eventHandle The event type
- * @param eventType Timeout time in milliseconds.
- * @param timeoutMilliseconds timeout value in ms.
- * @param event event flags.
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventWait(void *eventHandle, uint32_t eventType, uint32_t timeoutMilliseconds, uint32_t *event);
-
-/*!
- * @brief set event.
- * @param eventHandle event handle.
- * @param eventType The event type
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventSet(void *eventHandle, uint32_t eventType);
-
-/*!
- * @brief Get event flag.
- * @param eventHandle event handle.
- * @param eventType event type.
- * @param flag pointer to store event value.
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventGet(void *eventHandle, uint32_t eventType, uint32_t *flag);
-
-/*!
- * @brief clear event flag.
- * @param eventHandle event handle.
- * @param eventType The event type
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAEventClear(void *eventHandle, uint32_t eventType);
-
-/*!
- * @brief Delete event.
- * @param eventHandle The event handle.
- */
-status_t SDMMC_OSAEventDestroy(void *eventHandle);
-
-/*!
- * @brief Create a mutex.
- * @param mutexHandle mutex handle.
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAMutexCreate(void *mutexHandle);
-
-/*!
- * @brief set event.
- * @param mutexHandle mutex handle.
- * @param millisec The maximum number of milliseconds to wait for the mutex.
- *                 If the mutex is locked, Pass the value osaWaitForever_c will
- *                 wait indefinitely, pass 0 will return KOSA_StatusTimeout
- *                 immediately.
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAMutexLock(void *mutexHandle, uint32_t millisec);
-
-/*!
- * @brief Get event flag.
- * @param mutexHandle mutex handle.
- * @retval kStatus_Fail or kStatus_Success.
- */
-status_t SDMMC_OSAMutexUnlock(void *mutexHandle);
-
-/*!
- * @brief Delete mutex.
- * @param mutexHandle The mutex handle.
- */
-status_t SDMMC_OSAMutexDestroy(void *mutexHandle);
-
-/*!
- * @brief sdmmc delay.
- * @param milliseconds time to delay
- */
-void SDMMC_OSADelay(uint32_t milliseconds);
-
-/*!
- * @brief sdmmc delay us.
- * @param microseconds time to delay
- * @return actual delayed microseconds
- */
-uint32_t SDMMC_OSADelayUs(uint32_t microseconds);
-
-/* @} */
-
-#if defined(__cplusplus)
-}
-#endif
-/* @} */
-#endif /* _FSL_SDMMC_OSA_H_*/

+ 0 - 123
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sd/ChangeLogKSDK.txt

@@ -1,123 +0,0 @@
-/*!
-@page middleware_log Middleware Change Log
-
-@section sd SD Card driver for MCUXpresso SDK
-  The current driver version is 2.4.0.
-
-  - 2.4.0
-    - Improvements
-      - Removed deprecated api in sd driver.
-      - Added new api SD_PollingCardStatusBusy for application polling card status.
-      - Improved the read/write/erase function flow.
-      - Improved the signal line voltage switch flow.
-      - Added powerOnDelayMS/powerOffDelayMS in sd_usr_param_t to allow redefine the default power on/off delay.
-      - Added mutual exclusive access for init/deinit/read/write/erase function.
-      - Fixed the driver strength configurations missed when timing mode switch to non SDR50/SDR104 mode.
-      - Fixed violations of MISRA C-2012 rule 4.7, 17.7, 10.7, 10.4, 13.5, 14.4.
-
-  - 2.3.3
-    - Improvements
-      - Added host SDR timing mode capability validation during card initialization.
-      - Added plling card ready for data status when transfer data failed.
-      - Used cache line size align buffer for SD initialization api.
-    - Bug Fixes
-      - Fixed violations of MISRA C-2012 rule 11.9, 15.7, 4.7, 16.4, 10.1, 10.3, 10.4, 11.3, 14.4, 10.6, 17.7, 16.1, 16.3.
-
-  - 2.3.2
-    - Improvements
-      - Moved power off function after card detect in SD_Init for DAT3 detect card feature.
-
-  - 2.3.1
-    - Improvements
-      - Removed the dead loop while polling DAT0 and CMD13 instead of using timeout mechanism.
-
-  - 2.3.0
-    - Improvements
-      - Marked api SD_HostReset/SD_PowerOnCard/SD_PowerOffCard/SD_WaitCardDetectStatus as deprecated.
-      - Added new api SD_SetCardPower/SD_PollingCardDetectStatus/SD_HostDoReset.
-      - Added internalBuffer in sd_card_t and removed rawCid/rawCsd/rawScr.
-      - Added retuning support during data transfer under SDR50/SDR104 mode.
-      - Increased the read/write blocks failed retry times for stability.
-      - Added delay while retry the ACMD41 for stability.
-
-  - 2.2.12
-    - Improvements
-      - Increased the sd io driver strength for SD2.0 card.
-    - Bug Fixes
-      - Fixed the build warning by changing the old style function declaration static
-        status_t inline to static inline status_t(found by adding
-        -Wold-style-declaration in armgcc build flag).
-
-  - 2.2.10
-    - Bug Fixes
-      - Added event value check for all the FreeRTOS events to fix program hangs
-        when a card event occurs before create.
-
-  - 2.2.7
-    - Bug Fixes
-      - Fixed MDK 66-D warning.
-
-  - 2.2.5
-    - Improvements
-      - Added SD_ReadStatus api to get 512bit SD status.
-      - Added error log support in sdcard functions.
-      - Added SDMMC_ENABLE_SOFTWARE_TUNING to enable/disable software tuning and it is disabled by default.
-
-  - 2.2.4
-    - Bug Fixes
-      - Fixed DDR mode data sequence miss issue, which is caused by NIBBLE_POS.
-    - Improvements
-      - Increased g_sdmmc 512byte to improve the performance when application use a non-word align data buffer address.
-      - Enabled auto cmd12 for SD read/write.
-
-  - 2.2.3
-    - Bug Fixes
-      - Added response check for send operation condition command. If not checked, the card may occasionally init fail.
-
-  - 2.2.1
-    - Improvements
-      - Kept SD_Init function for forward compatibility.
-
-  - 2.2.0
-    - Improvements
-      - Separated the SD/MMC/SDIO init API to xxx_CardInit/xxx_HostInit.
-      - SD_Init/SDIO_Init will be deprecated in the next version.
-
-  - 2.1.6
-    - Improvements
-      - Enhanced SD IO default driver strength.
-
-  - 2.1.5
-  	- Bug Fixes
-      - Fixed Coverity issue.
-      - Fixed SD v1.x card write fail issue. It was caused by the block length set error.
-      - Fixed card cannot detect dynamically.
-
-  - 2.1.3
-    - Bug Fixes
-      - Fixed Non high-speed sdcard init fail at switch to high speed.
-    - Improvements
-      - Added Delay for SDCard power up.
-
-  - 2.1.2
-    - Improvements
-      - Improved SDMMC to support SD v3.0.
-
-  - 2.1.1
-    - Bug Fixes
-      - Fixed the bit mask error in the SD card switch to high speed function.
-    - Improvements
-      - Optimized the SD card initialization function.
-
-  - 2.1.0
-    - Bug Fixes
-      - Changed the callback mechanism when sending a command.
-      - Fixed the performance low issue when transferring data.
-    - Improvements
-      - Changed the name of some error codes returned by internal function.
-      - Merged all host related attributes to one structure.
-
-  - 2.0.0
-    - Initial version.
-
-*/

+ 0 - 2290
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sd/fsl_sd.c

@@ -1,2290 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2019 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-#include "fsl_sd.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*!@brief power reset delay */
-#define SD_POWER_ON_DELAY  (400U)
-#define SD_POWER_OFF_DELAY (100U)
-/*! @brief card access idle timeout value */
-#ifndef SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT
-#define SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT (600U) /* more then 500ms timeout value */
-#endif
-/*! @brief card cmd13 retry times */
-#ifndef SD_CMD13_RETRY_TIMES
-#define SD_CMD13_RETRY_TIMES (10)
-#endif
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-/*!
- * @brief Wait write process complete.
- *
- * @param card Card descriptor.
- * @retval kStatus_Timeout Send command timeout.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SendCardStatus(sd_card_t *card);
-
-/*!
- * @brief send write success blocks.
- *
- * @param card Card descriptor.
- * @param blocks blocks number wirte successed
- * @retval kStatus_SDMMC_TransferFailed Send command failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SendWriteSuccessBlocks(sd_card_t *card, uint32_t *blocks);
-
-/*!
- * @brief Send SEND_APPLICATION_COMMAND command.
- *
- * @param card Card descriptor.
- * @param relativeaddress
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support.
- * @retval kStatus_Success Operate successfully.
- */
-static inline status_t SD_SendApplicationCmd(sd_card_t *card, uint32_t relativeAddress);
-
-/*!
- * @brief Send GO_IDLE command to set the card to be idle state.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static inline status_t SD_GoIdle(sd_card_t *card);
-
-/*!
- * @brief Send STOP_TRANSMISSION command after multiple blocks read/write.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_StopTransmission(sd_card_t *card);
-
-/*!
- * @brief Send SET_BLOCK_SIZE command.
- *
- * @param card Card descriptor.
- * @param blockSize Block size.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static inline status_t SD_SetBlockSize(sd_card_t *card, uint32_t blockSize);
-
-/*!
- * @brief Send GET_RCA command to get card relative address.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SendRca(sd_card_t *card);
-
-/*!
- * @brief Send SWITCH_FUNCTION command to switch the card function group.
- *
- * @param card Card descriptor.
- * @param mode 0 to check function group. 1 to switch function group
- * @param group Function group
- * @param number Function number in the function group.
- * @param status Switch function status.
- * @retval kStatus_SDMMC_SetCardBlockSizeFailed Set card block size failed.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SwitchFunction(sd_card_t *card, uint32_t mode, uint32_t group, uint32_t number, uint32_t *status);
-
-/*!
- * @brief Decode raw SCR register content in the data blocks.
- *
- * @param card Card descriptor.
- * @param rawScr Raw SCR register content.
- */
-static void SD_DecodeScr(sd_card_t *card, uint32_t *rawScr);
-
-/*!
- * @brief Send GET_SCR command.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_SendApplicationCommandFailed Send application command failed.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_NotSupportYet Not support yet.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SendScr(sd_card_t *card);
-
-/*!
- * @brief Switch the card to be high speed mode.
- *
- * @param card Card descriptor.
- * @param group Group number.
- * @param functio Function number.
- * @retval kStatus_SDMMC_CardNotSupport Card not support.
- * @retval kStatus_SDMMC_SwitchFailed Switch failed.
- * @retval kStatus_SDMMC_NotSupportYet Not support yet.
- * @retval kStatus_Fail Switch failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SelectFunction(sd_card_t *card, uint32_t group, uint32_t function);
-
-/*!
- * @brief Send SET_DATA_WIDTH command to set SD bus width.
- *
- * @param card Card descriptor.
- * @param width Data bus width.
- * @retval kStatus_SDMMC_SendApplicationCommandFailed Send application command failed.
- * @retval kStatus_InvalidArgument Invalid argument.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SetDataBusWidth(sd_card_t *card, uint32_t width);
-
-/*!
- * @brief Decode raw CSD register content in the data blocks.
- *
- * @param card Card descriptor.
- * @param rawCsd Raw CSD register content.
- */
-static void SD_DecodeCsd(sd_card_t *card, uint32_t *rawCsd);
-
-/*!
- * @brief Send SEND_CSD command to get CSD register content from Card.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SendCsd(sd_card_t *card);
-
-/*!
- * @brief Decode raw CID register content in the data blocks.
- *
- * @param rawCid raw CID register content.
- * @param card Card descriptor.
- */
-static void SD_DecodeCid(sd_card_t *card, uint32_t *rawCid);
-
-/*!
- * @brief Send GET_CID command to get CID from card.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_AllSendCid(sd_card_t *card);
-
-/*!
- * @brief Send SEND_OPERATION_CONDITION command.
- *
- * This function sends host capacity support information and asks the accessed card to send its operating condition
- * register content.
- *
- * @param card Card descriptor.
- * @param argument The argument of the send operation condition ncomamnd.
- * @retval kStatus_SDMMC_SendApplicationCommandFailed Send application command failed.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Timeout Timeout.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_ApplicationSendOperationCondition(sd_card_t *card, uint32_t argument);
-
-/*!
- * @brief Send GET_INTERFACE_CONDITION command to get card interface condition.
- *
- * This function checks card interface condition, which includes host supply voltage information and asks the card
- * whether card supports the specified host voltage.
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_SendInterfaceCondition(sd_card_t *card);
-
-/*!
- * @brief Send switch voltage command
- * switch card voltage to 1.8v
- *
- * @param card Card descriptor.
- * @param voltage target voltage
- */
-static status_t SD_SwitchVoltage(sd_card_t *card, sdmmc_operation_voltage_t voltage);
-
-/*!
- * @brief select bus timing
- * select card timing
- * @param card Card descriptor.
- */
-static status_t SD_SelectBusTiming(sd_card_t *card);
-
-/*!
- * @brief Decode sd 512 bit status
- * @param card Card descriptor.
- * @param 512 bits satus raw data.
- */
-static void SD_DecodeStatus(sd_card_t *card, uint32_t *src);
-
-/*!
- * @brief Read data from specific SD card.
- *
- * @param card Card descriptor.
- * @param buffer Buffer to save data blocks read.
- * @param startBlock Card start block number to be read.
- * @param blockSize Block size.
- * @param blockCount Block count.
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support.
- * @retval kStatus_SDMMC_WaitWriteCompleteFailed Wait write complete failed.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_StopTransmissionFailed Stop transmission failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_Read(sd_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockSize, uint32_t blockCount);
-
-/*!
- * @brief Write data to specific card
- *
- * @param card Card descriptor.
- * @param buffer Buffer to be sent.
- * @param startBlock Card start block number to be written.
- * @param blockSize Block size.
- * @param blockCount Block count.
- * @param writtenBlocks successfully write blocks
- * @retval kStatus_SDMMC_CardNotSupport Card doesn't support.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_SDMMC_StopTransmissionFailed Stop transmission failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_Write(sd_card_t *card,
-                         const uint8_t *buffer,
-                         uint32_t startBlock,
-                         uint32_t blockSize,
-                         uint32_t blockCount,
-                         uint32_t *writtenBlocks);
-
-/*!
- * @brief Erase data for the given block range.
- *
- * @param card Card descriptor.
- * @param startBlock Card start block number to be erased.
- * @param blockCount The block count to be erased.
- * @param timeout timeout value in ms will be used to wait erase done.
- *
- * @retval kStatus_SDMMC_WaitWriteCompleteFailed wait erase timeout.
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- */
-static status_t SD_Erase(sd_card_t *card, uint32_t startBlock, uint32_t blockCount, uint32_t timeout);
-
-/*!
- * @brief card transfer function.
- *
- * @param card Card descriptor.
- * @param content Transfer content.
- * @param retry Retry times
- * @retval kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval kStatus_Success Operate successfully.
- * @retval kStatus_SDMMC_TuningFail tuning fail
- */
-static status_t SD_Transfer(sd_card_t *card, sdmmchost_transfer_t *content, uint32_t retry);
-
-/*!
- * @brief card execute tuning function.
- *
- * @param card Card descriptor.
- * @retval kStatus_Success Operate successfully.
- * @retval kStatus_SDMMC_TuningFail tuning fail.
- * @retval kStatus_SDMMC_TransferFailed transfer fail
- */
-static inline status_t SD_ExecuteTuning(sd_card_t *card);
-
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-/*!@brief sd size map */
-static uint32_t s_sdAuSizeMap[] = {0,
-                                   16 * 1024,
-                                   32 * 1024,
-                                   64 * 1024,
-                                   128 * 1024,
-                                   256 * 1024,
-                                   512 * 1024,
-                                   1024 * 1024,
-                                   2 * 1024 * 1024,
-                                   4 * 1024 * 1024,
-                                   8 * 1024 * 1024,
-                                   12 * 1024 * 1024,
-                                   16 * 1024 * 1024,
-                                   24 * 1024 * 1024,
-                                   32 * 1024 * 1024,
-                                   64 * 1024 * 1024};
-/*******************************************************************************
- * Code
- ******************************************************************************/
-static status_t SD_SendApplicationCmd(sd_card_t *card, uint32_t relativeAddress)
-{
-    assert(card != NULL);
-
-    return SDMMC_SendApplicationCommand(card->host, relativeAddress);
-}
-
-static status_t SD_GoIdle(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    return SDMMC_GoIdle(card->host);
-}
-
-static status_t SD_SetBlockSize(sd_card_t *card, uint32_t blockSize)
-{
-    assert(card != NULL);
-
-    return SDMMC_SetBlockSize(card->host, blockSize);
-}
-
-static status_t SD_ExecuteTuning(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    return SDMMCHOST_ExecuteTuning(card->host, (uint32_t)kSD_SendTuningBlock,
-                                   (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer), 64U);
-}
-
-static status_t SD_SwitchIOVoltage(sd_card_t *card, sdmmc_operation_voltage_t voltage)
-{
-    if ((card->usrParam.ioVoltage != NULL) && (card->usrParam.ioVoltage->type == kSD_IOVoltageCtrlByGpio))
-    {
-        /* make sure card signal line voltage is 3.3v before initalization */
-        if (card->usrParam.ioVoltage->func != NULL)
-        {
-            card->usrParam.ioVoltage->func(voltage);
-        }
-    }
-    else if ((card->usrParam.ioVoltage != NULL) && (card->usrParam.ioVoltage->type == kSD_IOVoltageCtrlByHost))
-    {
-        SDMMCHOST_SwitchToVoltage(card->host, (uint32_t)voltage);
-    }
-    else
-    {
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t SD_SwitchVoltage(sd_card_t *card, sdmmc_operation_voltage_t voltage)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSD_VoltageSwitch;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* check data line and cmd line status */
-    if (SDMMCHOST_GetSignalLineStatus(card->host, (uint32_t)kSDMMC_SignalLineData0 | (uint32_t)kSDMMC_SignalLineData1 |
-                                                      (uint32_t)kSDMMC_SignalLineData2 |
-                                                      (uint32_t)kSDMMC_SignalLineData3) != 0U)
-    {
-        return kStatus_SDMMC_SwitchVoltageFail;
-    }
-
-    /* switch io voltage */
-    if (SD_SwitchIOVoltage(card, voltage) == kStatus_SDMMC_NotSupportYet)
-    {
-        return kStatus_SDMMC_SwitchVoltageFail;
-    }
-
-    SDMMC_OSADelay(100U);
-
-    /*enable force clock on*/
-    SDMMCHOST_ForceClockOn(card->host, true);
-    /* dealy 1ms,not exactly correct when use while */
-    SDMMC_OSADelay(10U);
-    /*disable force clock on*/
-    SDMMCHOST_ForceClockOn(card->host, false);
-
-    /* check data line and cmd line status */
-    if (SDMMCHOST_GetSignalLineStatus(card->host, (uint32_t)kSDMMC_SignalLineData0 | (uint32_t)kSDMMC_SignalLineData1 |
-                                                      (uint32_t)kSDMMC_SignalLineData2 |
-                                                      (uint32_t)kSDMMC_SignalLineData3) == 0U)
-    {
-        error = kStatus_SDMMC_SwitchVoltageFail;
-        /* power reset the card */
-        SD_SetCardPower(card, false);
-        SD_SetCardPower(card, true);
-        /* re-check the data line status */
-        if (SDMMCHOST_GetSignalLineStatus(
-                card->host, (uint32_t)kSDMMC_SignalLineData0 | (uint32_t)kSDMMC_SignalLineData1 |
-                                (uint32_t)kSDMMC_SignalLineData2 | (uint32_t)kSDMMC_SignalLineData3) != 0U)
-        {
-            error = kStatus_SDMMC_SwitchVoltage18VFail33VSuccess;
-            SDMMC_LOG(
-                "\r\nNote: Current card support 1.8V, but board don't support, so sdmmc switch back to 3.3V.\r\n");
-        }
-        else
-        {
-            SDMMC_LOG(
-                "\r\nError: Current card support 1.8V, but board don't support, sdmmc tried to switch back\
-                    to 3.3V, but failed, please check board setting.\r\n");
-        }
-    }
-
-    return error;
-}
-
-static status_t SD_StopTransmission(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index              = (uint32_t)kSDMMC_StopTransmission;
-    command.argument           = 0U;
-    command.type               = kCARD_CommandTypeAbort;
-    command.responseType       = kCARD_ResponseTypeR1b;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success != error)
-    {
-        SDMMC_LOG("\r\nError: send CMD12 failed with host error %d, reponse %x\r\n", error, command.response[0U]);
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t SD_Transfer(sd_card_t *card, sdmmchost_transfer_t *content, uint32_t retry)
-{
-    assert(content != NULL);
-    status_t error;
-    uint32_t retuningCount = 3U;
-
-    do
-    {
-        error = SDMMCHOST_TransferFunction(card->host, content);
-        if (error == kStatus_Success)
-        {
-            break;
-        }
-
-        /* if transfer data failed, send cmd12 to abort current transfer */
-        if (content->data != NULL)
-        {
-            (void)SD_StopTransmission(card);
-            /* when transfer error occur, polling card status until it is ready for next data transfer, otherwise the
-             * retry transfer will fail again */
-            error = SD_PollingCardStatusBusy(card, SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-            if (error != kStatus_SDMMC_CardStatusIdle)
-            {
-                return kStatus_SDMMC_TransferFailed;
-            }
-        }
-
-        if ((retry == 0U) || (error == kStatus_SDMMC_ReTuningRequest))
-        {
-            if ((card->currentTiming == kSD_TimingSDR50Mode) || (card->currentTiming == kSD_TimingSDR104Mode))
-            {
-                if (--retuningCount == 0U)
-                {
-                    break;
-                }
-                /* perform retuning */
-                if (SD_ExecuteTuning(card) != kStatus_Success)
-                {
-                    error = kStatus_SDMMC_TuningFail;
-                    SDMMC_LOG("\r\nError: retuning failed.\r\n");
-                    break;
-                }
-                else
-                {
-                    SDMMC_LOG("\r\nlog: retuning successfully.\r\n");
-                    continue;
-                }
-            }
-        }
-
-        if (retry != 0U)
-        {
-            retry--;
-        }
-        else
-        {
-            break;
-        }
-
-    } while (true);
-
-    return error;
-}
-
-static status_t SD_SendCardStatus(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-    uint32_t retry               = SD_CMD13_RETRY_TIMES;
-
-    command.index        = (uint32_t)kSDMMC_SendStatus;
-    command.argument     = card->relativeAddress << 16U;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-    while (retry != 0U)
-    {
-        error = SDMMCHOST_TransferFunction(card->host, &content);
-        if (kStatus_Success != error)
-        {
-            SDMMC_LOG("\r\nError: send CMD13 failed with host error %d, response %x\r\n", error, command.response[0U]);
-            retry--;
-            continue;
-        }
-        else
-        {
-            if (((command.response[0U] & SDMMC_MASK(kSDMMC_R1ReadyForDataFlag)) != 0U) &&
-                (SDMMC_R1_CURRENT_STATE(command.response[0U]) != (uint32_t)kSDMMC_R1StateProgram))
-            {
-                error = kStatus_SDMMC_CardStatusIdle;
-            }
-            else
-            {
-                error = kStatus_SDMMC_CardStatusBusy;
-            }
-            break;
-        }
-    }
-
-    return error;
-}
-
-status_t SD_PollingCardStatusBusy(sd_card_t *card, uint32_t timeoutMs)
-{
-    assert(card != NULL);
-
-    uint32_t statusTimeoutUs = timeoutMs * 1000U;
-    bool cardBusy            = false;
-    status_t error           = kStatus_SDMMC_CardStatusBusy;
-
-    do
-    {
-        cardBusy = SDMMCHOST_IsCardBusy(card->host);
-
-        if (cardBusy == false)
-        {
-            error = SD_SendCardStatus(card);
-            if (error == kStatus_SDMMC_CardStatusIdle)
-            {
-                break;
-            }
-        }
-        else
-        {
-            /* Delay 125us to throttle the polling rate */
-            statusTimeoutUs -= SDMMC_OSADelayUs(125U);
-        }
-
-    } while (statusTimeoutUs != 0U);
-
-    return error;
-}
-
-static status_t SD_SendWriteSuccessBlocks(sd_card_t *card, uint32_t *blocks)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    status_t error               = kStatus_Success;
-    uint32_t *rawBuffer          = (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-
-    (void)memset(rawBuffer, 0, 4U);
-
-    /* Wait for the card write process complete because of that card read process and write process use one buffer. */
-    error = SD_PollingCardStatusBusy(card, SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        return kStatus_SDMMC_WaitWriteCompleteFailed;
-    }
-
-    if (kStatus_Success != SD_SendApplicationCmd(card, card->relativeAddress))
-    {
-        return kStatus_SDMMC_SendApplicationCommandFailed;
-    }
-
-    command.index        = (uint32_t)kSD_ApplicationSendNumberWriteBlocks;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    data.blockSize  = 4U;
-    data.blockCount = 1U;
-    data.rxData     = rawBuffer;
-
-    content.command = &command;
-    content.data    = &data;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success != error) || (((command.response[0U]) & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        SDMMC_LOG("\r\nError: send ACMD22 failed with host error %d, response %x\r\n", error, command.response[0U]);
-    }
-    else
-    {
-        *blocks = SWAP_WORD_BYTE_SEQUENCE(*rawBuffer);
-    }
-
-    return error;
-}
-
-static status_t SD_SendRca(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSD_SendRelativeAddress;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR6;
-
-    content.command = &command;
-    content.data    = NULL;
-
-    error = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success == error)
-    {
-        card->relativeAddress = (command.response[0U] >> 16U);
-    }
-    else
-    {
-        SDMMC_LOG("\r\nError: send CMD3 failed with host error %d, response %x\r\n", error, command.response[0U]);
-    }
-
-    return error;
-}
-
-static status_t SD_SwitchFunction(sd_card_t *card, uint32_t mode, uint32_t group, uint32_t number, uint32_t *status)
-{
-    assert(card != NULL);
-    assert(status != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    status_t error               = kStatus_Success;
-
-    command.index    = (uint32_t)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;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success != error) || (((command.response[0U]) & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        SDMMC_LOG("\r\n\r\nError: send CMD6 failed with host error %d, response %x\r\n", error, command.response[0U]);
-    }
-
-    return error;
-}
-
-static void SD_DecodeScr(sd_card_t *card, uint32_t *rawScr)
-{
-    assert(card != NULL);
-    assert(rawScr != NULL);
-
-    sd_scr_t *scr;
-
-    scr                  = &(card->scr);
-    scr->scrStructure    = (uint8_t)((rawScr[0U] & 0xF0000000U) >> 28U);
-    scr->sdSpecification = (uint8_t)((rawScr[0U] & 0xF000000U) >> 24U);
-    if ((uint8_t)((rawScr[0U] & 0x800000U) >> 23U) != 0U)
-    {
-        scr->flags |= (uint16_t)kSD_ScrDataStatusAfterErase;
-    }
-    scr->sdSecurity  = (uint8_t)((rawScr[0U] & 0x700000U) >> 20U);
-    scr->sdBusWidths = (uint8_t)((rawScr[0U] & 0xF0000U) >> 16U);
-    if ((uint8_t)((rawScr[0U] & 0x8000U) >> 15U) != 0U)
-    {
-        scr->flags |= (uint16_t)kSD_ScrSdSpecification3;
-    }
-    scr->extendedSecurity        = (uint8_t)((rawScr[0U] & 0x7800U) >> 10U);
-    scr->commandSupport          = (uint8_t)(rawScr[0U] & 0x3U);
-    scr->reservedForManufacturer = rawScr[1U];
-    /* Get specification version. */
-    if (scr->sdSpecification == 0U)
-    {
-        card->version = kSD_SpecificationVersion1_0;
-    }
-    else if (scr->sdSpecification == 1U)
-    {
-        card->version = kSD_SpecificationVersion1_1;
-    }
-    else if (scr->sdSpecification == 2U)
-    {
-        card->version = kSD_SpecificationVersion2_0;
-        if ((card->scr.flags & (uint32_t)kSD_ScrSdSpecification3) != 0U)
-        {
-            card->version = kSD_SpecificationVersion3_0;
-        }
-    }
-    else
-    {
-        /* reserved */
-    }
-
-    if ((card->scr.sdBusWidths & 0x4U) != 0U)
-    {
-        card->flags |= (uint32_t)kSD_Support4BitWidthFlag;
-    }
-    /* speed class control cmd */
-    if ((card->scr.commandSupport & 0x01U) != 0U)
-    {
-        card->flags |= (uint32_t)kSD_SupportSpeedClassControlCmd;
-    }
-    /* set block count cmd */
-    if ((card->scr.commandSupport & 0x02U) != 0U)
-    {
-        card->flags |= (uint32_t)kSD_SupportSetBlockCountCmd;
-    }
-}
-
-static status_t SD_SendScr(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    uint32_t *rawScr             = (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    status_t error               = kStatus_Success;
-
-    /* memset the global buffer */
-    (void)memset(rawScr, 0, 8U);
-
-    if (kStatus_Success != SD_SendApplicationCmd(card, card->relativeAddress))
-    {
-        return kStatus_SDMMC_SendApplicationCommandFailed;
-    }
-
-    command.index        = (uint32_t)kSD_ApplicationSendScr;
-    command.responseType = kCARD_ResponseTypeR1;
-    command.argument     = 0U;
-
-    data.blockSize  = 8U;
-    data.blockCount = 1U;
-    data.rxData     = rawScr;
-
-    content.data    = &data;
-    content.command = &command;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success != error) || (((command.response[0U]) & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        SDMMC_LOG("\r\nError: send ACMD51 failed with host error %d, response %x\r\n", error, command.response[0U]);
-    }
-    else
-    {
-        SDMMCHOST_ConvertDataToLittleEndian(card->host, rawScr, 2U, kSDMMC_DataPacketFormatMSBFirst);
-        /* decode scr */
-        SD_DecodeScr(card, rawScr);
-    }
-
-    return error;
-}
-
-static status_t SD_SelectFunction(sd_card_t *card, uint32_t group, uint32_t function)
-{
-    assert(card != NULL);
-
-    uint32_t *functionStatus       = (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    uint16_t functionGroupInfo[6U] = {0};
-    uint32_t currentFunctionStatus = 0U;
-    status_t error                 = kStatus_Success;
-
-    /* memset the global buffer */
-    (void)memset(functionStatus, 0, 64U);
-
-    /* check if card support CMD6 */
-    if ((card->version <= (uint32_t)kSD_SpecificationVersion1_0) ||
-        (0U == (card->csd.cardCommandClass & (uint32_t)kSDMMC_CommandClassSwitch)))
-    {
-        SDMMC_LOG("\r\nError: current card not support CMD6\r\n");
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    error = SD_SwitchFunction(card, (uint32_t)kSD_SwitchCheck, group, function, functionStatus);
-    /* Check if card support high speed mode. */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-    /* convert to little endian sequence */
-    SDMMCHOST_ConvertDataToLittleEndian(card->host, functionStatus, 5U, kSDMMC_DataPacketFormatMSBFirst);
-
-    /* -functionStatus[0U]---bit511~bit480;
-       -functionStatus[1U]---bit479~bit448;
-       -functionStatus[2U]---bit447~bit416;
-       -functionStatus[3U]---bit415~bit384;
-       -functionStatus[4U]---bit383~bit352;
-       According to the "switch function status[bits 511~0]" return by switch command in mode "check function":
-       -Check if function 1(high speed) in function group 1 is supported by checking if bit 401 is set;
-       -check if function 1 is ready and can be switched by checking if bits 379~376 equal value 1;
-     */
-    functionGroupInfo[5U] = (uint16_t)functionStatus[0U];
-    functionGroupInfo[4U] = (uint16_t)(functionStatus[1U] >> 16U);
-    functionGroupInfo[3U] = (uint16_t)(functionStatus[1U]);
-    functionGroupInfo[2U] = (uint16_t)(functionStatus[2U] >> 16U);
-    functionGroupInfo[1U] = (uint16_t)(functionStatus[2U]);
-    functionGroupInfo[0U] = (uint16_t)(functionStatus[3U] >> 16U);
-    currentFunctionStatus = ((functionStatus[3U] & 0xFFU) << 8U) | (functionStatus[4U] >> 24U);
-
-    /* check if function is support */
-    if (((functionGroupInfo[group] & (1UL << function)) == 0U) ||
-        ((currentFunctionStatus >> (group * 4U)) & 0xFU) != function)
-    {
-        SDMMC_LOG("\r\nError: current card not support function %d\r\n", function);
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    error = SD_SwitchFunction(card, (uint32_t)kSD_SwitchSet, group, function, functionStatus);
-    /* Switch to high speed mode. */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* convert to little endian sequence */
-    SDMMCHOST_ConvertDataToLittleEndian(card->host, &functionStatus[3U], 2U, kSDMMC_DataPacketFormatMSBFirst);
-
-    /* According to the "switch function status[bits 511~0]" return by switch command in mode "set function":
-       -check if group 1 is successfully changed to function 1 by checking if bits 379~376 equal value 1;
-     */
-    currentFunctionStatus = ((functionStatus[3U] & 0xFFU) << 8U) | (functionStatus[4U] >> 24U);
-
-    if (((currentFunctionStatus >> (group * 4U)) & 0xFU) != function)
-    {
-        SDMMC_LOG("\r\nError: switch to function %d failed\r\n", function);
-        return kStatus_SDMMC_SwitchFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t SD_SetDataBusWidth(sd_card_t *card, uint32_t width)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    if (kStatus_Success != SD_SendApplicationCmd(card, card->relativeAddress))
-    {
-        return kStatus_SDMMC_SendApplicationCommandFailed;
-    }
-
-    command.index        = (uint32_t)kSD_ApplicationSetBusWdith;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    if (width == (uint32_t)kSDMMC_BusWdith1Bit)
-    {
-        command.argument = 0U;
-    }
-    else if (width == (uint32_t)kSDMMC_BusWdith4Bit)
-    {
-        command.argument = 2U;
-    }
-    else
-    {
-        return kStatus_InvalidArgument;
-    }
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if ((kStatus_Success != error) || (((command.response[0U]) & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        SDMMC_LOG("\r\nError: send ACMD6 failed with host error %d, response %x\r\n", error, command.response[0U]);
-    }
-
-    return error;
-}
-
-static void SD_DecodeCsd(sd_card_t *card, uint32_t *rawCsd)
-{
-    assert(card != NULL);
-    assert(rawCsd != NULL);
-
-    sd_csd_t *csd;
-
-    csd                      = &(card->csd);
-    csd->csdStructure        = (uint8_t)((rawCsd[3U] & 0xC0000000U) >> 30U);
-    csd->dataReadAccessTime1 = (uint8_t)((rawCsd[3U] & 0xFF0000U) >> 16U);
-    csd->dataReadAccessTime2 = (uint8_t)((rawCsd[3U] & 0xFF00U) >> 8U);
-    csd->transferSpeed       = (uint8_t)(rawCsd[3U] & 0xFFU);
-    csd->cardCommandClass    = (uint16_t)((rawCsd[2U] & 0xFFF00000U) >> 20U);
-    csd->readBlockLength     = (uint8_t)((rawCsd[2U] & 0xF0000U) >> 16U);
-    if ((rawCsd[2U] & 0x8000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdReadBlockPartialFlag;
-    }
-    if ((rawCsd[2U] & 0x4000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdReadBlockPartialFlag;
-    }
-    if ((rawCsd[2U] & 0x2000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdReadBlockMisalignFlag;
-    }
-    if ((rawCsd[2U] & 0x1000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdDsrImplementedFlag;
-    }
-    if (csd->csdStructure == 0U)
-    {
-        csd->deviceSize = (uint32_t)((rawCsd[2U] & 0x3FFU) << 2U);
-        csd->deviceSize |= (uint32_t)((rawCsd[1U] & 0xC0000000U) >> 30U);
-        csd->readCurrentVddMin    = (uint8_t)((rawCsd[1U] & 0x38000000U) >> 27U);
-        csd->readCurrentVddMax    = (uint8_t)((rawCsd[1U] & 0x7000000U) >> 24U);
-        csd->writeCurrentVddMin   = (uint8_t)((rawCsd[1U] & 0xE00000U) >> 20U);
-        csd->writeCurrentVddMax   = (uint8_t)((rawCsd[1U] & 0x1C0000U) >> 18U);
-        csd->deviceSizeMultiplier = (uint8_t)((rawCsd[1U] & 0x38000U) >> 15U);
-
-        /* Get card total block count and block size. */
-        card->blockCount = ((csd->deviceSize + 1U) << (csd->deviceSizeMultiplier + 2U));
-        card->blockSize  = (1UL << (csd->readBlockLength));
-        if (card->blockSize != FSL_SDMMC_DEFAULT_BLOCK_SIZE)
-        {
-            card->blockCount = (card->blockCount * card->blockSize);
-            card->blockSize  = FSL_SDMMC_DEFAULT_BLOCK_SIZE;
-            card->blockCount = (card->blockCount / card->blockSize);
-        }
-    }
-    else if (csd->csdStructure == 1U)
-    {
-        card->blockSize = FSL_SDMMC_DEFAULT_BLOCK_SIZE;
-
-        csd->deviceSize = (uint32_t)((rawCsd[2U] & 0x3FU) << 16U);
-        csd->deviceSize |= (uint32_t)((rawCsd[1U] & 0xFFFF0000U) >> 16U);
-        if (csd->deviceSize >= 0xFFFFU)
-        {
-            card->flags |= (uint32_t)kSD_SupportSdxcFlag;
-        }
-
-        card->blockCount = ((csd->deviceSize + 1U) * 1024U);
-    }
-    else
-    {
-        /* not support csd version */
-    }
-
-    if ((uint8_t)((rawCsd[1U] & 0x4000U) >> 14U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdEraseBlockEnabledFlag;
-    }
-    csd->eraseSectorSize       = (uint8_t)((rawCsd[1U] & 0x3F80U) >> 7U);
-    csd->writeProtectGroupSize = (uint8_t)(rawCsd[1U] & 0x7FU);
-    if ((uint8_t)(rawCsd[0U] & 0x80000000U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdWriteProtectGroupEnabledFlag;
-    }
-    csd->writeSpeedFactor = (uint8_t)((rawCsd[0U] & 0x1C000000U) >> 26U);
-    csd->writeBlockLength = (uint8_t)((rawCsd[0U] & 0x3C00000U) >> 22U);
-    if ((uint8_t)((rawCsd[0U] & 0x200000U) >> 21U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdWriteBlockPartialFlag;
-    }
-    if ((uint8_t)((rawCsd[0U] & 0x8000U) >> 15U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdFileFormatGroupFlag;
-    }
-    if ((uint8_t)((rawCsd[0U] & 0x4000U) >> 14U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdCopyFlag;
-    }
-    if ((uint8_t)((rawCsd[0U] & 0x2000U) >> 13U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdPermanentWriteProtectFlag;
-    }
-    if ((uint8_t)((rawCsd[0U] & 0x1000U) >> 12U) != 0U)
-    {
-        csd->flags |= (uint16_t)kSD_CsdTemporaryWriteProtectFlag;
-    }
-    csd->fileFormat = (uint8_t)((rawCsd[0U] & 0xC00U) >> 10U);
-}
-
-static status_t SD_SendCsd(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDMMC_SendCsd;
-    command.argument     = (card->relativeAddress << 16U);
-    command.responseType = kCARD_ResponseTypeR2;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success == error)
-    {
-        (void)memcpy(card->internalBuffer, (uint8_t *)command.response, 16U);
-        /* The response is from bit 127:8 in R2, corrisponding to command.response[3U]:command.response[0U][31U:8]. */
-        SD_DecodeCsd(card, (uint32_t *)(uint32_t)card->internalBuffer);
-    }
-    else
-    {
-        error = kStatus_SDMMC_TransferFailed;
-        SDMMC_LOG("\r\nError: send CMD9(get csd) failed with host error %d, response %x\r\n", error,
-                  command.response[0U]);
-    }
-
-    return error;
-}
-
-static void SD_DecodeCid(sd_card_t *card, uint32_t *rawCid)
-{
-    assert(card != NULL);
-    assert(rawCid != NULL);
-
-    sd_cid_t *cid;
-
-    cid                 = &(card->cid);
-    cid->manufacturerID = (uint8_t)((rawCid[3U] & 0xFF000000U) >> 24U);
-    cid->applicationID  = (uint16_t)((rawCid[3U] & 0xFFFF00U) >> 8U);
-
-    cid->productName[0U] = (uint8_t)((rawCid[3U] & 0xFFU));
-    cid->productName[1U] = (uint8_t)((rawCid[2U] & 0xFF000000U) >> 24U);
-    cid->productName[2U] = (uint8_t)((rawCid[2U] & 0xFF0000U) >> 16U);
-    cid->productName[3U] = (uint8_t)((rawCid[2U] & 0xFF00U) >> 8U);
-    cid->productName[4U] = (uint8_t)((rawCid[2U] & 0xFFU));
-
-    cid->productVersion = (uint8_t)((rawCid[1U] & 0xFF000000U) >> 24U);
-
-    cid->productSerialNumber = (uint32_t)((rawCid[1U] & 0xFFFFFFU) << 8U);
-    cid->productSerialNumber |= (uint32_t)((rawCid[0U] & 0xFF000000U) >> 24U);
-
-    cid->manufacturerData = (uint16_t)((rawCid[0U] & 0xFFF00U) >> 8U);
-}
-
-static status_t SD_AllSendCid(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_SDMMC_TransferFailed;
-
-    command.index        = (uint32_t)kSDMMC_AllSendCid;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR2;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success == error)
-    {
-        (void)memcpy(card->internalBuffer, (uint8_t *)command.response, 16U);
-        SD_DecodeCid(card, (uint32_t *)(uint32_t)card->internalBuffer);
-
-        error = kStatus_Success;
-    }
-
-    return error;
-}
-
-static status_t SD_ApplicationSendOperationCondition(sd_card_t *card, uint32_t argument)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Fail;
-    uint32_t i                   = FSL_SDMMC_MAX_VOLTAGE_RETRIES;
-
-    command.index        = (uint32_t)kSD_ApplicationSendOperationCondition;
-    command.argument     = argument;
-    command.responseType = kCARD_ResponseTypeR3;
-
-    while (0U != i--)
-    {
-        if (kStatus_Success != SD_SendApplicationCmd(card, 0U))
-        {
-            continue;
-        }
-
-        content.command = &command;
-        content.data    = NULL;
-        error           = SDMMCHOST_TransferFunction(card->host, &content);
-        if (kStatus_Success != error)
-        {
-            SDMMC_LOG("\r\nError: send ACMD41 failed with host error %d, response %x\r\n", error, command.response[0U]);
-            return kStatus_SDMMC_TransferFailed;
-        }
-
-        /* Wait until card exit busy state. */
-        if ((command.response[0U] & SDMMC_MASK(kSD_OcrPowerUpBusyFlag)) != 0U)
-        {
-            /* high capacity check */
-            if ((command.response[0U] & SDMMC_MASK(kSD_OcrCardCapacitySupportFlag)) != 0U)
-            {
-                card->flags |= (uint32_t)kSD_SupportHighCapacityFlag;
-            }
-            /* 1.8V support */
-            if ((command.response[0U] & SDMMC_MASK(kSD_OcrSwitch18AcceptFlag)) != 0U)
-            {
-                card->flags |= (uint32_t)kSD_SupportVoltage180v;
-            }
-            card->ocr = command.response[0U];
-
-            return kStatus_Success;
-        }
-
-        SDMMC_OSADelay(10U);
-    }
-
-    SDMMC_LOG("\r\nError: send ACMD41 timeout\r\n");
-
-    return error;
-}
-
-static status_t SD_SendInterfaceCondition(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    uint32_t i                   = FSL_SDMMC_MAX_CMD_RETRIES;
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSD_SendInterfaceCondition;
-    command.argument     = 0x1AAU;
-    command.responseType = kCARD_ResponseTypeR7;
-
-    content.command = &command;
-    content.data    = NULL;
-    do
-    {
-        error = SDMMCHOST_TransferFunction(card->host, &content);
-        if (kStatus_Success != error)
-        {
-            SDMMC_LOG("\r\nError: send CMD8 failed with host error %d, response %x\r\n", error, command.response[0U]);
-        }
-        else
-        {
-            if ((command.response[0U] & 0xFFU) != 0xAAU)
-            {
-                error = kStatus_SDMMC_CardNotSupport;
-                SDMMC_LOG("\r\nError: card not support CMD8\r\n");
-            }
-            else
-            {
-                error = kStatus_Success;
-            }
-        }
-    } while ((--i != 0U) && (error != kStatus_Success));
-
-    return error;
-}
-
-static status_t SD_SelectBusTiming(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_SDMMC_SwitchBusTimingFailed;
-
-    if (card->operationVoltage != kSDMMC_OperationVoltage180V)
-    {
-        /* group 1, function 1 ->high speed mode*/
-        error = SD_SelectFunction(card, kSD_GroupTimingMode, kSD_FunctionSDR25HighSpeed);
-        /* If the result isn't "switching to high speed mode(50MHZ) successfully or card doesn't support high speed
-         * mode". Return failed status. */
-        if (error == kStatus_Success)
-        {
-            card->currentTiming = kSD_TimingSDR25HighSpeedMode;
-            card->busClock_Hz =
-                SDMMCHOST_SetCardClock(card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_50MHZ));
-        }
-        else
-        {
-            if (error == kStatus_SDMMC_NotSupportYet)
-            {
-                /* if not support high speed, keep the card work at default mode */
-                SDMMC_LOG("\r\nNote: High speed mode is not supported by card\r\n");
-                return kStatus_Success;
-            }
-        }
-    }
-    /* card is in UHS_I mode */
-    else
-    {
-        do
-        {
-            if (card->currentTiming == kSD_TimingSDR12DefaultMode)
-            {
-                /* if timing not specified, probe card capability from SDR104 mode */
-                card->currentTiming = kSD_TimingSDR104Mode;
-            }
-
-            if (card->currentTiming == kSD_TimingSDR104Mode)
-            {
-                if ((card->host->capability & (uint32_t)kSDMMCHOST_SupportSDR104) != 0U)
-                {
-                    error = SD_SelectFunction(card, kSD_GroupTimingMode, kSD_FunctionSDR104);
-                    if (error == kStatus_Success)
-                    {
-                        card->currentTiming = kSD_TimingSDR104Mode;
-                        card->busClock_Hz   = SDMMCHOST_SetCardClock(
-                            card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_208MHZ));
-                        break;
-                    }
-                }
-                SDMMC_LOG("\r\nNote: SDR104 mode is not supported\r\n");
-                card->currentTiming = kSD_TimingDDR50Mode;
-            }
-
-            if (card->currentTiming == kSD_TimingDDR50Mode)
-            {
-                error = SD_SelectFunction(card, kSD_GroupTimingMode, kSD_FunctionDDR50);
-                if (error == kStatus_Success)
-                {
-                    card->currentTiming = kSD_TimingDDR50Mode;
-                    card->busClock_Hz   = SDMMCHOST_SetCardClock(
-                        card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_50MHZ));
-                    SDMMCHOST_EnableDDRMode(card->host, true, 0U);
-                    break;
-                }
-                SDMMC_LOG("\r\nNote: DDR50 mode is not supported\r\n");
-                card->currentTiming = kSD_TimingSDR50Mode;
-            }
-
-            if (card->currentTiming == kSD_TimingSDR50Mode)
-            {
-                if ((card->host->capability & (uint32_t)kSDMMCHOST_SupportSDR50) != 0U)
-                {
-                    error = SD_SelectFunction(card, kSD_GroupTimingMode, kSD_FunctionSDR50);
-                    if (error == kStatus_Success)
-                    {
-                        card->currentTiming = kSD_TimingSDR50Mode;
-                        card->busClock_Hz   = SDMMCHOST_SetCardClock(
-                            card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_100MHZ));
-                        break;
-                    }
-                }
-                SDMMC_LOG("\r\nNote: SDR50 mode is not supported\r\n");
-                card->currentTiming = kSD_TimingSDR25HighSpeedMode;
-            }
-
-            if (card->currentTiming == kSD_TimingSDR25HighSpeedMode)
-            {
-                error = SD_SelectFunction(card, kSD_GroupTimingMode, kSD_FunctionSDR25HighSpeed);
-                if (error == kStatus_Success)
-                {
-                    card->currentTiming = kSD_TimingSDR25HighSpeedMode;
-                    card->busClock_Hz   = SDMMCHOST_SetCardClock(
-                        card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_50MHZ));
-                    break;
-                }
-            }
-
-            SDMMC_LOG("\r\nWarning: unknown timing mode\r\n");
-        } while (false);
-    }
-
-    if (error == kStatus_Success)
-    {
-        /* Update io strength according to different bus frequency */
-        if (card->usrParam.ioStrength != NULL)
-        {
-            card->usrParam.ioStrength(card->busClock_Hz);
-        }
-
-        /* SDR50 and SDR104 mode need tuning */
-        if ((card->currentTiming == kSD_TimingSDR50Mode) || (card->currentTiming == kSD_TimingSDR104Mode))
-        {
-            /* execute tuning */
-            if (SD_ExecuteTuning(card) != kStatus_Success)
-            {
-                SDMMC_LOG("\r\nError: tuning failed for mode %d\r\n", card->currentTiming);
-                return kStatus_SDMMC_TuningFail;
-            }
-        }
-    }
-
-    return error;
-}
-
-static void SD_DecodeStatus(sd_card_t *card, uint32_t *src)
-{
-    assert(card != NULL);
-    assert(src != NULL);
-
-    card->stat.busWidth        = (uint8_t)((src[0U] & 0xC0000000U) >> 30U);                                /* 511-510 */
-    card->stat.secureMode      = (uint8_t)((src[0U] & 0x20000000U) >> 29U);                                /* 509 */
-    card->stat.cardType        = (uint16_t)((src[0U] & 0x0000FFFFU));                                      /* 495-480 */
-    card->stat.protectedSize   = src[1U];                                                                  /* 479-448 */
-    card->stat.speedClass      = (uint8_t)((src[2U] & 0xFF000000U) >> 24U);                                /* 447-440 */
-    card->stat.performanceMove = (uint8_t)((src[2U] & 0x00FF0000U) >> 16U);                                /* 439-432 */
-    card->stat.auSize          = (uint8_t)((src[2U] & 0x0000F000U) >> 12U);                                /* 431-428 */
-    card->stat.eraseSize = (uint16_t)(((src[2U] & 0x000000FFU) << 8U) | ((src[3U] & 0xFF000000U) >> 24U)); /* 423-408 */
-    card->stat.eraseTimeout  = (((uint8_t)((src[3U] & 0x00FF0000U) >> 16U)) & 0xFCU) >> 2U;                /* 407-402 */
-    card->stat.eraseOffset   = ((uint8_t)((src[3U] & 0x00FF0000U) >> 16U)) & 0x3U;                         /* 401-400 */
-    card->stat.uhsSpeedGrade = (((uint8_t)((src[3U] & 0x0000FF00U) >> 8U)) & 0xF0U) >> 4U;                 /* 399-396 */
-    card->stat.uhsAuSize     = ((uint8_t)((src[3U] & 0x0000FF00U) >> 8U)) & 0xFU;                          /* 395-392 */
-}
-
-status_t SD_ReadStatus(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    status_t error               = kStatus_Success;
-    uint32_t *rawPointer         = (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-
-    (void)memset(rawPointer, 0, 64U);
-
-    /* wait card status ready. */
-    error = SD_PollingCardStatusBusy(card, SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        return kStatus_SDMMC_WaitWriteCompleteFailed;
-    }
-
-    if (kStatus_Success != SD_SendApplicationCmd(card, card->relativeAddress))
-    {
-        return kStatus_SDMMC_SendApplicationCommandFailed;
-    }
-
-    command.index        = (uint32_t)kSDMMC_SendStatus;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    data.blockSize  = 64U;
-    data.blockCount = 1U;
-    data.rxData     = rawPointer;
-
-    content.command = &command;
-    content.data    = &data;
-    error           = SD_Transfer(card, &content, 3U);
-    if ((kStatus_Success != error) || (((command.response[0U]) & SDMMC_R1_ALL_ERROR_FLAG) != 0U))
-    {
-        SDMMC_LOG("\r\nError: send ACMD13 failed with host error %d, response %x\r\n", error, command.response[0U]);
-
-        return kStatus_SDMMC_TransferFailed;
-    }
-    /* switch to little endian sequence */
-    SDMMCHOST_ConvertDataToLittleEndian(card->host, rawPointer, 16U, kSDMMC_DataPacketFormatMSBFirst);
-    SD_DecodeStatus(card, rawPointer);
-
-    return kStatus_Success;
-}
-
-status_t SD_SelectCard(sd_card_t *card, bool isSelected)
-{
-    assert(card != NULL);
-
-    return SDMMC_SelectCard(card->host, card->relativeAddress, isSelected);
-}
-
-status_t SD_SetDriverStrength(sd_card_t *card, sd_driver_strength_t driverStrength)
-{
-    assert(card != NULL);
-
-    status_t error;
-    uint32_t strength = (uint32_t)driverStrength;
-
-    error = SD_SelectFunction(card, kSD_GroupDriverStrength, strength);
-
-    return error;
-}
-
-status_t SD_SetMaxCurrent(sd_card_t *card, sd_max_current_t maxCurrent)
-{
-    assert(card != NULL);
-
-    status_t error;
-    uint32_t current = (uint32_t)maxCurrent;
-
-    error = SD_SelectFunction(card, kSD_GroupCurrentLimit, current);
-
-    return error;
-}
-
-static status_t SD_Read(sd_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockSize, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-    assert(blockSize == FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-    status_t error               = kStatus_Success;
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-
-    if ((((card->flags & (uint32_t)kSD_SupportHighCapacityFlag) != 0U) && (blockSize != 512U)) ||
-        (blockSize > card->blockSize) || (blockSize > card->host->maxBlockSize) || ((blockSize % 4U) != 0U))
-    {
-        SDMMC_LOG("\r\nError: read with parameter, block size %d is not support\r\n", blockSize);
-        return kStatus_SDMMC_CardNotSupport;
-    }
-
-    /* read command are not allowed while card is programming */
-    error = SD_PollingCardStatusBusy(card, SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        SDMMC_LOG("Error : read failed with wrong card busy\r\n");
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    data.blockSize           = blockSize;
-    data.blockCount          = blockCount;
-    data.rxData              = (uint32_t *)(uint32_t)buffer;
-    data.enableAutoCommand12 = true;
-
-    command.index    = (blockCount == 1U) ? (uint32_t)kSDMMC_ReadSingleBlock : (uint32_t)kSDMMC_ReadMultipleBlock;
-    command.argument = startBlock;
-    if (0U == (card->flags & (uint32_t)kSD_SupportHighCapacityFlag))
-    {
-        command.argument *= data.blockSize;
-    }
-    command.responseType       = kCARD_ResponseTypeR1;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = &data;
-
-    error = SD_Transfer(card, &content, 3U);
-    if (error != kStatus_Success)
-    {
-        return error;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t SD_Write(sd_card_t *card,
-                         const uint8_t *buffer,
-                         uint32_t startBlock,
-                         uint32_t blockSize,
-                         uint32_t blockCount,
-                         uint32_t *writtenBlocks)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-    assert(blockSize == FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    sdmmchost_data_t data        = {0};
-    status_t error;
-
-    if ((((card->flags & (uint32_t)kSD_SupportHighCapacityFlag) != 0U) && (blockSize != 512U)) ||
-        (blockSize > card->blockSize) || (blockSize > card->host->maxBlockSize) || ((blockSize % 4U) != 0U))
-    {
-        SDMMC_LOG("\r\nError: write with parameter, block size %d is not support\r\n", blockSize);
-        return kStatus_SDMMC_CardNotSupport;
-    }
-
-    /* polling card status idle */
-    error = SD_PollingCardStatusBusy(card, SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        SDMMC_LOG("Error : write failed, card status busy\r\n");
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    data.enableAutoCommand12   = true;
-    data.blockSize             = blockSize;
-    command.responseType       = kCARD_ResponseTypeR1;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    command.index    = (blockCount == 1U) ? (uint32_t)kSDMMC_WriteSingleBlock : (uint32_t)kSDMMC_WriteMultipleBlock;
-    command.argument = startBlock;
-    if (0U == (card->flags & (uint32_t)kSD_SupportHighCapacityFlag))
-    {
-        command.argument *= data.blockSize;
-    }
-
-    *writtenBlocks  = blockCount;
-    data.blockCount = blockCount;
-    data.txData     = (const uint32_t *)(uint32_t)buffer;
-
-    content.command = &command;
-    content.data    = &data;
-
-    error = SD_Transfer(card, &content, 3U);
-    if (error != kStatus_Success)
-    {
-        error = SD_SendWriteSuccessBlocks(card, writtenBlocks);
-        /* check the successfully written block */
-        if (error == kStatus_Success)
-        {
-            if (*writtenBlocks != 0U)
-            {
-                /* written success, but not all the blocks are written */
-                error = kStatus_Success;
-            }
-        }
-        SDMMC_LOG("\r\nWarning: write failed with block count %d, successed %d\r\n", blockCount, *writtenBlocks);
-    }
-
-    return error;
-}
-
-static status_t SD_Erase(sd_card_t *card, uint32_t startBlock, uint32_t blockCount, uint32_t timeout)
-{
-    assert(card != NULL);
-    assert(blockCount != 0U);
-    assert(timeout != 0U);
-
-    uint32_t eraseBlockStart;
-    uint32_t eraseBlockEnd;
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    /* polling card status idle */
-    error = SD_PollingCardStatusBusy(card, SD_CARD_ACCESS_WAIT_IDLE_TIMEOUT);
-    if (kStatus_SDMMC_CardStatusIdle != error)
-    {
-        SDMMC_LOG("Error : write failed, card status busy\r\n");
-        return kStatus_SDMMC_PollingCardIdleFailed;
-    }
-
-    eraseBlockStart = startBlock;
-    eraseBlockEnd   = eraseBlockStart + blockCount - 1U;
-    if (0U == (card->flags & (uint32_t)kSD_SupportHighCapacityFlag))
-    {
-        eraseBlockStart = eraseBlockStart * FSL_SDMMC_DEFAULT_BLOCK_SIZE;
-        eraseBlockEnd   = eraseBlockEnd * FSL_SDMMC_DEFAULT_BLOCK_SIZE;
-    }
-
-    /* Send ERASE_WRITE_BLOCK_START command to set the start block number to erase. */
-    command.index              = (uint32_t)kSD_EraseWriteBlockStart;
-    command.argument           = eraseBlockStart;
-    command.responseType       = kCARD_ResponseTypeR1;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SD_Transfer(card, &content, 1U);
-    if (kStatus_Success != error)
-    {
-        SDMMC_LOG("\r\nError: send CMD32(erase start) failed with host error %d, response %x\r\n", error,
-                  command.response[0U]);
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* Send ERASE_WRITE_BLOCK_END command to set the end block number to erase. */
-    command.index    = (uint32_t)kSD_EraseWriteBlockEnd;
-    command.argument = eraseBlockEnd;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SD_Transfer(card, &content, 0U);
-    if (kStatus_Success != error)
-    {
-        SDMMC_LOG("\r\nError: send CMD33(erase end) failed with host error %d, response %x\r\n", error,
-                  command.response[0U]);
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* Send ERASE command to start erase process. */
-    command.index              = (uint32_t)kSDMMC_Erase;
-    command.argument           = 0U;
-    command.responseType       = kCARD_ResponseTypeR1b;
-    command.responseErrorFlags = SDMMC_R1_ALL_ERROR_FLAG;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SD_Transfer(card, &content, 0U);
-    if (kStatus_Success != error)
-    {
-        SDMMC_LOG("\r\nError: send CMD38(erase) failed with host error %d, response %x\r\n", error,
-                  command.response[0U]);
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-bool SD_CheckReadOnly(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    return (((card->csd.flags & (uint16_t)kSD_CsdPermanentWriteProtectFlag) != 0U) ||
-            ((card->csd.flags & (uint16_t)kSD_CsdTemporaryWriteProtectFlag)) != 0U);
-}
-
-status_t SD_ReadBlocks(sd_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-    assert((blockCount + startBlock) <= card->blockCount);
-
-    uint32_t blockCountOneTime;
-    uint32_t blockLeft;
-    uint32_t blockDone   = 0U;
-    uint8_t *nextBuffer  = buffer;
-    bool dataAddrAlign   = true;
-    uint8_t *alignBuffer = (uint8_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    status_t error       = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    blockLeft = blockCount;
-
-    while (blockLeft != 0U)
-    {
-        nextBuffer = (uint8_t *)((uint32_t)buffer + blockDone * FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-        if ((!card->noInteralAlign) && (!dataAddrAlign || ((((uint32_t)nextBuffer) & (sizeof(uint32_t) - 1U)) != 0U)))
-        {
-            blockCountOneTime = 1;
-            (void)memset(alignBuffer, 0, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-            dataAddrAlign = false;
-            blockLeft -= blockCountOneTime;
-        }
-        else
-        {
-            if (blockLeft > card->host->maxBlockCount)
-            {
-                blockLeft         = (blockLeft - card->host->maxBlockCount);
-                blockCountOneTime = card->host->maxBlockCount;
-            }
-            else
-            {
-                blockCountOneTime = blockLeft;
-                blockLeft         = 0U;
-            }
-        }
-
-        error = SD_Read(card, dataAddrAlign ? nextBuffer : alignBuffer, (startBlock + blockDone),
-                        FSL_SDMMC_DEFAULT_BLOCK_SIZE, blockCountOneTime);
-        if (kStatus_Success != error)
-        {
-            error = kStatus_SDMMC_TransferFailed;
-            break;
-        }
-
-        blockDone += blockCountOneTime;
-
-        if (!card->noInteralAlign && (!dataAddrAlign))
-        {
-            (void)memcpy(nextBuffer, alignBuffer, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t SD_WriteBlocks(sd_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(blockCount != 0U);
-    assert((blockCount + startBlock) <= card->blockCount);
-
-    uint32_t blockCountOneTime   = 0U; /* The block count can be wrote in one time sending WRITE_BLOCKS command. */
-    uint32_t blockWrittenOneTime = 0U;
-    uint32_t blockLeft           = 0U; /* Left block count to be wrote. */
-    const uint8_t *nextBuffer;
-    bool dataAddrAlign   = true;
-    uint8_t *alignBuffer = (uint8_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    status_t error       = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    blockLeft = blockCount;
-    while (blockLeft != 0U)
-    {
-        nextBuffer = (uint8_t *)((uint32_t)buffer + (blockCount - blockLeft) * FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-        if (!card->noInteralAlign && (!dataAddrAlign || ((((uint32_t)nextBuffer) & (sizeof(uint32_t) - 1U)) != 0U)))
-        {
-            blockCountOneTime = 1;
-            (void)memcpy(alignBuffer, nextBuffer, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-            dataAddrAlign = false;
-        }
-        else
-        {
-            if (blockLeft > card->host->maxBlockCount)
-            {
-                blockCountOneTime = card->host->maxBlockCount;
-            }
-            else
-            {
-                blockCountOneTime = blockLeft;
-            }
-        }
-
-        error = SD_Write(card, dataAddrAlign ? nextBuffer : alignBuffer, (startBlock + blockCount - blockLeft),
-                         FSL_SDMMC_DEFAULT_BLOCK_SIZE, blockCountOneTime, &blockWrittenOneTime);
-        if (kStatus_Success != error)
-        {
-            error = kStatus_SDMMC_TransferFailed;
-            break;
-        }
-
-        blockLeft -= blockWrittenOneTime;
-
-        if ((!card->noInteralAlign) && !dataAddrAlign)
-        {
-            (void)memset(alignBuffer, 0, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-static uint32_t SD_CalculateEraseTimeout(sd_card_t *card, uint32_t blockCount, uint32_t auSize)
-{
-    uint32_t auCount    = blockCount / (auSize / FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-    uint32_t timeout_ms = 0U;
-
-    if (auCount == 0U)
-    {
-        auCount = 1U;
-    }
-
-    timeout_ms = auCount * 250U; /* 250 ms erase timeout per AU by default */
-
-    if ((card->stat.eraseTimeout != 0U) && (card->stat.eraseSize != 0U))
-    {
-        /* timeout determined by the block count to be erased and the au size */
-        timeout_ms = auCount * (((uint32_t)card->stat.eraseTimeout * 1000U) / (uint32_t)card->stat.eraseSize + 500U) +
-                     card->stat.eraseOffset * 1000U;
-    }
-
-    /* convert to ms */
-    return timeout_ms < 1000U ? 1000U : timeout_ms;
-}
-
-status_t SD_EraseBlocks(sd_card_t *card, uint32_t startBlock, uint32_t blockCount)
-{
-    assert(card != NULL);
-    assert(blockCount != 0U);
-    assert((blockCount + startBlock) <= card->blockCount);
-
-    uint32_t blockCountOneTime; /* The block count can be erased in one time sending ERASE_BLOCKS command. */
-    uint32_t blockDone = 0U;    /* The block count has been erased. */
-    uint32_t blockLeft;         /* Left block count to be erase. */
-    status_t error                 = kStatus_Success;
-    uint32_t onetimeMaxEraseBlocks = 0U;
-    uint32_t auSize                = 0U;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    /* sdsc card erasable sector is determined by CSD register */
-    if (card->csd.csdStructure == 0U)
-    {
-        onetimeMaxEraseBlocks = card->csd.eraseSectorSize + 1UL;
-    }
-    else
-    {
-        /* limit one time maximum erase size to 1 AU */
-        if ((card->stat.auSize >= SD_AU_START_VALUE))
-        {
-            /* UHS card should use uhs au size field */
-            if (card->operationVoltage == kSDMMC_OperationVoltage180V)
-            {
-                auSize = s_sdAuSizeMap[card->stat.uhsAuSize == 0U ? card->stat.auSize : card->stat.uhsAuSize];
-                onetimeMaxEraseBlocks = auSize / FSL_SDMMC_DEFAULT_BLOCK_SIZE;
-            }
-            else
-            {
-                auSize                = s_sdAuSizeMap[card->stat.auSize];
-                onetimeMaxEraseBlocks = auSize / FSL_SDMMC_DEFAULT_BLOCK_SIZE;
-            }
-
-            if (card->stat.eraseSize != 0U)
-            {
-                onetimeMaxEraseBlocks *= card->stat.eraseSize;
-            }
-        }
-    }
-
-    if (onetimeMaxEraseBlocks == 0U)
-    {
-        SDMMC_LOG(
-            "Warning: AU size in sd descriptor is not set properly, please check if SD_ReadStatus is called before\
-          SD_EraseBlocks\r\n");
-        error = kStatus_SDMMC_AuSizeNotSetProperly;
-    }
-    else
-    {
-        blockLeft = blockCount;
-        while (blockLeft != 0U)
-        {
-            if (blockLeft > onetimeMaxEraseBlocks)
-            {
-                blockCountOneTime = onetimeMaxEraseBlocks;
-                blockLeft         = blockLeft - blockCountOneTime;
-            }
-            else
-            {
-                blockCountOneTime = blockLeft;
-                blockLeft         = 0U;
-            }
-
-            error = SD_Erase(card, (startBlock + blockDone), blockCountOneTime,
-                             SD_CalculateEraseTimeout(card, blockCountOneTime, auSize));
-            if (error != kStatus_Success)
-            {
-                break;
-            }
-
-            blockDone += blockCountOneTime;
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-static status_t SD_ProbeBusVoltage(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t applicationCommand41Argument = 0U;
-    status_t error                        = kStatus_Success;
-
-    /* 3.3V voltage should be supported as default */
-    applicationCommand41Argument |=
-        SDMMC_MASK(kSD_OcrVdd29_30Flag) | SDMMC_MASK(kSD_OcrVdd32_33Flag) | SDMMC_MASK(kSD_OcrVdd33_34Flag);
-
-    if ((card->usrParam.ioVoltage != NULL) && (card->usrParam.ioVoltage->type != kSD_IOVoltageCtrlNotSupport) &&
-        ((card->host->capability & (uint32_t)kSDMMCHOST_SupportVoltage1v8) != 0U) &&
-        ((card->host->capability & ((uint32_t)kSDMMCHOST_SupportSDR104 | (uint32_t)kSDMMCHOST_SupportSDR50 |
-                                    (uint32_t)kSDMMCHOST_SupportDDRMode)) != 0U))
-    {
-        /* allow user select the work voltage, if not select, sdmmc will handle it automatically */
-        applicationCommand41Argument |= SDMMC_MASK(kSD_OcrSwitch18RequestFlag);
-        /* reset to 3v3 signal voltage */
-        if (SD_SwitchIOVoltage(card, kSDMMC_OperationVoltage330V) == kStatus_Success)
-        {
-            /* Host changed the operation signal voltage successfully, then card need power reset */
-            SD_SetCardPower(card, false);
-            SD_SetCardPower(card, true);
-        }
-    }
-
-    card->operationVoltage = kSDMMC_OperationVoltage330V;
-
-    /* send card active */
-    SDMMCHOST_SendCardActive(card->host);
-
-    do
-    {
-        /* card go idle */
-        if (kStatus_Success != SD_GoIdle(card))
-        {
-            error = kStatus_SDMMC_GoIdleFailed;
-            break;
-        }
-
-        error = SD_SendInterfaceCondition(card);
-        /* Check card's supported interface condition. */
-        if (kStatus_Success == error)
-        {
-            /* SDHC or SDXC card */
-            applicationCommand41Argument |= SDMMC_MASK(kSD_OcrHostCapacitySupportFlag);
-            card->flags |= (uint32_t)kSD_SupportSdhcFlag;
-        }
-        else
-        {
-            /* SDSC card */
-            if (kStatus_Success != SD_GoIdle(card))
-            {
-                error = kStatus_SDMMC_GoIdleFailed;
-                break;
-            }
-        }
-        error = SD_ApplicationSendOperationCondition(card, applicationCommand41Argument);
-        /* Set card interface condition according to SDHC capability and card's supported interface condition. */
-        if (kStatus_Success != error)
-        {
-            error = kStatus_SDMMC_HandShakeOperationConditionFailed;
-            break;
-        }
-
-        /* check if card support 1.8V */
-        if ((card->flags & (uint32_t)kSD_SupportVoltage180v) != 0U)
-        {
-            if ((card->usrParam.ioVoltage != NULL) && (card->usrParam.ioVoltage->type == kSD_IOVoltageCtrlNotSupport))
-            {
-                break;
-            }
-
-            error = SD_SwitchVoltage(card, kSDMMC_OperationVoltage180V);
-            if (kStatus_SDMMC_SwitchVoltageFail == error)
-            {
-                break;
-            }
-
-            if (error == kStatus_SDMMC_SwitchVoltage18VFail33VSuccess)
-            {
-                applicationCommand41Argument &= ~SDMMC_MASK(kSD_OcrSwitch18RequestFlag);
-                card->flags &= ~(uint32_t)kSD_SupportVoltage180v;
-                continue;
-            }
-            else
-            {
-                card->operationVoltage = kSDMMC_OperationVoltage180V;
-                break;
-            }
-        }
-        break;
-    } while (true);
-
-    return error;
-}
-
-static status_t sdcard_init(sd_card_t *card)
-{
-    assert(card != NULL);
-    assert(card->isHostReady == true);
-    status_t error = kStatus_Success;
-
-    /* reset variables */
-    card->flags = 0U;
-    /* set DATA bus width */
-    SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith1Bit);
-    /*set card freq to 400KHZ*/
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, SDMMC_CLOCK_400KHZ);
-
-    error = SD_ProbeBusVoltage(card);
-    /* probe bus voltage*/
-    if (error != kStatus_Success)
-    {
-        return kStatus_SDMMC_SwitchVoltageFail;
-    }
-
-    error = SD_AllSendCid(card);
-    /* Initialize card if the card is SD card. */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_AllSendCidFailed;
-    }
-
-    error = SD_SendRca(card);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SendRelativeAddressFailed;
-    }
-
-    error = SD_SendCsd(card);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SendCsdFailed;
-    }
-
-    error = SD_SelectCard(card, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SelectCardFailed;
-    }
-
-    /* Set to max frequency in non-high speed mode. */
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, SD_CLOCK_25MHZ);
-
-    error = SD_SendScr(card);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SendScrFailed;
-    }
-
-    /* Set to 4-bit data bus mode. */
-    if ((card->flags & (uint32_t)kSD_Support4BitWidthFlag) != 0U)
-    {
-        error = SD_SetDataBusWidth(card, kSDMMC_BusWdith4Bit);
-        if (kStatus_Success != error)
-        {
-            return kStatus_SDMMC_SetDataBusWidthFailed;
-        }
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith4Bit);
-    }
-
-    /* try to get card current status */
-    error = SD_ReadStatus(card);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SendScrFailed;
-    }
-
-    error = SD_SetBlockSize(card, FSL_SDMMC_DEFAULT_BLOCK_SIZE);
-    /* set block size */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SetCardBlockSizeFailed;
-    }
-
-    error = SD_SelectBusTiming(card);
-    /* select bus timing */
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SwitchBusTimingFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SD_CardInit(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-    /* create mutex lock */
-    (void)SDMMC_OSAMutexCreate(&card->lock);
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    SD_SetCardPower(card, true);
-
-    error = sdcard_init(card);
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-void SD_CardDeinit(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    (void)SD_SelectCard(card, false);
-    SD_HostDoReset(card);
-    SD_SetCardPower(card, false);
-    (void)SDMMC_OSAMutexDestroy(&card->lock);
-}
-
-status_t SD_HostInit(sd_card_t *card)
-{
-    assert(card != NULL);
-    assert(card->usrParam.cd != NULL);
-
-    status_t error = kStatus_Success;
-
-    if (!card->isHostReady)
-    {
-        error = SDMMCHOST_Init(card->host);
-        if (error != kStatus_Success)
-        {
-            return kStatus_Fail;
-        }
-    }
-
-    if ((card->usrParam.cd->type == kSD_DetectCardByHostCD) || (card->usrParam.cd->type == kSD_DetectCardByHostDATA3))
-    {
-        (void)SDMMCHOST_CardDetectInit(card->host, card->usrParam.cd);
-    }
-
-    /* set the host status flag, after the card re-plug in, don't need init host again */
-    card->isHostReady = true;
-
-    return kStatus_Success;
-}
-
-void SD_HostDeinit(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    SDMMCHOST_Deinit(card->host);
-    /* should re-init host */
-    card->isHostReady = false;
-}
-
-void SD_SetCardPower(sd_card_t *card, bool enable)
-{
-    assert(card != NULL);
-
-    uint32_t powerDelay = 0U;
-
-    if (card->usrParam.pwr != NULL)
-    {
-        card->usrParam.pwr(enable);
-    }
-    else
-    {
-        SDMMCHOST_SetCardPower(card->host, enable);
-    }
-
-    if (enable)
-    {
-        powerDelay = card->usrParam.powerOnDelayMS == 0U ? SD_POWER_ON_DELAY : card->usrParam.powerOnDelayMS;
-    }
-    else
-    {
-        powerDelay = card->usrParam.powerOffDelayMS == 0U ? SD_POWER_OFF_DELAY : card->usrParam.powerOffDelayMS;
-    }
-
-    SDMMC_OSADelay(powerDelay);
-}
-
-bool SD_IsCardPresent(sd_card_t *card)
-{
-    assert(card != NULL);
-    assert(card->usrParam.cd != NULL);
-
-    if (card->usrParam.cd->type == kSD_DetectCardByGpioCD)
-    {
-        if (card->usrParam.cd->cardDetected == NULL)
-        {
-            return false;
-        }
-        return card->usrParam.cd->cardDetected();
-    }
-    else
-    {
-        if (card->isHostReady == false)
-        {
-            return false;
-        }
-
-        if (SDMMCHOST_CardDetectStatus(card->host) == (uint32_t)kSD_Removed)
-        {
-            return false;
-        }
-    }
-
-    return true;
-}
-
-status_t SD_PollingCardInsert(sd_card_t *card, uint32_t status)
-{
-    assert(card != NULL);
-    assert(card->usrParam.cd != NULL);
-
-    if (card->usrParam.cd->type == kSD_DetectCardByGpioCD)
-    {
-        if (card->usrParam.cd->cardDetected == NULL)
-        {
-            return kStatus_Fail;
-        }
-
-        do
-        {
-            if ((card->usrParam.cd->cardDetected() == true) && (status == (uint32_t)kSD_Inserted))
-            {
-                SDMMC_OSADelay(card->usrParam.cd->cdDebounce_ms);
-                if (card->usrParam.cd->cardDetected() == true)
-                {
-                    break;
-                }
-            }
-
-            if ((card->usrParam.cd->cardDetected() == false) && (status == (uint32_t)kSD_Removed))
-            {
-                break;
-            }
-        } while (true);
-    }
-    else
-    {
-        if (card->isHostReady == false)
-        {
-            return kStatus_Fail;
-        }
-
-        if (SDMMCHOST_PollingCardDetectStatus(card->host, status, ~0U) != kStatus_Success)
-        {
-            return kStatus_Fail;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-status_t SD_Init(sd_card_t *card)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-
-    if (!card->isHostReady)
-    {
-        error = SD_HostInit(card);
-        if (error != kStatus_Success)
-        {
-            error = kStatus_SDMMC_HostNotReady;
-        }
-    }
-    else
-    {
-        SD_HostDoReset(card);
-    }
-
-    if (kStatus_Success == error)
-    {
-        if (SD_PollingCardInsert(card, kSD_Inserted) != kStatus_Success)
-        {
-            error = kStatus_SDMMC_CardDetectFailed;
-        }
-        else
-        {
-            error = SD_CardInit(card);
-            if (error != kStatus_Success)
-            {
-                error = kStatus_SDMMC_CardInitFailed;
-            }
-        }
-    }
-
-    return error;
-}
-
-void SD_Deinit(sd_card_t *card)
-{
-    /* card deinitialize */
-    SD_CardDeinit(card);
-    /* host deinitialize */
-    SD_HostDeinit(card);
-}
-
-void SD_HostDoReset(sd_card_t *card)
-{
-    SDMMCHOST_Reset(card->host);
-}

+ 0 - 349
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sd/fsl_sd.h

@@ -1,349 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2019 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _FSL_SD_H_
-#define _FSL_SD_H_
-
-#include "fsl_sdmmc_common.h"
-/*!
- * @addtogroup sdcard SD Card Driver
- * @ingroup card
- * @{
- */
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*! @brief Driver version. */
-#define FSL_SD_DRIVER_VERSION (MAKE_VERSION(2U, 4U, 0U)) /*2.4.0*/
-
-/*! @brief SD card flags
- * @anchor _sd_card_flag
- */
-enum
-{
-    kSD_SupportHighCapacityFlag     = (1U << 1U), /*!< Support high capacity */
-    kSD_Support4BitWidthFlag        = (1U << 2U), /*!< Support 4-bit data width */
-    kSD_SupportSdhcFlag             = (1U << 3U), /*!< Card is SDHC */
-    kSD_SupportSdxcFlag             = (1U << 4U), /*!< Card is SDXC */
-    kSD_SupportVoltage180v          = (1U << 5U), /*!< card support 1.8v voltage*/
-    kSD_SupportSetBlockCountCmd     = (1U << 6U), /*!< card support cmd23 flag*/
-    kSD_SupportSpeedClassControlCmd = (1U << 7U), /*!< card support speed class control flag */
-};
-
-/*!
- * @brief SD card state
- *
- * Define the card structure including the necessary fields to identify and describe the card.
- */
-typedef struct _sd_card
-{
-    sdmmchost_t *host; /*!< Host configuration */
-
-    sd_usr_param_t usrParam; /*!< user parameter */
-    bool isHostReady;        /*!< use this flag to indicate if need host re-init or not*/
-
-    bool noInteralAlign;      /*!< used to enable/disable the functionality of the exchange buffer */
-    uint32_t busClock_Hz;     /*!< SD bus clock frequency united in Hz */
-    uint32_t relativeAddress; /*!< Relative address of the card */
-    uint32_t version;         /*!< Card version */
-    uint32_t flags;           /*!< Flags in _sd_card_flag */
-    uint8_t internalBuffer[FSL_SDMMC_CARD_INTERNAL_BUFFER_SIZE]; /*!< internal buffer */
-    uint32_t ocr;                                                /*!< Raw OCR content */
-    sd_cid_t cid;                                                /*!< CID */
-    sd_csd_t csd;                                                /*!< CSD */
-    sd_scr_t scr;                                                /*!< SCR */
-    sd_status_t stat;                                            /*!< sd 512 bit status */
-    uint32_t blockCount;                                         /*!< Card total block number */
-    uint32_t blockSize;                                          /*!< Card block size */
-    sd_timing_mode_t currentTiming;                              /*!< current timing mode */
-    sd_driver_strength_t driverStrength;                         /*!< driver strength */
-    sd_max_current_t maxCurrent;                                 /*!< card current limit */
-    sdmmc_operation_voltage_t operationVoltage;                  /*!< card operation voltage */
-    sdmmc_osa_mutex_t lock;                                      /*!< card access lock */
-} sd_card_t;
-
-/*************************************************************************************************
- * API
- ************************************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/*!
- * @name SDCARD Function
- * @{
- */
-
-/*!
- * @brief Initializes the card on a specific host controller.
- * This function initializes the card on a specific host controller, it is consist of
- * host init, card detect, card init function, however user can ignore this high level function,
- * instead of use the low level function, such as SD_CardInit, SD_HostInit, SD_CardDetect.
- *
- * Thread safe function, please note that the function will create the mutex lock dynamically by default,
- * so to avoid the mutex create redundantly, application must follow bellow sequence for card re-initialization
- * @code
- * SD_Deinit(card);
- * SD_Init(card);
- * @endcode
- *
- * @param card Card descriptor.
- * @retval #kStatus_SDMMC_HostNotReady host is not ready.
- * @retval #kStatus_SDMMC_GoIdleFailed Go idle failed.
- * @retval #kStatus_SDMMC_NotSupportYet Card not support.
- * @retval #kStatus_SDMMC_HandShakeOperationConditionFailed Send operation condition failed.
- * @retval #kStatus_SDMMC_AllSendCidFailed Send CID failed.
- * @retval #kStatus_SDMMC_SendRelativeAddressFailed Send relative address failed.
- * @retval #kStatus_SDMMC_SendCsdFailed Send CSD failed.
- * @retval #kStatus_SDMMC_SelectCardFailed Send SELECT_CARD command failed.
- * @retval #kStatus_SDMMC_SendScrFailed Send SCR failed.
- * @retval #kStatus_SDMMC_SetDataBusWidthFailed Set bus width failed.
- * @retval #kStatus_SDMMC_SwitchBusTimingFailed Switch high speed failed.
- * @retval #kStatus_SDMMC_SetCardBlockSizeFailed Set card block size failed.
- * @retval #kStatus_Success Operate successfully.
- */
-status_t SD_Init(sd_card_t *card);
-
-/*!
- * @brief Deinitializes the card.
- * This function deinitializes the specific card and host.
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- */
-void SD_Deinit(sd_card_t *card);
-
-/*!
- * @brief Initializes the card.
- *
- * This function initializes the card only, make sure the host is ready when call this function,
- * otherwise it will return kStatus_SDMMC_HostNotReady.
- *
- * Thread safe function, please note that the function will create the mutex lock dynamically by default,
- * so to avoid the mutex create redundantly, application must follow bellow sequence for card re-initialization
- * @code
- * SD_CardDeinit(card);
- * SD_CardInit(card);
- * @endcode
- *
- * @param card Card descriptor.
- * @retval #kStatus_SDMMC_HostNotReady host is not ready.
- * @retval #kStatus_SDMMC_GoIdleFailed Go idle failed.
- * @retval #kStatus_SDMMC_NotSupportYet Card not support.
- * @retval #kStatus_SDMMC_HandShakeOperationConditionFailed Send operation condition failed.
- * @retval #kStatus_SDMMC_AllSendCidFailed Send CID failed.
- * @retval #kStatus_SDMMC_SendRelativeAddressFailed Send relative address failed.
- * @retval #kStatus_SDMMC_SendCsdFailed Send CSD failed.
- * @retval #kStatus_SDMMC_SelectCardFailed Send SELECT_CARD command failed.
- * @retval #kStatus_SDMMC_SendScrFailed Send SCR failed.
- * @retval #kStatus_SDMMC_SetDataBusWidthFailed Set bus width failed.
- * @retval #kStatus_SDMMC_SwitchBusTimingFailed Switch high speed failed.
- * @retval #kStatus_SDMMC_SetCardBlockSizeFailed Set card block size failed.
- * @retval #kStatus_Success Operate successfully.
- */
-status_t SD_CardInit(sd_card_t *card);
-
-/*!
- * @brief Deinitializes the card.
- *
- * This function deinitializes the specific card.
- * Please note it is a thread safe function.
- *
- *
- * @param card Card descriptor.
- */
-void SD_CardDeinit(sd_card_t *card);
-
-/*!
- * @brief initialize the host.
- *
- * This function deinitializes the specific host.
- *
- * @param card Card descriptor.
- */
-status_t SD_HostInit(sd_card_t *card);
-
-/*!
- * @brief Deinitializes the host.
- *
- * This function deinitializes the host.
- *
- * @param card Card descriptor.
- */
-void SD_HostDeinit(sd_card_t *card);
-
-/*!
- * @brief reset the host.
- *
- * This function reset the specific host.
- *
- * @param card Card descriptor.
- */
-void SD_HostDoReset(sd_card_t *card);
-
-/*!
- * @brief set card power.
- *
- * The power off operation depend on host or the user define power on function.
- * @param card card descriptor.
- * @param enable true is power on, false is power off.
- */
-void SD_SetCardPower(sd_card_t *card, bool enable);
-
-/*!
- * @brief sd wait card detect function.
- *
- * Detect card through GPIO, CD, DATA3.
- * @param card card descriptor.
- * @param status detect status, kSD_Inserted or kSD_Removed.
- */
-status_t SD_PollingCardInsert(sd_card_t *card, uint32_t status);
-
-/*!
- * @brief sd card present check function.
- *
- * @param card card descriptor.
- */
-bool SD_IsCardPresent(sd_card_t *card);
-
-/*!
- * @brief Checks whether the card is write-protected.
- *
- * This function checks if the card is write-protected via the CSD register.
- *
- * @param card The specific card.
- * @retval true Card is read only.
- * @retval false Card isn't read only.
- */
-bool SD_CheckReadOnly(sd_card_t *card);
-
-/*!
- * @brief Send SELECT_CARD command to set the card to be transfer state or not.
- *
- * @param card Card descriptor.
- * @param isSelected True to set the card into transfer state, false to disselect.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_Success Operate successfully.
- */
-status_t SD_SelectCard(sd_card_t *card, bool isSelected);
-
-/*!
- * @brief Send ACMD13 to get the card current status.
- *
- * @param card Card descriptor.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_SDMMC_SendApplicationCommandFailed send application command failed.
- * @retval #kStatus_Success Operate successfully.
- */
-status_t SD_ReadStatus(sd_card_t *card);
-
-/*!
- * @brief Reads blocks from the specific card.
- *
- * This function reads blocks from the specific card with default block size defined by the
- * SDHC_CARD_DEFAULT_BLOCK_SIZE.
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- * @param buffer The buffer to save the data read from card.
- * @param startBlock The start block index.
- * @param blockCount The number of blocks to read.
- * @retval #kStatus_InvalidArgument Invalid argument.
- * @retval #kStatus_SDMMC_CardNotSupport Card not support.
- * @retval #kStatus_SDMMC_NotSupportYet Not support now.
- * @retval #kStatus_SDMMC_WaitWriteCompleteFailed Send status failed.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_SDMMC_StopTransmissionFailed Stop transmission failed.
- * @retval #kStatus_Success Operate successfully.
- */
-status_t SD_ReadBlocks(sd_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockCount);
-
-/*!
- * @brief Writes blocks of data to the specific card.
- *
- * This function writes blocks to the specific card with default block size 512 bytes.
- *
- * Please note,
- * 1. It is a thread safe function.
- * 2. It is a async write function which means that the card status may still busy after the function return.
- * Application can call function SD_PollingCardStatusBusy to wait card status idle after the write operation.
- *
- * @param card Card descriptor.
- * @param buffer The buffer holding the data to be written to the card.
- * @param startBlock The start block index.
- * @param blockCount The number of blocks to write.
- * @retval #kStatus_InvalidArgument Invalid argument.
- * @retval #kStatus_SDMMC_NotSupportYet Not support now.
- * @retval #kStatus_SDMMC_CardNotSupport Card not support.
- * @retval #kStatus_SDMMC_WaitWriteCompleteFailed Send status failed.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_SDMMC_StopTransmissionFailed Stop transmission failed.
- * @retval #kStatus_Success Operate successfully.
- */
-status_t SD_WriteBlocks(sd_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockCount);
-
-/*!
- * @brief Erases blocks of the specific card.
- *
- * This function erases blocks of the specific card with default block size 512 bytes.
- *
- * Please note,
- * 1. It is a thread safe function.
- * 2. It is a async erase function which means that the card status may still busy after the function return.
- * Application can call function SD_PollingCardStatusBusy to wait card status idle after the erase operation.
- *
- * @param card Card descriptor.
- * @param startBlock The start block index.
- * @param blockCount The number of blocks to erase.
- * @retval #kStatus_InvalidArgument Invalid argument.
- * @retval #kStatus_SDMMC_WaitWriteCompleteFailed Send status failed.
- * @retval #kStatus_SDMMC_TransferFailed Transfer failed.
- * @retval #kStatus_SDMMC_WaitWriteCompleteFailed Send status failed.
- * @retval #kStatus_Success Operate successfully.
- */
-status_t SD_EraseBlocks(sd_card_t *card, uint32_t startBlock, uint32_t blockCount);
-
-/*!
- * @brief select card driver strength
- * select card driver strength
- * @param card Card descriptor.
- * @param driverStrength Driver strength
- */
-status_t SD_SetDriverStrength(sd_card_t *card, sd_driver_strength_t driverStrength);
-
-/*!
- * @brief select max current
- * select max operation current
- * @param card Card descriptor.
- * @param maxCurrent Max current
- */
-status_t SD_SetMaxCurrent(sd_card_t *card, sd_max_current_t maxCurrent);
-
-/*!
- * @brief Polling card idle status.
- *
- * This function can be used to polling the status from busy to Idle, the function will return if the card
- * status idle or timeout.
- *
- * @param card Card descriptor.
- * @param timeoutMs polling card status timeout value.
- * @retval kStatus_Success Operate successfully.
- * @retval kStatus_SDMMC_WaitWriteCompleteFailed CMD13 transfer failed.
- * @retval kStatus_SDMMC_PollingCardIdleFailed, polling card DAT0 idle failed.
- */
-status_t SD_PollingCardStatusBusy(sd_card_t *card, uint32_t timeoutMs);
-
-/* @} */
-
-#if defined(__cplusplus)
-}
-#endif
-/*! @} */
-#endif /* _FSL_SD_H_*/

+ 0 - 98
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sdio/ChangeLogKSDK.txt

@@ -1,98 +0,0 @@
-/*!
-@page middleware_log Middleware Change Log
-
-@section sdio SDIO Card driver for MCUXpresso SDK
-The current driver version is 2.4.0.
-
-  - 2.4.0
-    - Improvements
-      - Removed deprecated api in sdio driver.
-      - Improved the signal line voltage switch flow.
-      - Added powerOnDelayMS/powerOffDelayMS in sdio_usr_param_t to allow redefine the default power on/off delay.
-      - Added mutual exclusive access for init/deinit/direct/extend function.
-      - Fixed violations of MISRA C-2012 rule 4.7, 17.7, 10.1, 12.2.
-
-  - 2.3.3
-    - Bug Fixes
-      - Fixed logical dead code coverity issue.
-    - Improvements
-      - Removed deprecated api in sdio driver.
-
-  - 2.3.2
-    - Improvements
-      - Added host SDR timing mode capability validation during card initialization.
-      - Used cache line size align buffer for SDIO initialization api.
-    - Bug Fixes
-      - Fixed violations of MISRA C-2012 rule 11.9, 15.7, 4.7, 16.4, 10.1, 10.3, 10.4, 11.3, 14.4, 10.6, 17.7, 16.1, 16.3.
-
-  - 2.3.1
-    - Improvements
-      - Moved power off function after card detect in SD_Init for DAT3 detect card feature.
-
-  - 2.3.0
-    - Improvements
-      - Marked api SDIO_HostReset/SDIO_PowerOnCard/SDIO_PowerOffCard/SDIO_WaitCardDetectStatus as deprecated.
-      - Added new api SDIO_SetCardPower/SDIO_PollingCardDetectStatus/SDIO_HostDoReset.
-      - Added internalBuffer in sdio_card_t for card register content extract and improve the data access efficiency.
-      - Added retry function after switch to target timing failed in SDIO_SelectBusTiming.
-      - Changed defalut bus clock from 400KHZ to 25MHZ.
-
-  - 2.2.13
-    - Improvements
-      - Removed the sdio card interrupt from sdio host initialization, since the card interrupt enablement should be determined by application.
-    - Bug Fixes
-      - Fixed Out-of-bounds write Coverity issue.
-
-  - 2.2.12
-    - Improvements
-      - Added manual tuning function for looking for the tuning window automatically.
-      - Fixed the build warning by changing the old style function declaration static
-        status_t inline to static inline status_t(found by adding
-        -Wold-style-declaration in armgcc build flag).
-      - Fixed the fall through build warning by adding SUPPRESS_FALL_THROUGH_WARNING() in sdio driver.
-
-  - 2.2.11
-    - Bug Fixes
-      - Added check card async interrupt capability in function
-	      SDIO_GetCardCapability.
-      - Fixed OUT OF BOUNDS access in function SDIO_IO_Transfer.
-
-  - 2.2.10
-    - Bug Fixes
-      - Fixed SDIO card driver get an incorrect io number when the card io number is
-        bigger than 2.
-    - Improvements
-      - Added SDIO 3.0 support.
-      - Added API SDIO_IO_RW_Direct for direct read/write card register access.
-
-  - 2.2.9
-    - Improvements
-      - Added API SDIO_SetIOIRQHandler/SDIO_HandlePendingIOInterrupt to handle multi io pending IRQ.
-
-  - 2.2.8
-    - Improvements
-      - Updated sdmmc to support SDIO interrupt.
-      - Added API SDIO_GetPendingInterrupt to get the pending io interrupt.
-
-  - 2.2.7
-    - Bug Fixes
-      - Fixed MDK 66-D warning.
-
-  - 2.2.6
-    - Improvements
-      - Added an unify transfer interface for SDIO.
-    - Bug Fixes
-      - Fixed Wrong pointer address used by SDMMCHOST_Init.
-
-  - 2.1.5
-    - Improvements
-      - Improved SDIO card init sequence and add retry option for SDIO_SwitchToHighSpeed function.
-
-  - 2.1.4
-    - Improvements
-      - Added Go_Idle function for SDIO card.
-
-  - 2.0.0
-    - Initial version.
-
-*/

+ 0 - 2109
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sdio/fsl_sdio.c

@@ -1,2109 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "fsl_sdio.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*! @brief define the tuple number will be read during init */
-#define SDIO_COMMON_CIS_TUPLE_NUM (3U)
-/*! @brief SDIO retry times */
-#define SDIO_RETRY_TIMES (1000U)
-/*!@brief power reset delay */
-/*!@brief power reset delay */
-#define SDIO_POWER_ON_DELAY  (400U)
-#define SDIO_POWER_OFF_DELAY (100U)
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-/*!
- * @brief probe bus voltage.
- * @param card Card descriptor.
- */
-static status_t SDIO_ProbeBusVoltage(sdio_card_t *card);
-
-/*!
- * @brief send card operation condition
- * @param card Card descriptor.
- * @param command argment
- * @param accept1V8 flag indicate card acccpt 1v8 switch or not
- *  argument = 0U , means to get the operation condition
- *  argument !=0 , set the operation condition register
- */
-static status_t SDIO_SendOperationCondition(sdio_card_t *card, uint32_t argument, uint32_t *accept1V8);
-
-/*!
- * @brief card Send relative address
- * @param card Card descriptor.
- */
-static status_t SDIO_SendRca(sdio_card_t *card);
-
-/*!
- * @brief card select card
- * @param card Card descriptor.
- * @param select/diselect flag
- */
-static inline status_t SDIO_SelectCard(sdio_card_t *card, bool isSelected);
-
-/*!
- * @brief card go idle
- * @param card Card descriptor.
- */
-static inline status_t SDIO_GoIdle(sdio_card_t *card);
-
-/*!
- * @brief decode CIS
- * @param card Card descriptor.
- * @param func number
- * @param data buffer pointer
- * @param tuple code
- * @param tuple link
- */
-static status_t SDIO_DecodeCIS(
-    sdio_card_t *card, sdio_func_num_t func, uint8_t *dataBuffer, uint32_t tplCode, uint32_t tplLink);
-
-/*!
- * @brief switch to the maxium support bus width, depend on the host and card's capability.
- * @param card Card descriptor.
- */
-static status_t SDIO_SetMaxDataBusWidth(sdio_card_t *card);
-
-/*!
- * @brief sdio card excute tuning.
- * @param card Card descriptor.
- */
-static status_t SDIO_ExecuteTuning(sdio_card_t *card);
-
-/*!
- * @brief sdio io access direct
- * @param card Card descriptor.
- * @param direction access direction.
- * @param func number
- * @param regAddr register address.
- * @param dataIn data to write
- * @param dataOut data address for read
- * @param rawFlag read after write flag, it is used for write access only.
- */
-static status_t SDIO_IO_Access_Direct(sdio_card_t *card,
-                                      sdio_io_direction_t direction,
-                                      sdio_func_num_t func,
-                                      uint32_t regAddr,
-                                      uint8_t dataIn,
-                                      uint8_t *dataOut,
-                                      bool rawFlag);
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-/* define the tuple list */
-static const uint32_t s_tupleList[SDIO_COMMON_CIS_TUPLE_NUM] = {
-    SDIO_TPL_CODE_MANIFID,
-    SDIO_TPL_CODE_FUNCID,
-    SDIO_TPL_CODE_FUNCE,
-};
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-static inline status_t SDIO_SelectCard(sdio_card_t *card, bool isSelected)
-{
-    assert(card != NULL);
-
-    return SDMMC_SelectCard(card->host, card->relativeAddress, isSelected);
-}
-
-static inline status_t SDIO_GoIdle(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    return SDMMC_GoIdle(card->host);
-}
-
-static status_t SDIO_SwitchIOVoltage(sdio_card_t *card, sdmmc_operation_voltage_t voltage)
-{
-    if ((card->usrParam.ioVoltage != NULL) && (card->usrParam.ioVoltage->type == kSD_IOVoltageCtrlByGpio))
-    {
-        /* make sure card signal line voltage is 3.3v before initalization */
-        if (card->usrParam.ioVoltage->func != NULL)
-        {
-            card->usrParam.ioVoltage->func(voltage);
-        }
-    }
-    else if ((card->usrParam.ioVoltage != NULL) && (card->usrParam.ioVoltage->type == kSD_IOVoltageCtrlByHost))
-    {
-        SDMMCHOST_SwitchToVoltage(card->host, (uint32_t)voltage);
-    }
-    else
-    {
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t SDIO_SwitchVoltage(sdio_card_t *card, sdmmc_operation_voltage_t voltage)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSD_VoltageSwitch;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR1;
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* check data line and cmd line status */
-    if (SDMMCHOST_GetSignalLineStatus(card->host, (uint32_t)kSDMMC_SignalLineData0 | (uint32_t)kSDMMC_SignalLineData1 |
-                                                      (uint32_t)kSDMMC_SignalLineData2 |
-                                                      (uint32_t)kSDMMC_SignalLineData3) != 0U)
-    {
-        return kStatus_SDMMC_SwitchVoltageFail;
-    }
-
-    /* switch io voltage */
-    if (SDIO_SwitchIOVoltage(card, voltage) == kStatus_SDMMC_NotSupportYet)
-    {
-        return kStatus_SDMMC_SwitchVoltageFail;
-    }
-
-    SDMMC_OSADelay(100U);
-
-    /*enable force clock on*/
-    SDMMCHOST_ForceClockOn(card->host, true);
-    /* dealy 1ms,not exactly correct when use while */
-    SDMMC_OSADelay(10U);
-    /*disable force clock on*/
-    SDMMCHOST_ForceClockOn(card->host, false);
-
-    /* check data line and cmd line status */
-    if (SDMMCHOST_GetSignalLineStatus(card->host, (uint32_t)kSDMMC_SignalLineData0 | (uint32_t)kSDMMC_SignalLineData1 |
-                                                      (uint32_t)kSDMMC_SignalLineData2 |
-                                                      (uint32_t)kSDMMC_SignalLineData3) == 0U)
-    {
-        error = kStatus_SDMMC_SwitchVoltageFail;
-        /* power reset the card */
-        SDIO_SetCardPower(card, false);
-        SDIO_SetCardPower(card, true);
-        /* re-check the data line status */
-        if (SDMMCHOST_GetSignalLineStatus(
-                card->host, (uint32_t)kSDMMC_SignalLineData0 | (uint32_t)kSDMMC_SignalLineData1 |
-                                (uint32_t)kSDMMC_SignalLineData2 | (uint32_t)kSDMMC_SignalLineData3) != 0U)
-        {
-            error = kStatus_SDMMC_SwitchVoltage18VFail33VSuccess;
-            SDMMC_LOG("\r\nNote: Current card support 1.8V, but board don't support, so sdmmc switch back to 3.3V.");
-        }
-        else
-        {
-            SDMMC_LOG(
-                "\r\nError: Current card support 1.8V, but board don't support, sdmmc tried to switch back\
-                    to 3.3V, but failed, please check board setting.");
-        }
-    }
-
-    return error;
-}
-
-static status_t SDIO_ExecuteTuning(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    return SDMMCHOST_ExecuteTuning(card->host, (uint32_t)kSD_SendTuningBlock,
-                                   (uint32_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer), 64U);
-}
-
-static status_t SDIO_SendRca(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t i = FSL_SDMMC_MAX_CMD_RETRIES;
-
-    sdmmchost_transfer_t content = {0};
-    sdmmchost_cmd_t command      = {0};
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDIO_SendRelativeAddress;
-    command.argument     = 0U;
-    command.responseType = kCARD_ResponseTypeR6;
-    command.responseErrorFlags =
-        (uint32_t)kSDIO_StatusR6Error | (uint32_t)kSDIO_StatusIllegalCmd | (uint32_t)kSDIO_StatusCmdCRCError;
-
-    content.command = &command;
-    content.data    = NULL;
-
-    while (--i != 0U)
-    {
-        error = SDMMCHOST_TransferFunction(card->host, &content);
-        if (kStatus_Success == error)
-        {
-            /* check illegal state and cmd CRC error, may be the voltage or clock not stable, retry the cmd*/
-            if ((command.response[0U] & ((uint32_t)kSDIO_StatusIllegalCmd | (uint32_t)kSDIO_StatusCmdCRCError)) != 0U)
-            {
-                continue;
-            }
-
-            card->relativeAddress = (command.response[0U] >> 16U);
-
-            return kStatus_Success;
-        }
-    }
-
-    return kStatus_SDMMC_TransferFailed;
-}
-
-status_t SDIO_CardInActive(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    return SDMMC_SetCardInactive(card->host);
-}
-
-static status_t SDIO_SendOperationCondition(sdio_card_t *card, uint32_t argument, uint32_t *accept1V8)
-{
-    assert(card != NULL);
-
-    sdmmchost_transfer_t content = {0U};
-    sdmmchost_cmd_t command      = {0U};
-    uint32_t i                   = SDIO_RETRY_TIMES;
-    status_t error               = kStatus_Success;
-
-    command.index        = (uint32_t)kSDIO_SendOperationCondition;
-    command.argument     = argument;
-    command.responseType = kCARD_ResponseTypeR4;
-
-    content.command = &command;
-    content.data    = NULL;
-
-    while (--i != 0U)
-    {
-        error = SDMMCHOST_TransferFunction(card->host, &content);
-        if ((kStatus_Success != error) || (command.response[0U] == 0U))
-        {
-            continue;
-        }
-
-        /* if argument equal 0, then should check and save the info */
-        if ((argument != 0U) && ((command.response[0U] & SDMMC_MASK(kSDIO_OcrPowerUpBusyFlag)) == 0U))
-        {
-            continue;
-        }
-        else if (argument == 0U)
-        {
-            /* check the io number and ocr value */
-            if ((((command.response[0U] & SDIO_OCR_IO_NUM_MASK) >> kSDIO_OcrIONumber) == 0U) ||
-                ((command.response[0U] & 0xFFFFFFU) == 0U))
-            {
-                return kStatus_Fail;
-            }
-
-            break;
-        }
-        else
-        {
-            /* check if memory present */
-            if ((command.response[0U] & SDMMC_MASK(kSDIO_OcrMemPresent)) == SDMMC_MASK(kSDIO_OcrMemPresent))
-            {
-                card->memPresentFlag = true;
-            }
-            /* save the io number */
-            card->ioTotalNumber = (uint8_t)((command.response[0U] & SDIO_OCR_IO_NUM_MASK) >> kSDIO_OcrIONumber);
-            /* save the operation condition */
-            card->ocr = command.response[0U] & 0xFFFFFFU;
-            if (accept1V8 != NULL)
-            {
-                *accept1V8 = command.response[0U] & 0x1000000U;
-            }
-
-            break;
-        }
-    }
-
-    return ((i != 0U) ? kStatus_Success : kStatus_Fail);
-}
-
-static status_t SDIO_IO_Access_Direct(sdio_card_t *card,
-                                      sdio_io_direction_t direction,
-                                      sdio_func_num_t func,
-                                      uint32_t regAddr,
-                                      uint8_t dataIn,
-                                      uint8_t *dataOut,
-                                      bool rawFlag)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    sdmmchost_transfer_t content = {0U};
-    sdmmchost_cmd_t command      = {0U};
-    status_t error               = kStatus_Success;
-
-    command.index    = (uint32_t)kSDIO_RWIODirect;
-    command.argument = ((uint32_t)func << SDIO_CMD_ARGUMENT_FUNC_NUM_POS) |
-                       ((regAddr & SDIO_CMD_ARGUMENT_REG_ADDR_MASK) << SDIO_CMD_ARGUMENT_REG_ADDR_POS);
-
-    if ((dataOut != NULL) && (direction == kSDIO_IOWrite))
-    {
-        command.argument |= (1UL << SDIO_CMD_ARGUMENT_RW_POS) | ((uint32_t)rawFlag << SDIO_DIRECT_CMD_ARGUMENT_RAW_POS);
-    }
-
-    if (direction == kSDIO_IOWrite)
-    {
-        command.argument |= (uint32_t)dataIn & SDIO_DIRECT_CMD_DATA_MASK;
-    }
-
-    command.responseType = kCARD_ResponseTypeR5;
-    command.responseErrorFlags =
-        ((uint32_t)kSDIO_StatusCmdCRCError | (uint32_t)kSDIO_StatusIllegalCmd | (uint32_t)kSDIO_StatusError |
-         (uint32_t)kSDIO_StatusFunctionNumError | (uint32_t)kSDIO_StatusOutofRange);
-
-    content.command = &command;
-    content.data    = NULL;
-    error           = SDMMCHOST_TransferFunction(card->host, &content);
-    if (kStatus_Success != error)
-    {
-        error = kStatus_SDMMC_TransferFailed;
-    }
-
-    if ((error == kStatus_Success) && (dataOut != NULL))
-    {
-        /* read data from response */
-        *dataOut = (uint8_t)(command.response[0U] & SDIO_DIRECT_CMD_DATA_MASK);
-    }
-
-    return error;
-}
-
-status_t SDIO_IO_Write_Direct(sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *data, bool raw)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    status_t error = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    error = SDIO_IO_Access_Direct(card, kSDIO_IOWrite, func, regAddr, *data, data, raw);
-    if (kStatus_Success != error)
-    {
-        error = kStatus_SDMMC_TransferFailed;
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t SDIO_IO_Read_Direct(sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *data)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    status_t error = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    error = SDIO_IO_Access_Direct(card, kSDIO_IORead, func, regAddr, 0, data, false);
-    if (kStatus_Success != error)
-    {
-        error = kStatus_SDMMC_TransferFailed;
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t SDIO_IO_RW_Direct(sdio_card_t *card,
-                           sdio_io_direction_t direction,
-                           sdio_func_num_t func,
-                           uint32_t regAddr,
-                           uint8_t dataIn,
-                           uint8_t *dataOut)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    status_t error = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    error = SDIO_IO_Access_Direct(card, direction, func, regAddr, dataIn, dataOut, true);
-    if (kStatus_Success != error)
-    {
-        error = kStatus_SDMMC_TransferFailed;
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t SDIO_IO_Write_Extended(
-    sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *buffer, uint32_t count, uint32_t flags)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    sdmmchost_transfer_t content = {0U};
-    sdmmchost_cmd_t command      = {0U};
-    sdmmchost_data_t data        = {0U};
-    bool blockMode               = false;
-    bool opCode                  = false;
-    status_t error               = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    /* check if card support block mode */
-    if (((card->cccrflags & (uint32_t)kSDIO_CCCRSupportMultiBlock) != 0U) &&
-        ((flags & SDIO_EXTEND_CMD_BLOCK_MODE_MASK) != 0U))
-    {
-        blockMode = true;
-    }
-
-    if ((flags & SDIO_EXTEND_CMD_OP_CODE_MASK) != 0U)
-    {
-        opCode = true;
-    }
-
-    /* check the byte size counter in non-block mode
-     * so you need read CIS for each function first,before you do read/write
-     */
-    if (!blockMode)
-    {
-        if ((func == kSDIO_FunctionNum0) && (card->commonCIS.fn0MaxBlkSize != 0U) &&
-            (count > card->commonCIS.fn0MaxBlkSize))
-        {
-            error = kStatus_SDMMC_SDIO_InvalidArgument;
-        }
-        else if ((func != kSDIO_FunctionNum0) && (card->funcCIS[(uint32_t)func - 1U].ioMaxBlockSize != 0U) &&
-                 (count > card->funcCIS[(uint32_t)func - 1U].ioMaxBlockSize))
-        {
-            error = kStatus_SDMMC_SDIO_InvalidArgument;
-        }
-        else
-        {
-            /* Intentional empty */
-        }
-    }
-
-    if (error == kStatus_Success)
-    {
-        command.index    = (uint32_t)kSDIO_RWIOExtended;
-        command.argument = ((uint32_t)func << SDIO_CMD_ARGUMENT_FUNC_NUM_POS) |
-                           ((regAddr & SDIO_CMD_ARGUMENT_REG_ADDR_MASK) << SDIO_CMD_ARGUMENT_REG_ADDR_POS) |
-                           (1UL << SDIO_CMD_ARGUMENT_RW_POS) | (count & SDIO_EXTEND_CMD_COUNT_MASK) |
-                           ((blockMode ? 1UL : 0UL) << SDIO_EXTEND_CMD_ARGUMENT_BLOCK_MODE_POS |
-                            ((opCode ? 1UL : 0UL) << SDIO_EXTEND_CMD_ARGUMENT_OP_CODE_POS));
-        command.responseType = kCARD_ResponseTypeR5;
-        command.responseErrorFlags =
-            ((uint32_t)kSDIO_StatusCmdCRCError | (uint32_t)kSDIO_StatusIllegalCmd | (uint32_t)kSDIO_StatusError |
-             (uint32_t)kSDIO_StatusFunctionNumError | (uint32_t)kSDIO_StatusOutofRange);
-
-        if (blockMode)
-        {
-            if (func == kSDIO_FunctionNum0)
-            {
-                data.blockSize = card->io0blockSize;
-            }
-            else
-            {
-                data.blockSize = card->ioFBR[(uint32_t)func - 1U].ioBlockSize;
-            }
-            data.blockCount = count;
-        }
-        else
-        {
-            data.blockSize  = count;
-            data.blockCount = 1U;
-        }
-        data.txData = (uint32_t *)(uint32_t)buffer;
-
-        content.command = &command;
-        content.data    = &data;
-        error           = SDMMCHOST_TransferFunction(card->host, &content);
-        if (kStatus_Success != error)
-        {
-            error = kStatus_SDMMC_TransferFailed;
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t SDIO_IO_Read_Extended(
-    sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *buffer, uint32_t count, uint32_t flags)
-{
-    assert(card != NULL);
-    assert(buffer != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    sdmmchost_transfer_t content = {0U};
-    sdmmchost_cmd_t command      = {0U};
-    sdmmchost_data_t data        = {0U};
-    bool blockMode               = false;
-    bool opCode                  = false;
-    status_t error               = kStatus_Success;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    /* check if card support block mode */
-    if (((card->cccrflags & (uint32_t)kSDIO_CCCRSupportMultiBlock) != 0U) &&
-        ((flags & SDIO_EXTEND_CMD_BLOCK_MODE_MASK) != 0U))
-    {
-        blockMode = true;
-    }
-
-    /* op code =0 : read/write to fixed addr
-     *  op code =1 :read/write addr incrementing
-     */
-    if ((flags & SDIO_EXTEND_CMD_OP_CODE_MASK) != 0U)
-    {
-        opCode = true;
-    }
-
-    /* check the byte size counter in non-block mode
-     * so you need read CIS for each function first,before you do read/write
-     */
-    if (!blockMode)
-    {
-        if ((func == kSDIO_FunctionNum0) && (card->commonCIS.fn0MaxBlkSize != 0U) &&
-            (count > card->commonCIS.fn0MaxBlkSize))
-        {
-            error = kStatus_SDMMC_SDIO_InvalidArgument;
-        }
-        else if ((func != kSDIO_FunctionNum0) && (card->funcCIS[(uint32_t)func - 1U].ioMaxBlockSize != 0U) &&
-                 (count > card->funcCIS[(uint32_t)func - 1U].ioMaxBlockSize))
-        {
-            error = kStatus_SDMMC_SDIO_InvalidArgument;
-        }
-        else
-        {
-            /* Intentional empty */
-        }
-    }
-
-    if (error == kStatus_Success)
-    {
-        command.index    = (uint32_t)kSDIO_RWIOExtended;
-        command.argument = ((uint32_t)func << SDIO_CMD_ARGUMENT_FUNC_NUM_POS) |
-                           ((regAddr & SDIO_CMD_ARGUMENT_REG_ADDR_MASK) << SDIO_CMD_ARGUMENT_REG_ADDR_POS) |
-                           (count & SDIO_EXTEND_CMD_COUNT_MASK) |
-                           ((blockMode ? 1UL : 0UL) << SDIO_EXTEND_CMD_ARGUMENT_BLOCK_MODE_POS |
-                            ((opCode ? 1UL : 0UL) << SDIO_EXTEND_CMD_ARGUMENT_OP_CODE_POS));
-        command.responseType = kCARD_ResponseTypeR5;
-        command.responseErrorFlags =
-            ((uint32_t)kSDIO_StatusCmdCRCError | (uint32_t)kSDIO_StatusIllegalCmd | (uint32_t)kSDIO_StatusError |
-             (uint32_t)kSDIO_StatusFunctionNumError | (uint32_t)kSDIO_StatusOutofRange);
-
-        if (blockMode)
-        {
-            if (func == kSDIO_FunctionNum0)
-            {
-                data.blockSize = card->io0blockSize;
-            }
-            else
-            {
-                data.blockSize = card->ioFBR[(uint32_t)func - 1U].ioBlockSize;
-            }
-            data.blockCount = count;
-        }
-        else
-        {
-            data.blockSize  = count;
-            data.blockCount = 1U;
-        }
-        data.rxData = (uint32_t *)(uint32_t)buffer;
-
-        content.command = &command;
-        content.data    = &data;
-        error           = SDMMCHOST_TransferFunction(card->host, &content);
-        if (kStatus_Success != error)
-        {
-            error = kStatus_SDMMC_TransferFailed;
-        }
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t SDIO_IO_Transfer(sdio_card_t *card,
-                          sdio_command_t cmd,
-                          uint32_t argument,
-                          uint32_t blockSize,
-                          uint8_t *txData,
-                          uint8_t *rxData,
-                          uint16_t dataSize,
-                          uint32_t *response)
-{
-    assert(card != NULL);
-
-    uint32_t actualSize          = dataSize;
-    sdmmchost_transfer_t content = {0U};
-    sdmmchost_cmd_t command      = {0U};
-    sdmmchost_data_t data        = {0U};
-    uint32_t i                   = SDIO_RETRY_TIMES;
-    uint32_t *dataAddr           = (uint32_t *)(uint32_t)(txData == NULL ? rxData : txData);
-    uint8_t *alignBuffer         = (uint8_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    status_t error               = kStatus_Fail;
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    if ((dataSize != 0U) && (txData != NULL) && (rxData != NULL))
-    {
-        error = kStatus_InvalidArgument;
-    }
-    else
-    {
-        command.index        = (uint32_t)cmd;
-        command.argument     = argument;
-        command.responseType = kCARD_ResponseTypeR5;
-        command.responseErrorFlags =
-            ((uint32_t)kSDIO_StatusCmdCRCError | (uint32_t)kSDIO_StatusIllegalCmd | (uint32_t)kSDIO_StatusError |
-             (uint32_t)kSDIO_StatusFunctionNumError | (uint32_t)kSDIO_StatusOutofRange);
-        content.command = &command;
-        content.data    = NULL;
-
-        if (dataSize != 0U)
-        {
-            /* if block size bigger than 1, then use block mode */
-            if ((argument & SDIO_EXTEND_CMD_BLOCK_MODE_MASK) != 0U)
-            {
-                if (dataSize % blockSize != 0U)
-                {
-                    actualSize = ((dataSize / blockSize) + 1U) * blockSize;
-                }
-
-                data.blockCount = actualSize / blockSize;
-                data.blockSize  = blockSize;
-            }
-            else
-            {
-                data.blockCount = 1;
-                data.blockSize  = dataSize;
-            }
-            /* if data buffer address can not meet host controller internal DMA requirement, sdio driver will try to use
-             * internal align buffer if data size is not bigger than internal buffer size,
-             * Align address transfer always can get a better performance, so if you want sdio driver make buffer
-             * address align, you should redefine the SDMMC_GLOBAL_BUFFER_SIZE macro to a value which is big enough for
-             * your application.
-             */
-            if (
-#if SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE != 1U
-                (((uint32_t)dataAddr & (SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE - 1U)) != 0U) &&
-#endif
-                (actualSize <= FSL_SDMMC_DEFAULT_BLOCK_SIZE) && (!card->noInternalAlign))
-            {
-                dataAddr = (uint32_t *)(uint32_t)alignBuffer;
-                (void)memset(alignBuffer, 0, actualSize);
-                if (txData != NULL)
-                {
-                    (void)memcpy(alignBuffer, txData, dataSize);
-                }
-            }
-
-            if (rxData != NULL)
-            {
-                data.rxData = dataAddr;
-            }
-            else
-            {
-                data.txData = dataAddr;
-            }
-
-            content.data = &data;
-        }
-
-        do
-        {
-            error = SDMMCHOST_TransferFunction(card->host, &content);
-            if (kStatus_Success == error)
-            {
-                if ((rxData != NULL) && (dataSize != 0U) &&
-#if SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE != 1U
-                    (((uint32_t)rxData & (SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE - 1U)) != 0U) &&
-#endif
-                    (actualSize <= FSL_SDMMC_DEFAULT_BLOCK_SIZE) && (!card->noInternalAlign))
-                {
-                    (void)memcpy(rxData, alignBuffer, dataSize);
-                }
-
-                if (response != NULL)
-                {
-                    *response = command.response[0];
-                }
-
-                error = kStatus_Success;
-                break;
-            }
-
-            i--;
-        } while (i != 0U);
-    }
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-status_t SDIO_GetCardCapability(sdio_card_t *card, sdio_func_num_t func)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    uint8_t *tempBuffer = (uint8_t *)FSL_SDMMC_CARD_INTERNAL_BUFFER_ALIGN_ADDR(card->internalBuffer);
-    uint32_t i          = 0U;
-    status_t error      = kStatus_Success;
-
-    (void)memset(tempBuffer, 0, SDIO_CCCR_REG_NUMBER);
-
-    for (i = 0U; i <= SDIO_CCCR_REG_NUMBER; i++)
-    {
-        error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, SDIO_FBR_BASE((uint32_t)func) + i, 0U,
-                                      &tempBuffer[i], false);
-        if (kStatus_Success != error)
-        {
-            return kStatus_SDMMC_TransferFailed;
-        }
-    }
-
-    switch (func)
-    {
-        case kSDIO_FunctionNum0:
-
-            card->sdVersion    = tempBuffer[kSDIO_RegSDVersion];
-            card->sdioVersion  = tempBuffer[kSDIO_RegCCCRSdioVer] >> 4U;
-            card->cccrVersioin = tempBuffer[kSDIO_RegCCCRSdioVer] & 0xFU;
-            /* continuous SPI interrupt */
-            if ((tempBuffer[kSDIO_RegBusInterface] & 0x40U) != 0U)
-            {
-                card->cccrflags |= (uint32_t)kSDIO_CCCRSupportContinuousSPIInt;
-            }
-            /* 8bit data bus */
-            if ((tempBuffer[kSDIO_RegBusInterface] & 0x4U) != 0U)
-            {
-                card->cccrflags |= SDIO_CCCR_SUPPORT_8BIT_BUS;
-            }
-
-            /* card capability register */
-            card->cccrflags |= (tempBuffer[kSDIO_RegCardCapability] & 0xDFUL);
-            /* master power control */
-            if ((tempBuffer[kSDIO_RegPowerControl] & 0x01U) != 0U)
-            {
-                card->cccrflags |= (uint32_t)kSDIO_CCCRSupportMasterPowerControl;
-            }
-            /* high speed flag */
-            if ((tempBuffer[kSDIO_RegBusSpeed] & 0x01U) != 0U)
-            {
-                card->cccrflags |= SDIO_CCCR_SUPPORT_HIGHSPEED;
-            }
-            /* uhs mode flag */
-            card->cccrflags |= (tempBuffer[kSDIO_RegUHSITimingSupport] & 7UL) << 11U;
-            /* driver type flag */
-            card->cccrflags |= (tempBuffer[kSDIO_RegDriverStrength] & 7UL) << 14U;
-            /* low speed 4bit */
-            if ((tempBuffer[kSDIO_RegCardCapability] & 0x80U) != 0U)
-            {
-                card->cccrflags |= (uint32_t)kSDIO_CCCRSupportLowSpeed4Bit;
-            }
-            /* common CIS pointer */
-            card->commonCISPointer = tempBuffer[kSDIO_RegCommonCISPointer] |
-                                     ((uint32_t)tempBuffer[(uint32_t)kSDIO_RegCommonCISPointer + 1U] << 8U) |
-                                     ((uint32_t)tempBuffer[(uint32_t)kSDIO_RegCommonCISPointer + 2U] << 16U);
-
-            /* check card capability of support async interrupt */
-            if ((tempBuffer[kSDIO_RegInterruptExtension] & SDIO_CCCR_ASYNC_INT_MASK) == SDIO_CCCR_ASYNC_INT_MASK)
-            {
-                card->cccrflags |= SDIO_CCCR_SUPPORT_ASYNC_INT;
-            }
-
-            break;
-
-        case kSDIO_FunctionNum1:
-        case kSDIO_FunctionNum2:
-        case kSDIO_FunctionNum3:
-        case kSDIO_FunctionNum4:
-        case kSDIO_FunctionNum5:
-        case kSDIO_FunctionNum6:
-        case kSDIO_FunctionNum7:
-            card->ioFBR[(uint32_t)func - 1U].ioStdFunctionCode = tempBuffer[0U] & 0x0FU;
-            card->ioFBR[(uint32_t)func - 1U].ioExtFunctionCode = tempBuffer[1U];
-            card->ioFBR[(uint32_t)func - 1U].ioPointerToCIS =
-                tempBuffer[9U] | ((uint32_t)tempBuffer[10U] << 8U) | ((uint32_t)tempBuffer[11U] << 16U);
-            card->ioFBR[(uint32_t)func - 1U].ioPointerToCSA =
-                tempBuffer[12U] | ((uint32_t)tempBuffer[13U] << 8U) | ((uint32_t)tempBuffer[14U] << 16U);
-            if ((tempBuffer[2U] & 0x01U) != 0U)
-            {
-                card->ioFBR[(uint32_t)func - 1U].flags |= (uint8_t)kSDIO_FBRSupportPowerSelection;
-            }
-            if ((tempBuffer[0U] & 0x40U) != 0U)
-            {
-                card->ioFBR[(uint32_t)func - 1U].flags |= (uint8_t)kSDIO_FBRSupportCSA;
-            }
-
-            break;
-
-        default:
-            assert(false);
-            break;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_SetBlockSize(sdio_card_t *card, sdio_func_num_t func, uint32_t blockSize)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-    assert(blockSize <= SDIO_MAX_BLOCK_SIZE);
-
-    uint8_t temp   = 0U;
-    status_t error = kStatus_Success;
-
-    /* check the block size for block mode
-     * so you need read CIS for each function first,before you do read/write
-     */
-    if ((func == kSDIO_FunctionNum0) && (card->commonCIS.fn0MaxBlkSize != 0U) &&
-        (blockSize > card->commonCIS.fn0MaxBlkSize))
-    {
-        return kStatus_SDMMC_SDIO_InvalidArgument;
-    }
-    else if ((func != kSDIO_FunctionNum0) && (card->funcCIS[(uint32_t)func - 1U].ioMaxBlockSize != 0U) &&
-             (blockSize > card->funcCIS[(uint32_t)func - 1U].ioMaxBlockSize))
-    {
-        return kStatus_SDMMC_SDIO_InvalidArgument;
-    }
-    else
-    {
-        /* Intentional empty */
-    }
-
-    temp = (uint8_t)(blockSize & 0xFFU);
-
-    error =
-        SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0,
-                              SDIO_FBR_BASE((uint32_t)func) + (uint32_t)kSDIO_RegFN0BlockSizeLow, temp, &temp, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SetCardBlockSizeFailed;
-    }
-
-    temp = (uint8_t)((blockSize >> 8U) & 0xFFU);
-
-    error =
-        SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0,
-                              SDIO_FBR_BASE((uint32_t)func) + (uint32_t)kSDIO_RegFN0BlockSizeHigh, temp, &temp, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_SetCardBlockSizeFailed;
-    }
-
-    /* record the current block size */
-    if (func == kSDIO_FunctionNum0)
-    {
-        card->io0blockSize = blockSize;
-    }
-    else
-    {
-        card->ioFBR[(uint32_t)func - 1U].ioBlockSize = (uint16_t)blockSize;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_CardReset(sdio_card_t *card)
-{
-    status_t error = kStatus_Success;
-
-    error = SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegIOAbort, 0x08U, NULL, false);
-    if (error != kStatus_Success)
-    {
-        error = kStatus_SDMMC_TransferFailed;
-    }
-
-    return error;
-}
-
-status_t SDIO_SetDataBusWidth(sdio_card_t *card, sdio_bus_width_t busWidth)
-{
-    assert(card != NULL);
-
-    uint8_t regBusInterface = 0U;
-    status_t error          = kStatus_Success;
-
-    if (((busWidth == kSDIO_DataBus4Bit) && ((card->cccrflags & (uint32_t)kSDIO_CCCRSupportHighSpeed) == 0U) &&
-         ((card->cccrflags & (uint32_t)kSDIO_CCCRSupportLowSpeed4Bit) == 0U)))
-    {
-        return kStatus_SDMMC_SDIO_InvalidArgument;
-    }
-
-    if ((((card->cccrflags & SDIO_CCCR_SUPPORT_8BIT_BUS) == 0U) ||
-         ((card->usrParam.capability & (uint32_t)kSDMMC_Support8BitWidth) == 0U) ||
-         ((card->host->capability & (uint32_t)kSDMMCHOST_Support8BitDataWidth) == 0U)) &&
-        (busWidth == kSDIO_DataBus8Bit))
-    {
-        return kStatus_SDMMC_SDIO_InvalidArgument;
-    }
-
-    /* load bus interface register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegBusInterface, 0U, &regBusInterface,
-                                  false);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-    /* set bus width */
-    regBusInterface &= 0xFCU;
-    regBusInterface |= (uint8_t)busWidth;
-
-    /* write to register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegBusInterface, regBusInterface,
-                                  &regBusInterface, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-#if SDMMCHOST_SUPPORT_8_BIT_WIDTH
-    if (busWidth == kSDIO_DataBus8Bit)
-    {
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith8Bit);
-    }
-    else
-#endif
-        if (busWidth == kSDIO_DataBus4Bit)
-    {
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith4Bit);
-    }
-    else
-    {
-        SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith1Bit);
-    }
-
-    return kStatus_Success;
-}
-
-static status_t SDIO_SetMaxDataBusWidth(sdio_card_t *card)
-{
-    sdio_bus_width_t busWidth = kSDIO_DataBus1Bit;
-
-    if (((card->cccrflags & SDIO_CCCR_SUPPORT_8BIT_BUS) != 0U) &&
-        ((card->usrParam.capability & (uint32_t)kSDMMC_Support8BitWidth) != 0U) &&
-        ((card->host->capability & (uint32_t)kSDMMCHOST_Support8BitDataWidth) != 0U))
-    {
-        busWidth = kSDIO_DataBus8Bit;
-    }
-    /* switch data bus width */
-    else if ((((card->cccrflags & (uint32_t)kSDIO_CCCRSupportHighSpeed) != 0U) ||
-              ((card->cccrflags & (uint32_t)kSDIO_CCCRSupportLowSpeed4Bit) != 0U)) &&
-             ((card->host->capability & (uint32_t)kSDMMCHOST_Support4BitDataWidth) != 0U))
-    {
-        busWidth = kSDIO_DataBus4Bit;
-    }
-    else
-    {
-        busWidth = kSDIO_DataBus1Bit;
-    }
-
-    return SDIO_SetDataBusWidth(card, busWidth);
-}
-
-status_t SDIO_SwitchToHighSpeed(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    uint8_t temp        = 0U;
-    uint32_t retryTimes = SDIO_RETRY_TIMES;
-    status_t status     = kStatus_SDMMC_SDIO_SwitchHighSpeedFail;
-    status_t error      = kStatus_Success;
-
-    if ((card->cccrflags & SDIO_CCCR_SUPPORT_HIGHSPEED) != 0U)
-    {
-        error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegBusSpeed, 0U, &temp, false);
-        if (kStatus_Success != error)
-        {
-            return kStatus_SDMMC_TransferFailed;
-        }
-
-        do
-        {
-            temp &= (uint8_t)~SDIO_CCCR_BUS_SPEED_MASK;
-            temp |= SDIO_CCCR_ENABLE_HIGHSPEED_MODE;
-
-            retryTimes--;
-            /* enable high speed mode */
-            error =
-                SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegBusSpeed, temp, &temp, true);
-            if (kStatus_Success != error)
-            {
-                continue;
-            }
-            /* either EHS=0 and SHS=0 ,the card is still in default mode  */
-            if ((temp & 0x03U) == 0x03U)
-            {
-                card->busClock_Hz = SDMMCHOST_SetCardClock(
-                    card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_50MHZ));
-                status = kStatus_Success;
-                break;
-            }
-            else
-            {
-                continue;
-            }
-
-        } while (retryTimes != 0U);
-    }
-    else
-    {
-        /* default mode 25MHZ */
-        card->busClock_Hz =
-            SDMMCHOST_SetCardClock(card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_25MHZ));
-        status = kStatus_Success;
-    }
-
-    return status;
-}
-
-static status_t SDIO_SelectBusTiming(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t targetBusFreq   = SD_CLOCK_25MHZ;
-    uint32_t targetTiming    = 0U;
-    uint8_t temp             = 0U;
-    uint32_t supportModeFlag = 0U;
-    uint32_t retryTimes      = SDIO_RETRY_TIMES;
-    status_t error           = kStatus_Success;
-
-    do
-    {
-        if (card->currentTiming == kSD_TimingSDR12DefaultMode)
-        {
-            /* if timing not specified, probe card capability from SDR104 mode */
-            card->currentTiming = kSD_TimingSDR104Mode;
-        }
-
-        if (card->currentTiming == kSD_TimingSDR104Mode)
-        {
-            if (((card->host->capability & (uint32_t)kSDMMCHOST_SupportSDR104) != 0U) &&
-                ((card->cccrflags & SDIO_CCCR_SUPPORT_SDR104) == SDIO_CCCR_SUPPORT_SDR104) &&
-                (card->operationVoltage == kSDMMC_OperationVoltage180V))
-            {
-                targetTiming    = SDIO_CCCR_ENABLE_SDR104_MODE;
-                targetBusFreq   = FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_208MHZ);
-                supportModeFlag = SDIO_CCCR_SUPPORT_SDR104;
-            }
-            else
-            {
-                card->currentTiming = kSD_TimingDDR50Mode;
-            }
-        }
-
-        if (card->currentTiming == kSD_TimingDDR50Mode)
-        {
-            if (((card->host->capability & (uint32_t)kSDMMCHOST_SupportDDRMode) != 0U) &&
-                ((card->cccrflags & SDIO_CCCR_SUPPORT_DDR50) == SDIO_CCCR_SUPPORT_DDR50) &&
-                (card->operationVoltage == kSDMMC_OperationVoltage180V))
-            {
-                targetTiming    = SDIO_CCCR_ENABLE_DDR50_MODE;
-                targetBusFreq   = FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_50MHZ);
-                supportModeFlag = SDIO_CCCR_SUPPORT_DDR50;
-            }
-            else
-            {
-                card->currentTiming = kSD_TimingSDR50Mode;
-            }
-        }
-
-        if (card->currentTiming == kSD_TimingSDR50Mode)
-        {
-            if (((card->host->capability & (uint32_t)kSDMMCHOST_SupportSDR50) != 0U) &&
-                ((card->cccrflags & SDIO_CCCR_SUPPORT_SDR50) == SDIO_CCCR_SUPPORT_SDR50) &&
-                (card->operationVoltage == kSDMMC_OperationVoltage180V))
-            {
-                targetTiming    = SDIO_CCCR_ENABLE_SDR50_MODE;
-                targetBusFreq   = FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_100MHZ);
-                supportModeFlag = SDIO_CCCR_SUPPORT_SDR50;
-            }
-            else
-            {
-                card->currentTiming = kSD_TimingSDR25HighSpeedMode;
-            }
-        }
-
-        if (card->currentTiming == kSD_TimingSDR25HighSpeedMode)
-        {
-            if ((card->cccrflags & SDIO_CCCR_SUPPORT_HIGHSPEED) == SDIO_CCCR_SUPPORT_HIGHSPEED)
-            {
-                targetTiming    = SDIO_CCCR_ENABLE_HIGHSPEED_MODE;
-                targetBusFreq   = FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, SD_CLOCK_50MHZ);
-                supportModeFlag = SDIO_CCCR_SUPPORT_HIGHSPEED;
-            }
-            else
-            {
-                card->currentTiming = kSD_TimingSDR12DefaultMode;
-            }
-        }
-
-        if (card->currentTiming == kSD_TimingSDR12DefaultMode)
-        {
-            /* default timing mode */
-            targetBusFreq = SD_CLOCK_25MHZ;
-        }
-
-        error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegBusSpeed, 0U, &temp, false);
-        if (kStatus_Success != error)
-        {
-            return kStatus_SDMMC_TransferFailed;
-        }
-        do
-        {
-            temp &= (uint8_t)~SDIO_CCCR_BUS_SPEED_MASK;
-            temp |= (uint8_t)targetTiming;
-
-            retryTimes--;
-            error =
-                SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegBusSpeed, temp, &temp, true);
-            if (kStatus_Success != error)
-            {
-                continue;
-            }
-
-            if ((temp & targetTiming) != targetTiming)
-            {
-                continue;
-            }
-
-            break;
-
-        } while (retryTimes != 0U);
-
-        if (retryTimes == 0U)
-        {
-            retryTimes = SDIO_RETRY_TIMES;
-            /* if cannot switch target timing, it will switch continuously until find a valid timing. */
-            card->cccrflags &= ~supportModeFlag;
-            continue;
-        }
-
-        break;
-
-    } while (true);
-
-    card->busClock_Hz =
-        SDMMCHOST_SetCardClock(card->host, FSL_SDMMC_CARD_MAX_BUS_FREQ(card->usrParam.maxFreq, targetBusFreq));
-
-    /* enable DDR mode if it is the target mode */
-    if (card->currentTiming == kSD_TimingDDR50Mode)
-    {
-        SDMMCHOST_EnableDDRMode(card->host, true, 0U);
-    }
-
-    if (card->usrParam.ioStrength != NULL)
-    {
-        card->usrParam.ioStrength(card->busClock_Hz);
-    }
-
-    /* SDR50 and SDR104 mode need tuning */
-    if ((card->currentTiming == kSD_TimingSDR50Mode) || (card->currentTiming == kSD_TimingSDR104Mode))
-    {
-        /* execute tuning */
-        if (SDIO_ExecuteTuning(card) != kStatus_Success)
-        {
-            return kStatus_SDMMC_TuningFail;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_SetDriverStrength(sdio_card_t *card, sd_driver_strength_t driverStrength)
-{
-    uint8_t strength = 0U, temp = 0U;
-    status_t error = kStatus_Success;
-
-    switch (driverStrength)
-    {
-        case kSD_DriverStrengthTypeA:
-            strength = SDIO_CCCR_ENABLE_DRIVER_TYPE_A;
-            break;
-        case kSD_DriverStrengthTypeC:
-            strength = SDIO_CCCR_ENABLE_DRIVER_TYPE_C;
-            break;
-        case kSD_DriverStrengthTypeD:
-            strength = SDIO_CCCR_ENABLE_DRIVER_TYPE_D;
-            break;
-        default:
-            strength = SDIO_CCCR_ENABLE_DRIVER_TYPE_B;
-            break;
-    }
-
-    error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegDriverStrength, 0U, &temp, false);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    temp &= (uint8_t)~SDIO_CCCR_DRIVER_TYPE_MASK;
-    temp |= strength;
-
-    error = SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegDriverStrength, temp, &temp, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return error;
-}
-
-status_t SDIO_EnableAsyncInterrupt(sdio_card_t *card, bool enable)
-{
-    assert(card != NULL);
-
-    uint8_t eai    = 0U;
-    status_t error = kStatus_Success;
-
-    if ((card->cccrflags & SDIO_CCCR_SUPPORT_ASYNC_INT) == 0U)
-    {
-        return kStatus_SDMMC_NotSupportYet;
-    }
-
-    /* load interrupt enable register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegInterruptExtension, 0U, &eai, false);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-    /* if already enable/disable , do not need enable/disable again */
-    if (((eai)&SDIO_CCCR_ENABLE_AYNC_INT) == (enable ? SDIO_CCCR_ENABLE_AYNC_INT : 0U))
-    {
-        return kStatus_Success;
-    }
-
-    /* enable the eai */
-    if (enable)
-    {
-        eai |= SDIO_CCCR_ENABLE_AYNC_INT;
-    }
-    else
-    {
-        eai &= (uint8_t) ~(SDIO_CCCR_ENABLE_AYNC_INT);
-    }
-
-    /* write to register */
-    error =
-        SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegInterruptExtension, eai, &eai, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-static status_t SDIO_DecodeCIS(
-    sdio_card_t *card, sdio_func_num_t func, uint8_t *dataBuffer, uint32_t tplCode, uint32_t tplLink)
-{
-    assert(card != NULL);
-    assert(dataBuffer != NULL);
-
-    if (func == kSDIO_FunctionNum0)
-    {
-        /* only decode MANIFID,FUNCID,FUNCE here  */
-        if (tplCode == SDIO_TPL_CODE_MANIFID)
-        {
-            card->commonCIS.mID   = dataBuffer[0U] | ((uint16_t)dataBuffer[1U] << 8U);
-            card->commonCIS.mInfo = dataBuffer[2U] | ((uint16_t)dataBuffer[3U] << 8U);
-        }
-        else if (tplCode == SDIO_TPL_CODE_FUNCID)
-        {
-            card->commonCIS.funcID = dataBuffer[0U];
-        }
-        else if (tplCode == SDIO_TPL_CODE_FUNCE)
-        {
-            /* max transfer block size and data size */
-            card->commonCIS.fn0MaxBlkSize = dataBuffer[1U] | ((uint16_t)dataBuffer[2U] << 8U);
-            /* max transfer speed */
-            card->commonCIS.maxTransSpeed = dataBuffer[3U];
-        }
-        else
-        {
-            /* reserved here */
-            return kStatus_Fail;
-        }
-    }
-    else
-    {
-        /* only decode FUNCID,FUNCE here  */
-        if (tplCode == SDIO_TPL_CODE_FUNCID)
-        {
-            card->funcCIS[(uint32_t)func - 1U].funcID = dataBuffer[0U];
-        }
-        else if (tplCode == SDIO_TPL_CODE_FUNCE)
-        {
-            if (tplLink == 0x2AU)
-            {
-                card->funcCIS[(uint32_t)func - 1U].funcInfo  = dataBuffer[1U];
-                card->funcCIS[(uint32_t)func - 1U].ioVersion = dataBuffer[2U];
-                card->funcCIS[(uint32_t)func - 1U].cardPSN   = dataBuffer[3U] | ((uint32_t)dataBuffer[4U] << 8U) |
-                                                             ((uint32_t)dataBuffer[5U] << 16U) |
-                                                             ((uint32_t)dataBuffer[6U] << 24U);
-                card->funcCIS[(uint32_t)func - 1U].ioCSASize = dataBuffer[7U] | ((uint32_t)dataBuffer[8U] << 8U) |
-                                                               ((uint32_t)dataBuffer[9U] << 16U) |
-                                                               ((uint32_t)dataBuffer[10U] << 24U);
-                card->funcCIS[(uint32_t)func - 1U].ioCSAProperty  = dataBuffer[11U];
-                card->funcCIS[(uint32_t)func - 1U].ioMaxBlockSize = dataBuffer[12U] | ((uint16_t)dataBuffer[13U] << 8U);
-                card->funcCIS[(uint32_t)func - 1U].ioOCR = dataBuffer[14U] | ((uint32_t)dataBuffer[15U] << 8U) |
-                                                           ((uint32_t)dataBuffer[16U] << 16U) |
-                                                           ((uint32_t)dataBuffer[17U] << 24U);
-                card->funcCIS[(uint32_t)func - 1U].ioOPMinPwr     = dataBuffer[18U];
-                card->funcCIS[(uint32_t)func - 1U].ioOPAvgPwr     = dataBuffer[19U];
-                card->funcCIS[(uint32_t)func - 1U].ioOPMaxPwr     = dataBuffer[20U];
-                card->funcCIS[(uint32_t)func - 1U].ioSBMinPwr     = dataBuffer[21U];
-                card->funcCIS[(uint32_t)func - 1U].ioSBAvgPwr     = dataBuffer[22U];
-                card->funcCIS[(uint32_t)func - 1U].ioSBMaxPwr     = dataBuffer[23U];
-                card->funcCIS[(uint32_t)func - 1U].ioMinBandWidth = dataBuffer[24U] | ((uint16_t)dataBuffer[25U] << 8U);
-                card->funcCIS[(uint32_t)func - 1U].ioOptimumBandWidth =
-                    dataBuffer[26U] | ((uint16_t)dataBuffer[27U] << 8U);
-                card->funcCIS[(uint32_t)func - 1U].ioReadyTimeout = dataBuffer[28U] | ((uint16_t)dataBuffer[29U] << 8U);
-
-                card->funcCIS[(uint32_t)func - 1U].ioHighCurrentAvgCurrent =
-                    dataBuffer[34U] | ((uint16_t)dataBuffer[35U] << 8U);
-                card->funcCIS[(uint32_t)func - 1U].ioHighCurrentMaxCurrent =
-                    dataBuffer[36U] | ((uint16_t)dataBuffer[37U] << 8U);
-                card->funcCIS[(uint32_t)func - 1U].ioLowCurrentAvgCurrent =
-                    dataBuffer[38U] | ((uint16_t)dataBuffer[39U] << 8U);
-                card->funcCIS[(uint32_t)func - 1U].ioLowCurrentMaxCurrent =
-                    dataBuffer[40U] | ((uint16_t)dataBuffer[41U] << 8U);
-            }
-            else
-            {
-                return kStatus_Fail;
-            }
-        }
-        else
-        {
-            return kStatus_Fail;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_ReadCIS(sdio_card_t *card, sdio_func_num_t func, const uint32_t *tupleList, uint32_t tupleNum)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-    assert(tupleList != NULL);
-
-    uint8_t tplCode = 0U;
-    uint8_t tplLink = 0U;
-    uint32_t cisPtr = 0U;
-    uint32_t i = 0U, num = 0U;
-    bool tupleMatch = false;
-    status_t error  = kStatus_Success;
-
-    uint8_t dataBuffer[255U] = {0U};
-
-    /* get the CIS pointer for each function */
-    if (func == kSDIO_FunctionNum0)
-    {
-        cisPtr = card->commonCISPointer;
-    }
-    else
-    {
-        cisPtr = card->ioFBR[(uint32_t)func - 1U].ioPointerToCIS;
-    }
-
-    if (0U == cisPtr)
-    {
-        return kStatus_SDMMC_SDIO_ReadCISFail;
-    }
-
-    do
-    {
-        error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, cisPtr++, 0U, &tplCode, false);
-        if (kStatus_Success != error)
-        {
-            return kStatus_SDMMC_TransferFailed;
-        }
-        /* end of chain tuple */
-        if (tplCode == 0xFFU)
-        {
-            break;
-        }
-
-        if (tplCode == 0U)
-        {
-            continue;
-        }
-
-        for (i = 0; i < tupleNum; i++)
-        {
-            if (tplCode == tupleList[i])
-            {
-                tupleMatch = true;
-                break;
-            }
-        }
-
-        error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, cisPtr++, 0U, &tplLink, false);
-        if (kStatus_Success != error)
-        {
-            return kStatus_SDMMC_TransferFailed;
-        }
-        /* end of chain tuple */
-        if (tplLink == 0xFFU)
-        {
-            break;
-        }
-
-        if (tupleMatch)
-        {
-            (void)memset(dataBuffer, 0, 255U);
-            for (i = 0; i < tplLink; i++)
-            {
-                error =
-                    SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, cisPtr++, 0U, &dataBuffer[i], false);
-                if (kStatus_Success != error)
-                {
-                    return kStatus_SDMMC_TransferFailed;
-                }
-            }
-            tupleMatch = false;
-            /* pharse the data */
-            (void)SDIO_DecodeCIS(card, func, dataBuffer, tplCode, tplLink);
-            /* read finish then return */
-            if (++num == tupleNum)
-            {
-                break;
-            }
-        }
-        else
-        {
-            /* move pointer */
-            cisPtr += tplLink;
-            /* tuple code not match,continue read tuple code */
-            continue;
-        }
-    } while (true);
-    return kStatus_Success;
-}
-
-static status_t SDIO_ProbeBusVoltage(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    uint32_t ocr = 0U, accept1V8 = 0U;
-    status_t error = kStatus_Success;
-
-    /* application able to set the supported voltage window */
-    if ((card->ocr & SDIO_OCR_VOLTAGE_WINDOW_MASK) != 0U)
-    {
-        ocr = card->ocr & SDIO_OCR_VOLTAGE_WINDOW_MASK;
-    }
-    else
-    {
-        /* 3.3V voltage should be supported as default */
-        ocr |= SDMMC_MASK(kSD_OcrVdd29_30Flag) | SDMMC_MASK(kSD_OcrVdd32_33Flag) | SDMMC_MASK(kSD_OcrVdd33_34Flag);
-    }
-
-    if ((card->operationVoltage != kSDMMC_OperationVoltage180V) && (card->usrParam.ioVoltage != NULL) &&
-        (card->usrParam.ioVoltage->type != kSD_IOVoltageCtrlNotSupport) &&
-        ((card->host->capability & (uint32_t)kSDMMCHOST_SupportVoltage1v8) != 0U) &&
-        ((card->host->capability & ((uint32_t)kSDMMCHOST_SupportSDR104 | (uint32_t)kSDMMCHOST_SupportSDR50 |
-                                    (uint32_t)kSDMMCHOST_SupportDDRMode)) != 0U))
-    {
-        /* allow user select the work voltage, if not select, sdmmc will handle it automatically */
-        ocr |= SDMMC_MASK(kSD_OcrSwitch18RequestFlag);
-
-        /* reset to 3v3 signal voltage */
-        if (SDIO_SwitchIOVoltage(card, kSDMMC_OperationVoltage330V) == kStatus_Success)
-        {
-            /* Host changed the operation signal voltage successfully, then card need power reset */
-            SDIO_SetCardPower(card, false);
-            SDIO_SetCardPower(card, true);
-        }
-    }
-
-    /* send card active */
-    SDMMCHOST_SendCardActive(card->host);
-
-    do
-    {
-        /* card go idle */
-        if (kStatus_Success != SDIO_GoIdle(card))
-        {
-            return kStatus_SDMMC_GoIdleFailed;
-        }
-
-        /* Get IO OCR-CMD5 with arg0 ,set new voltage if needed*/
-        if (kStatus_Success != SDIO_SendOperationCondition(card, 0U, NULL))
-        {
-            return kStatus_SDMMC_HandShakeOperationConditionFailed;
-        }
-
-        if (kStatus_Success != SDIO_SendOperationCondition(card, ocr, &accept1V8))
-        {
-            return kStatus_SDMMC_InvalidVoltage;
-        }
-
-        /* check if card support 1.8V */
-        if ((accept1V8 & SDMMC_MASK(kSD_OcrSwitch18AcceptFlag)) != 0U)
-        {
-            if ((card->usrParam.ioVoltage != NULL) && (card->usrParam.ioVoltage->type == kSD_IOVoltageCtrlNotSupport))
-            {
-                break;
-            }
-
-            error = SDIO_SwitchVoltage(card, kSDMMC_OperationVoltage180V);
-            if (kStatus_SDMMC_SwitchVoltageFail == error)
-            {
-                break;
-            }
-
-            if (error == kStatus_SDMMC_SwitchVoltage18VFail33VSuccess)
-            {
-                ocr &= ~SDMMC_MASK(kSD_OcrSwitch18RequestFlag);
-                error = kStatus_Success;
-                continue;
-            }
-            else
-            {
-                card->operationVoltage = kSDMMC_OperationVoltage180V;
-                break;
-            }
-        }
-        break;
-    } while (true);
-
-    return error;
-}
-
-static status_t sdiocard_init(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-
-    if (!card->isHostReady)
-    {
-        return kStatus_SDMMC_HostNotReady;
-    }
-    /* Identify mode ,set clock to 400KHZ. */
-    card->busClock_Hz = SDMMCHOST_SetCardClock(card->host, SDMMC_CLOCK_400KHZ);
-    SDMMCHOST_SetCardBusWidth(card->host, kSDMMC_BusWdith1Bit);
-
-    error = SDIO_ProbeBusVoltage(card);
-    if (error != kStatus_Success)
-    {
-        return kStatus_SDMMC_SwitchVoltageFail;
-    }
-
-    /* there is a memonly card */
-    if ((card->ioTotalNumber == 0U) && (card->memPresentFlag))
-    {
-        return kStatus_SDMMC_SDIO_InvalidCard;
-    }
-
-    /* send relative address ,cmd3*/
-    if (kStatus_Success != SDIO_SendRca(card))
-    {
-        return kStatus_SDMMC_SendRelativeAddressFailed;
-    }
-    /* select card cmd7 */
-    if (kStatus_Success != SDIO_SelectCard(card, true))
-    {
-        return kStatus_SDMMC_SelectCardFailed;
-    }
-
-    /* get card capability */
-    if (kStatus_Success != SDIO_GetCardCapability(card, kSDIO_FunctionNum0))
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* read common CIS here */
-    if (SDIO_ReadCIS(card, kSDIO_FunctionNum0, s_tupleList, SDIO_COMMON_CIS_TUPLE_NUM) != kStatus_Success)
-    {
-        return kStatus_SDMMC_SDIO_ReadCISFail;
-    }
-
-    /* switch data bus width */
-    if (kStatus_Success != SDIO_SetMaxDataBusWidth(card))
-    {
-        return kStatus_SDMMC_SetDataBusWidthFailed;
-    }
-
-    /* trying switch to card support timing mode. */
-    if (kStatus_Success != SDIO_SelectBusTiming(card))
-    {
-        return kStatus_SDMMC_SDIO_SwitchHighSpeedFail;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_CardInit(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-    /* create mutex lock */
-    (void)SDMMC_OSAMutexCreate(&card->lock);
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-
-    SDIO_SetCardPower(card, true);
-
-    error = sdiocard_init(card);
-
-    (void)SDMMC_OSAMutexUnlock(&card->lock);
-
-    return error;
-}
-
-void SDIO_CardDeinit(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    (void)SDMMC_OSAMutexLock(&card->lock, osaWaitForever_c);
-    (void)SDIO_CardReset(card);
-    (void)SDIO_SelectCard(card, false);
-    SDIO_SetCardPower(card, false);
-    (void)SDMMC_OSAMutexDestroy(&card->lock);
-}
-
-status_t SDIO_HostInit(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    if (!card->isHostReady)
-    {
-        if (SDMMCHOST_Init(card->host) != kStatus_Success)
-        {
-            return kStatus_Fail;
-        }
-    }
-
-    if ((card->usrParam.cd->type == kSD_DetectCardByHostCD) || (card->usrParam.cd->type == kSD_DetectCardByHostDATA3))
-    {
-        (void)SDMMCHOST_CardDetectInit(card->host, card->usrParam.cd);
-    }
-
-    if (card->usrParam.sdioInt != NULL)
-    {
-        (void)SDMMCHOST_CardIntInit(card->host, card->usrParam.sdioInt);
-    }
-
-    /* set the host status flag, after the card re-plug in, don't need init host again */
-    card->isHostReady = true;
-
-    return kStatus_Success;
-}
-
-void SDIO_HostDeinit(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    SDMMCHOST_Deinit(card->host);
-
-    /* should re-init host */
-    card->isHostReady = false;
-}
-
-void SDIO_HostDoReset(sdio_card_t *card)
-{
-    SDMMCHOST_Reset(card->host);
-}
-
-status_t SDIO_PollingCardInsert(sdio_card_t *card, uint32_t status)
-{
-    assert(card != NULL);
-    assert(card->usrParam.cd != NULL);
-
-    if (card->usrParam.cd->type == kSD_DetectCardByGpioCD)
-    {
-        if (card->usrParam.cd->cardDetected == NULL)
-        {
-            return kStatus_Fail;
-        }
-
-        do
-        {
-            if ((card->usrParam.cd->cardDetected() == true) && (status == (uint32_t)kSD_Inserted))
-            {
-                SDMMC_OSADelay(card->usrParam.cd->cdDebounce_ms);
-                if (card->usrParam.cd->cardDetected() == true)
-                {
-                    break;
-                }
-            }
-
-            if ((card->usrParam.cd->cardDetected() == false) && (status == (uint32_t)kSD_Removed))
-            {
-                break;
-            }
-        } while (true);
-    }
-    else
-    {
-        if (card->isHostReady == false)
-        {
-            return kStatus_Fail;
-        }
-
-        if (SDMMCHOST_PollingCardDetectStatus(card->host, status, ~0U) != kStatus_Success)
-        {
-            return kStatus_Fail;
-        }
-    }
-
-    return kStatus_Success;
-}
-
-bool SDIO_IsCardPresent(sdio_card_t *card)
-{
-    assert(card != NULL);
-    assert(card->usrParam.cd != NULL);
-
-    if (card->usrParam.cd->type == kSD_DetectCardByGpioCD)
-    {
-        if (card->usrParam.cd->cardDetected == NULL)
-        {
-            return false;
-        }
-        return card->usrParam.cd->cardDetected();
-    }
-    else
-    {
-        if (card->isHostReady == false)
-        {
-            return false;
-        }
-
-        if (SDMMCHOST_CardDetectStatus(card->host) == (uint32_t)kSD_Removed)
-        {
-            return false;
-        }
-    }
-
-    return true;
-}
-
-void SDIO_SetCardPower(sdio_card_t *card, bool enable)
-{
-    assert(card != NULL);
-
-    uint32_t powerDelay = 0U;
-
-    if (card->usrParam.pwr != NULL)
-    {
-        card->usrParam.pwr(enable);
-    }
-    else
-    {
-        SDMMCHOST_SetCardPower(card->host, enable);
-    }
-
-    if (enable)
-    {
-        powerDelay = card->usrParam.powerOnDelayMS == 0U ? SDIO_POWER_ON_DELAY : card->usrParam.powerOnDelayMS;
-    }
-    else
-    {
-        powerDelay = card->usrParam.powerOffDelayMS == 0U ? SDIO_POWER_OFF_DELAY : card->usrParam.powerOffDelayMS;
-    }
-
-    SDMMC_OSADelay(powerDelay);
-}
-
-status_t SDIO_Init(sdio_card_t *card)
-{
-    assert(card != NULL);
-    assert(card->host != NULL);
-
-    status_t error = kStatus_Success;
-
-    if (!card->isHostReady)
-    {
-        if (SDIO_HostInit(card) != kStatus_Success)
-        {
-            error = kStatus_SDMMC_HostNotReady;
-        }
-    }
-    else
-    {
-        /* reset the host */
-        SDIO_HostDoReset(card);
-    }
-
-    if (error == kStatus_Success)
-    {
-        /* card detect */
-        if (SDIO_PollingCardInsert(card, kSD_Inserted) != kStatus_Success)
-        {
-            error = kStatus_SDMMC_CardDetectFailed;
-        }
-        else
-        {
-            error = SDIO_CardInit(card);
-            if (error != kStatus_Success)
-            {
-                error = kStatus_SDMMC_CardInitFailed;
-            }
-        }
-    }
-
-    return error;
-}
-
-void SDIO_Deinit(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    SDIO_CardDeinit(card);
-    SDIO_HostDeinit(card);
-}
-
-status_t SDIO_EnableIOInterrupt(sdio_card_t *card, sdio_func_num_t func, bool enable)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    uint8_t intEn  = 0U;
-    status_t error = kStatus_Success;
-
-    /* load io interrupt enable register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegIOIntEnable, 0U, &intEn, false);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    if (enable)
-    {
-        /* if already enable , do not need enable again */
-        if ((((intEn >> (uint32_t)func) & 0x01U) == 0x01U) && ((intEn & 0x01U) != 0U))
-        {
-            return kStatus_Success;
-        }
-
-        /* enable the interrupt and interrupt master */
-        intEn |= (1U << (uint32_t)func) | 0x01U;
-        card->ioIntNums++;
-    }
-    else
-    {
-        /* if already disable , do not need enable again */
-        if (((intEn >> (uint32_t)func) & 0x01U) == 0x00U)
-        {
-            return kStatus_Success;
-        }
-
-        /* disable the interrupt, don't disable the interrupt master here */
-        intEn &= ~(1U << (uint32_t)func);
-        if (card->ioIntNums != 0U)
-        {
-            card->ioIntNums--;
-        }
-    }
-
-    /* write to register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegIOIntEnable, intEn, &intEn, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_GetPendingInterrupt(sdio_card_t *card, uint8_t *pendingInt)
-{
-    assert(card != NULL);
-
-    status_t error = kStatus_Success;
-
-    /* load io interrupt enable register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegIOIntPending, 0U, pendingInt, false);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_EnableIO(sdio_card_t *card, sdio_func_num_t func, bool enable)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-    assert(func != kSDIO_FunctionNum0);
-
-    uint8_t ioEn = 0U, ioReady = 0U;
-    volatile uint32_t i = SDIO_RETRY_TIMES;
-    uint32_t ioReadyTimeoutMS =
-        (uint32_t)card->funcCIS[(uint32_t)func - 1U].ioReadyTimeout * SDIO_IO_READY_TIMEOUT_UNIT;
-    status_t error = kStatus_Success;
-
-    if (ioReadyTimeoutMS != 0U)
-    {
-        /* do not poll the IO ready status, but use IO ready timeout  */
-        i = 1U;
-    }
-
-    /* load io enable register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegIOEnable, 0U, &ioEn, false);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-    /* if already enable/disable , do not need enable/disable again */
-    if (((ioEn >> (uint8_t)func) & 0x01U) == (enable ? 1U : 0U))
-    {
-        return kStatus_Success;
-    }
-
-    /* enable the io */
-    if (enable)
-    {
-        ioEn |= (1U << (uint32_t)func);
-    }
-    else
-    {
-        ioEn &= ~(1U << (uint32_t)func);
-    }
-
-    /* write to register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegIOEnable, ioEn, &ioEn, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    /* if enable io, need check the IO ready status */
-    if (enable)
-    {
-        do
-        {
-            SDMMC_OSADelay(ioReadyTimeoutMS);
-            /* wait IO ready */
-            error =
-                SDIO_IO_Access_Direct(card, kSDIO_IORead, kSDIO_FunctionNum0, kSDIO_RegIOReady, 0U, &ioReady, false);
-            if (kStatus_Success != error)
-            {
-                return kStatus_SDMMC_TransferFailed;
-            }
-            /* check if IO ready */
-            if ((ioReady & (1U << (uint32_t)func)) != 0U)
-            {
-                return kStatus_Success;
-            }
-
-            i--;
-        } while (i != 0U);
-
-        return kStatus_Fail;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_SelectIO(sdio_card_t *card, sdio_func_num_t func)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionMemory);
-
-    uint8_t ioSel  = (uint8_t)func;
-    status_t error = kStatus_Success;
-
-    /* write to register */
-    error =
-        SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegFunctionSelect, ioSel, &ioSel, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-status_t SDIO_AbortIO(sdio_card_t *card, sdio_func_num_t func)
-{
-    assert(card != NULL);
-    assert(func <= kSDIO_FunctionNum7);
-
-    uint8_t ioAbort = (uint8_t)func;
-    status_t error  = kStatus_Success;
-
-    /* write to register */
-    error = SDIO_IO_Access_Direct(card, kSDIO_IOWrite, kSDIO_FunctionNum0, kSDIO_RegIOAbort, ioAbort, &ioAbort, true);
-    if (kStatus_Success != error)
-    {
-        return kStatus_SDMMC_TransferFailed;
-    }
-
-    return kStatus_Success;
-}
-
-void SDIO_SetIOIRQHandler(sdio_card_t *card, sdio_func_num_t func, sdio_io_irq_handler_t handler)
-{
-    assert(card != NULL);
-    assert((func <= kSDIO_FunctionNum7) && (func != kSDIO_FunctionNum0));
-
-    card->ioIRQHandler[(uint32_t)func - 1U] = handler;
-    card->ioIntIndex                        = (uint8_t)func;
-}
-
-status_t SDIO_HandlePendingIOInterrupt(sdio_card_t *card)
-{
-    assert(card != NULL);
-
-    uint8_t i = 0, pendingInt = 0;
-
-    /* call IRQ handler directly if one IRQ handler only */
-    if (card->ioIntNums == 1U)
-    {
-        if (card->ioIRQHandler[card->ioIntIndex - 1U] != NULL)
-        {
-            (card->ioIRQHandler[card->ioIntIndex - 1U])(card, card->ioIntIndex);
-        }
-    }
-    else
-    {
-        /* get pending int firstly */
-        if (SDIO_GetPendingInterrupt(card, &pendingInt) != kStatus_Success)
-        {
-            return kStatus_SDMMC_TransferFailed;
-        }
-
-        for (i = 1; i <= FSL_SDIO_MAX_IO_NUMS; i++)
-        {
-            if ((pendingInt & (1U << i)) != 0U)
-            {
-                if ((card->ioIRQHandler[i - 1U]) != NULL)
-                {
-                    (card->ioIRQHandler[i - 1U])(card, i);
-                }
-            }
-        }
-    }
-
-    return kStatus_Success;
-}

+ 0 - 529
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/sdio/fsl_sdio.h

@@ -1,529 +0,0 @@
-/*
- * Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-#ifndef _FSL_SDIO_H_
-#define _FSL_SDIO_H_
-
-#include "fsl_sdmmc_common.h"
-
-/*!
- * @addtogroup sdiocard SDIO Card Driver
- * @ingroup card
- * @{
- */
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*! @brief Middleware version. */
-#define FSL_SDIO_DRIVER_VERSION (MAKE_VERSION(2U, 4U, 0U)) /*2.4.0*/
-
-/*!@brief sdio device support maximum IO number */
-#ifndef FSL_SDIO_MAX_IO_NUMS
-#define FSL_SDIO_MAX_IO_NUMS (7U)
-#endif
-/*!@brief sdio card descriptor */
-typedef struct _sdio_card sdio_card_t;
-/*!@brief sdio io handler */
-typedef void (*sdio_io_irq_handler_t)(sdio_card_t *card, uint32_t func);
-/*! @brief sdio io read/write direction */
-typedef enum _sdio_io_direction
-{
-    kSDIO_IORead  = 0U, /*!< io read */
-    kSDIO_IOWrite = 1U, /*!< io write */
-} sdio_io_direction_t;
-
-/*!
- * @brief SDIO card state
- *
- * Define the card structure including the necessary fields to identify and describe the card.
- */
-struct _sdio_card
-{
-    sdmmchost_t *host;         /*!< Host information */
-    sdio_usr_param_t usrParam; /*!< user parameter */
-    bool noInternalAlign;      /*!< use this flag to disable sdmmc align. If disable, sdmmc will not make sure the
-                              data buffer address is word align, otherwise all the transfer are align to low level driver */
-    uint8_t internalBuffer[FSL_SDMMC_CARD_INTERNAL_BUFFER_SIZE]; /*!< internal buffer */
-
-    bool isHostReady;    /*!< use this flag to indicate if need host re-init or not*/
-    bool memPresentFlag; /*!< indicate if memory present */
-
-    uint32_t busClock_Hz;                       /*!< SD bus clock frequency united in Hz */
-    uint32_t relativeAddress;                   /*!< Relative address of the card */
-    uint8_t sdVersion;                          /*!< SD version */
-    sd_timing_mode_t currentTiming;             /*!< current timing mode */
-    sd_driver_strength_t driverStrength;        /*!< driver strength */
-    sd_max_current_t maxCurrent;                /*!< card current limit */
-    sdmmc_operation_voltage_t operationVoltage; /*!< card operation voltage */
-
-    uint8_t sdioVersion;         /*!< SDIO version */
-    uint8_t cccrVersioin;        /*!< CCCR version */
-    uint8_t ioTotalNumber;       /*!< total number of IO function */
-    uint32_t cccrflags;          /*!< Flags in _sd_card_flag */
-    uint32_t io0blockSize;       /*!< record the io0 block size*/
-    uint32_t ocr;                /*!< Raw OCR content, only 24bit avalible for SDIO card */
-    uint32_t commonCISPointer;   /*!< point to common CIS */
-    sdio_common_cis_t commonCIS; /*!< CIS table */
-
-    /* io registers/IRQ handler */
-    sdio_fbr_t ioFBR[FSL_SDIO_MAX_IO_NUMS];                   /*!< FBR table */
-    sdio_func_cis_t funcCIS[FSL_SDIO_MAX_IO_NUMS];            /*!< function CIS table*/
-    sdio_io_irq_handler_t ioIRQHandler[FSL_SDIO_MAX_IO_NUMS]; /*!< io IRQ handler */
-    uint8_t ioIntIndex;                                       /*!< used to record current enabled io interrupt index */
-    uint8_t ioIntNums;                                        /*!< used to record total enabled io interrupt numbers  */
-    sdmmc_osa_mutex_t lock;                                   /*!< card access lock */
-};
-
-/*************************************************************************************************
- * API
- ************************************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-/*!
- * @name Initialization and deinitialization
- * @{
- */
-
-/*!
- * @brief SDIO card init function
- *
- *
- * Thread safe function, please note that the function will create the mutex lock dynamically by default,
- * so to avoid the mutex create redundantly, application must follow bellow sequence for card re-initialization
- * @code
- * SDIO_Deinit(card);
- * SDIO_Init(card);
- * @endcode
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_GoIdleFailed
- * @retval kStatus_SDMMC_HandShakeOperationConditionFailed
- * @retval kStatus_SDMMC_SDIO_InvalidCard
- * @retval kStatus_SDMMC_SDIO_InvalidVoltage
- * @retval kStatus_SDMMC_SendRelativeAddressFailed
- * @retval kStatus_SDMMC_SelectCardFailed
- * @retval kStatus_SDMMC_SDIO_SwitchHighSpeedFail
- * @retval kStatus_SDMMC_SDIO_ReadCISFail
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_Init(sdio_card_t *card);
-
-/*!
- * @brief SDIO card deinit, include card and host deinit.
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- */
-void SDIO_Deinit(sdio_card_t *card);
-
-/*!
- * @brief Initializes the card.
- *
- * This function initializes the card only, make sure the host is ready when call this function,
- * otherwise it will return kStatus_SDMMC_HostNotReady.
- *
- * Thread safe function, please note that the function will create the mutex lock dynamically by default,
- * so to avoid the mutex create redundantly, application must follow bellow sequence for card re-initialization
- * @code
- * SDIO_CardDeinit(card);
- * SDIO_CardInit(card);
- * @endcode
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_HostNotReady host is not ready.
- * @retval kStatus_SDMMC_GoIdleFailed Go idle failed.
- * @retval kStatus_SDMMC_NotSupportYet Card not support.
- * @retval kStatus_SDMMC_SendOperationConditionFailed Send operation condition failed.
- * @retval kStatus_SDMMC_AllSendCidFailed Send CID failed.
- * @retval kStatus_SDMMC_SendRelativeAddressFailed Send relative address failed.
- * @retval kStatus_SDMMC_SendCsdFailed Send CSD failed.
- * @retval kStatus_SDMMC_SelectCardFailed Send SELECT_CARD command failed.
- * @retval kStatus_SDMMC_SendScrFailed Send SCR failed.
- * @retval kStatus_SDMMC_SetBusWidthFailed Set bus width failed.
- * @retval kStatus_SDMMC_SwitchHighSpeedFailed Switch high speed failed.
- * @retval kStatus_SDMMC_SetCardBlockSizeFailed Set card block size failed.
- * @retval kStatus_Success Operate successfully.
- */
-status_t SDIO_CardInit(sdio_card_t *card);
-
-/*!
- * @brief Deinitializes the card.
- *
- * This function deinitializes the specific card.
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- */
-void SDIO_CardDeinit(sdio_card_t *card);
-
-/*!
- * @brief initialize the host.
- *
- * This function deinitializes the specific host.
- *
- * @param card Card descriptor.
- */
-status_t SDIO_HostInit(sdio_card_t *card);
-
-/*!
- * @brief Deinitializes the host.
- *
- * This function deinitializes the host.
- *
- * @param card Card descriptor.
- */
-void SDIO_HostDeinit(sdio_card_t *card);
-
-/*!
- * @brief reset the host.
- *
- * This function reset the specific host.
- *
- * @param card Card descriptor.
- */
-void SDIO_HostDoReset(sdio_card_t *card);
-
-/*!
- * @brief set card power.
- *
- * The power off operation depend on host or the user define power on function.
- * @param card card descriptor.
- * @param enable true is power on, false is power off.
- */
-void SDIO_SetCardPower(sdio_card_t *card, bool enable);
-
-/*!
- * @brief set SDIO card to inactive state
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_CardInActive(sdio_card_t *card);
-
-/*!
- * @brief get SDIO card capability
- *
- * @param card Card descriptor.
- * @param func IO number
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_GetCardCapability(sdio_card_t *card, sdio_func_num_t func);
-
-/*!
- * @brief set SDIO card block size
- *
- * @param card Card descriptor.
- * @param func io number
- * @param blockSize block size
- * @retval kStatus_SDMMC_SetCardBlockSizeFailed
- * @retval kStatus_SDMMC_SDIO_InvalidArgument
- * @retval kStatus_Success
- */
-status_t SDIO_SetBlockSize(sdio_card_t *card, sdio_func_num_t func, uint32_t blockSize);
-
-/*!
- * @brief set SDIO card reset
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_CardReset(sdio_card_t *card);
-
-/*!
- * @brief set SDIO card data bus width
- *
- * @param card Card descriptor.
- * @param busWidth bus width
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_SetDataBusWidth(sdio_card_t *card, sdio_bus_width_t busWidth);
-
-/*!
- * @brief switch the card to high speed
- *
- * @param card Card descriptor.
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_SDMMC_SDIO_SwitchHighSpeedFail
- * @retval kStatus_Success
- */
-status_t SDIO_SwitchToHighSpeed(sdio_card_t *card);
-
-/*!
- * @brief read SDIO card CIS for each function
- *
- * @param card Card descriptor.
- * @param func io number
- * @param tupleList code list
- * @param tupleNum code number
- * @retval kStatus_SDMMC_SDIO_ReadCISFail
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_ReadCIS(sdio_card_t *card, sdio_func_num_t func, const uint32_t *tupleList, uint32_t tupleNum);
-
-/*!
- * @brief sdio wait card detect function.
- *
- * Detect card through GPIO, CD, DATA3.
- * @param card card descriptor.
- * @param status detect status, kSD_Inserted or kSD_Removed.
- */
-status_t SDIO_PollingCardInsert(sdio_card_t *card, uint32_t status);
-
-/*!
- * @brief sdio card present check function.
- *
- * @param card card descriptor.
- */
-bool SDIO_IsCardPresent(sdio_card_t *card);
-
-/* @} */
-
-/*!
- * @name IO operations
- * @{
- */
-
-/*!
- * @brief IO direct write transfer function
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- * @param func IO numner
- * @param regAddr register address
- * @param data the data pinter to write
- * @param raw flag, indicate read after write or write only
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_IO_Write_Direct(sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *data, bool raw);
-
-/*!
- * @brief IO direct read transfer function
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- * @param func IO number
- * @param regAddr register address
- * @param data pointer to read
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_IO_Read_Direct(sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *data);
-
-/*!
- * @brief IO direct read/write transfer function
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- * @param direction io access direction, please reference sdio_io_direction_t.
- * @param func IO number
- * @param regAddr register address
- * @param dataIn data to write
- * @param dataOut data pointer for readback data, support both for read and write, when application want readback
- * the data after write command, dataOut should not be NULL.
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-
-status_t SDIO_IO_RW_Direct(sdio_card_t *card,
-                           sdio_io_direction_t direction,
-                           sdio_func_num_t func,
-                           uint32_t regAddr,
-                           uint8_t dataIn,
-                           uint8_t *dataOut);
-
-/*!
- * @brief IO extended write transfer function
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- * @param func IO number
- * @param regAddr register address
- * @param buffer data buffer to write
- * @param count data count
- * @param flags write flags
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_SDMMC_SDIO_InvalidArgument
- * @retval kStatus_Success
- */
-status_t SDIO_IO_Write_Extended(
-    sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *buffer, uint32_t count, uint32_t flags);
-/*!
- * @brief IO extended read transfer function
- *
- * Please note it is a thread safe function.
- *
- * @param card Card descriptor.
- * @param func IO number
- * @param regAddr register address
- * @param buffer data buffer to read
- * @param count data count
- * @param flags write flags
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_SDMMC_SDIO_InvalidArgument
- * @retval kStatus_Success
- */
-status_t SDIO_IO_Read_Extended(
-    sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *buffer, uint32_t count, uint32_t flags);
-/*!
- * @brief enable IO interrupt
- *
- * @param card Card descriptor.
- * @param func IO number
- * @param enable enable/disable flag
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_EnableIOInterrupt(sdio_card_t *card, sdio_func_num_t func, bool enable);
-
-/*!
- * @brief enable IO and wait IO ready
- *
- * @param card Card descriptor.
- * @param func IO number
- * @param enable enable/disable flag
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_EnableIO(sdio_card_t *card, sdio_func_num_t func, bool enable);
-
-/*!
- * @brief select IO
- *
- * @param card Card descriptor.
- * @param func IO number
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_SelectIO(sdio_card_t *card, sdio_func_num_t func);
-
-/*!
- * @brief Abort IO transfer
- *
- * @param card Card descriptor.
- * @param func IO number
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_AbortIO(sdio_card_t *card, sdio_func_num_t func);
-
-/*!
- * @brief Set driver strength.
- *
- * @param card Card descriptor.
- * @param driverStrength target driver strength.
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_SetDriverStrength(sdio_card_t *card, sd_driver_strength_t driverStrength);
-
-/*!
- * @brief Enable/Disable Async interrupt.
- *
- * @param card Card descriptor.
- * @param enable true is enable, false is disable.
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_EnableAsyncInterrupt(sdio_card_t *card, bool enable);
-
-/*!
- * @brief Get pending interrupt.
- *
- * @param card Card descriptor.
- * @param pendingInt pointer store pending interrupt
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_GetPendingInterrupt(sdio_card_t *card, uint8_t *pendingInt);
-
-/*!
- * @brief sdio card io transfer function.
- * This function can be used for trnansfer direct/extend command.
- * Please pay attention to the non-align data buffer address transfer,
- * if data buffer address can not meet host controller internal DMA requirement, sdio driver will try to use
- * internal align buffer if data size is not bigger than internal buffer size,
- * Align address transfer always can get a better performance, so if application want sdio driver make sure buffer
- * address align,
- *
- * Please note it is a thread safe function.
- *
- * @param card card descriptor.
- * @param cmd command to transfer
- * @param argument argument to transfer
- * @param blockSize used for block mode.
- * @param txData tx buffer pointer or NULL
- * @param rxData rx buffer pointer or NULL
- * @param dataSize transfer data size
- * @param response reponse pointer, if application want read response back, please set it to a NON-NULL pointer.
-
- */
-status_t SDIO_IO_Transfer(sdio_card_t *card,
-                          sdio_command_t cmd,
-                          uint32_t argument,
-                          uint32_t blockSize,
-                          uint8_t *txData,
-                          uint8_t *rxData,
-                          uint16_t dataSize,
-                          uint32_t *response);
-
-/*!
- * @brief sdio set io IRQ handler.
- *
- * @param card card descriptor.
- * @param func function io number.
- * @param handler io IRQ handler.
- */
-void SDIO_SetIOIRQHandler(sdio_card_t *card, sdio_func_num_t func, sdio_io_irq_handler_t handler);
-
-/*!
- * @brief sdio card io pending interrupt handle function.
- * This function is used to handle the pending io interrupt.
- * To reigster a IO IRQ handler,
- * @code
- * SDIO_EnableIOInterrupt(card, 0, true);
- * SDIO_SetIOIRQHandler(card, 0, func0_handler);
- * @endcode
- * call it in interrupt callback
- * @code
- * SDIO_HandlePendingIOInterrupt(card);
- * @endcode
- * To releae a IO IRQ handler,
- * @code
- * SDIO_EnableIOInterrupt(card, 0, false);
- * SDIO_SetIOIRQHandler(card, 0, NULL);
- * @endcode
- * @param card card descriptor.
- *
- * @retval kStatus_SDMMC_TransferFailed
- * @retval kStatus_Success
- */
-status_t SDIO_HandlePendingIOInterrupt(sdio_card_t *card);
-
-/* @} */
-
-#if defined(__cplusplus)
-}
-#endif
-
-/* @} */
-
-#endif /* _FSL_SDIO_H_*/

+ 0 - 58
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdhc/sdmmc_config.c

@@ -1,58 +0,0 @@
-/*
- * Copyright 2021 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "sdmmc_config.h"
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-/*!brief sdmmc dma buffer */
-SDK_ALIGN(uint32_t s_sdmmcHostDmaBuffer[BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE],
-          SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE);
-#if defined(SDIO_ENABLED) || defined(SD_ENABLED)
-static sd_detect_card_t s_cd;
-#endif
-sdmmchost_t s_host;
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-#ifdef SD_ENABLED
-void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData)
-{
-    assert(card);
-
-    s_host.dmaDesBuffer                                      = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum                              = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    ((sd_card_t *)card)->host                                = &s_host;
-    ((sd_card_t *)card)->host->hostController.base           = BOARD_SDMMC_SD_HOST_BASEADDR;
-    ((sd_card_t *)card)->host->hostController.sourceClock_Hz = CLOCK_GetFreq(kCLOCK_CoreSysClk);
-
-    ((sd_card_t *)card)->usrParam.cd = &s_cd;
-
-    NVIC_SetPriority(BOARD_SDMMC_SD_HOST_IRQ, hostIRQPriority);
-}
-#endif
-
-#ifdef MMC_ENABLED
-void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority)
-{
-    assert(card);
-
-    s_host.dmaDesBuffer                                       = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum                               = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    ((mmc_card_t *)card)->host                                = &s_host;
-    ((mmc_card_t *)card)->host->hostController.base           = BOARD_SDMMC_MMC_HOST_BASEADDR;
-    ((mmc_card_t *)card)->host->hostController.sourceClock_Hz = CLOCK_GetFreq(kCLOCK_CoreSysClk);
-    ((mmc_card_t *)card)->hostVoltageWindowVCC                = BOARD_SDMMC_MMC_VCC_SUPPLY;
-    ((mmc_card_t *)card)->hostVoltageWindowVCCQ               = BOARD_SDMMC_MMC_VCCQ_SUPPLY;
-
-    NVIC_SetPriority(BOARD_SDMMC_MMC_HOST_IRQ, hostIRQPriority);
-}
-#endif

+ 0 - 101
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdhc/sdmmc_config.h

@@ -1,101 +0,0 @@
-/*
- * Copyright 2021 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _SDMMC_CONFIG_H_
-#define _SDMMC_CONFIG_H_
-
-#ifdef SD_ENABLED
-#include "fsl_sd.h"
-#endif
-#ifdef MMC_ENABLED
-#include "fsl_mmc.h"
-#endif
-#include "clock_config.h"
-#include "fsl_sdmmc_host.h"
-#include "fsl_sdmmc_common.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/* @brief host basic configuration */
-#define BOARD_SDMMC_SD_HOST_BASEADDR  SDHC
-#define BOARD_SDMMC_MMC_HOST_BASEADDR SDHC
-
-#define BOARD_SDMMC_SD_HOST_IRQ  SDHC_IRQn
-#define BOARD_SDMMC_MMC_HOST_IRQ SDHC_IRQn
-/* @brief card detect configuration */
-#define BOARD_SDMMC_SD_CD_GPIO_BASE        GPIOB
-#define BOARD_SDMMC_SD_CD_GPIO_PIN         20U
-#define BOARD_SDMMC_SD_CD_PORT_BASE        PORTB
-#define BOARD_SDMMC_SD_CD_PORT_IRQ         PORTB_IRQn
-#define BOARD_SDMMC_SD_CD_IRQ_PRIORITY     6U
-#define BOARD_SDMMC_SD_CD_INTTERUPT_TYPE   kPORT_InterruptEitherEdge
-#define BOARD_SDMMC_SD_CD_INSERT_LEVEL     (0U)
-#define BOARD_SDMMC_SD_CD_PORT_IRQ_HANDLER PORTB_IRQHandler
-/* @brief card detect type
- *
- * Note: if you want to use DAT3 as card detect pin, please pay attention, DAT3 card detection cannot works during the
- * card access, since the DAT3 will be used for data transfer, thus the functionality of card detect interrupt will be
- * disabled as soon as card is detected. So If application would like to re-detect sdcard/sdiocard, please calling
- * SD_PollingCardInsert/SDIO_PollingCardInsert The function will polling the card detect status and could yield CPU
- * while RTOS and non-blocking adapter is using.
- *
- * Using card detect pin for card detection is recommended.
- */
-#define BOARD_SDMMC_SD_CD_TYPE                       kSD_DetectCardByGpioCD
-#define BOARD_SDMMC_SD_CARD_DETECT_DEBOUNCE_DELAY_MS (100U)
-
-#define BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE (4U)
-/* @brief mmc configuration */
-#define BOARD_SDMMC_MMC_VCC_SUPPLY  kMMC_VoltageWindows270to360
-#define BOARD_SDMMC_MMC_VCCQ_SUPPLY kMMC_VoltageWindows270to360
-
-/* @brief The SDSPI configuration. */
-#define BOARD_SDSPI_HOST_BASE         SPI1_BASE /*!< SPI base address for SDSPI */
-#define BOARD_SDSPI_HOST_CD_GPIO_BASE GPIOB     /*!< Port related to card detect pin for SDSPI */
-#define BOARD_SDSPI_HOST_CD_PIN       20U       /*!< Card detect pin for SDSPI */
-
-/*!@ brief host interrupt priority*/
-#define BOARD_SDMMC_SD_HOST_IRQ_PRIORITY  (5U)
-#define BOARD_SDMMC_MMC_HOST_IRQ_PRIORITY (5U)
-/*!@brief dma descriptor buffer size */
-#define BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE (32U)
-
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus */
-
-/*******************************************************************************
- * API
- ******************************************************************************/
-
-/*!
- * @brief BOARD SD configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param userData user data for callback
- */
-#ifdef SD_ENABLED
-void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData);
-#endif
-
-/*!
- * @brief BOARD MMC configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param userData user data for callback
- */
-#ifdef MMC_ENABLED
-void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority);
-
-#endif
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus */
-
-#endif /* _BOARD_H_ */

+ 0 - 115
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdif/sdmmc_config.c

@@ -1,115 +0,0 @@
-/*
- * Copyright 2021 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "sdmmc_config.h"
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-/*!brief sdmmc dma buffer */
-SDK_ALIGN(uint32_t s_sdmmcHostDmaBuffer[BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE],
-          SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE);
-#if defined(SDIO_ENABLED) || defined(SD_ENABLED)
-static sd_detect_card_t s_cd;
-#endif
-static sdmmchost_t s_host;
-#ifdef SDIO_ENABLED
-sdio_card_int_t s_sdioInt;
-#endif
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-void Board_InitSdifUnusedDataPin(void)
-{
-}
-
-uint32_t BOARD_SDIF0ClockConfiguration(void)
-{
-    return 0;
-}
-
-#ifdef SD_ENABLED
-void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData)
-{
-    assert(card);
-
-    s_host.dmaDesBuffer                                      = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum                              = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    ((sd_card_t *)card)->host                                = &s_host;
-    ((sd_card_t *)card)->host->hostController.base           = BOARD_SDMMC_SD_HOST_BASEADDR;
-    ((sd_card_t *)card)->host->hostController.sourceClock_Hz = BOARD_SDIF0ClockConfiguration();
-
-    ((sd_card_t *)card)->usrParam.cd = &s_cd;
-
-    /* This function is used to init the SDIF unused data pin, DATA4 - DATA7, these pin should be configured
-     * ,otherswise the SDIF will not work, please check the corresponding errata.
-     */
-    Board_InitSdifUnusedDataPin();
-
-    NVIC_SetPriority(BOARD_SDMMC_SD_HOST_IRQ, hostIRQPriority);
-}
-#endif
-
-#ifdef SDIO_ENABLED
-void BOARD_SDIO_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, sdio_int_t cardInt)
-{
-    assert(card);
-
-    s_host.dmaDesBuffer                                        = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum                                = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    ((sdio_card_t *)card)->host                                = &s_host;
-    ((sdio_card_t *)card)->host->hostController.base           = BOARD_SDMMC_SDIO_HOST_BASEADDR;
-    ((sdio_card_t *)card)->host->hostController.sourceClock_Hz = BOARD_SDIF0ClockConfiguration();
-
-    ((sdio_card_t *)card)->usrParam.cd = &s_cd;
-    if (cardInt != NULL)
-    {
-        s_sdioInt.cardInterrupt                 = cardInt;
-        ((sdio_card_t *)card)->usrParam.sdioInt = &s_sdioInt;
-    }
-
-    /* This function is used to init the SDIF unused data pin, DATA4 - DATA7, these pin should be configured
-     * ,otherswise the SDIF will not work, please check the corresponding errata.
-     */
-    Board_InitSdifUnusedDataPin();
-
-    BOARD_SDCardDetectInit(cd, NULL);
-
-    NVIC_SetPriority(BOARD_SDMMC_SDIO_HOST_IRQ, hostIRQPriority);
-}
-#endif
-
-#ifdef MMC_ENABLED
-void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority)
-
-{
-    assert(card);
-
-    s_host.dmaDesBuffer                                       = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum                               = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    ((mmc_card_t *)card)->host                                = &s_host;
-    ((mmc_card_t *)card)->host->hostController.base           = BOARD_SDMMC_MMC_HOST_BASEADDR;
-    ((mmc_card_t *)card)->host->hostController.sourceClock_Hz = BOARD_SDIF0ClockConfiguration();
-
-    ((mmc_card_t *)card)->hostVoltageWindowVCC  = BOARD_SDMMC_MMC_VCC_SUPPLY;
-    ((mmc_card_t *)card)->hostVoltageWindowVCCQ = BOARD_SDMMC_MMC_VCCQ_SUPPLY;
-
-    /* This function is used to init the SDIF unused data pin, DATA4 - DATA7, these pin should be configured
-     * ,otherswise the SDIF will not work, please check the corresponding errata.
-     */
-    Board_InitSdifUnusedDataPin();
-
-    NVIC_SetPriority(BOARD_SDMMC_MMC_HOST_IRQ, hostIRQPriority);
-}
-#endif

+ 0 - 92
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/sdif/sdmmc_config.h

@@ -1,92 +0,0 @@
-/*
- * Copyright 2021 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _SDMMC_CONFIG_H_
-#define _SDMMC_CONFIG_H_
-
-#ifdef SD_ENABLED
-#include "fsl_sd.h"
-#endif
-#ifdef MMC_ENABLED
-#include "fsl_mmc.h"
-#endif
-#ifdef SDIO_ENABLED
-#include "fsl_sdio.h"
-#endif
-#include "clock_config.h"
-#include "fsl_sdmmc_host.h"
-#include "fsl_sdmmc_common.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/* @brief host basic configuration */
-#define BOARD_SDMMC_SD_HOST_BASEADDR   SDIF
-#define BOARD_SDMMC_SD_HOST_IRQ        SDIO_IRQn
-#define BOARD_SDMMC_MMC_HOST_BASEADDR  SDIF
-#define BOARD_SDMMC_MMC_HOST_IRQ       SDIO_IRQn
-#define BOARD_SDMMC_SDIO_HOST_BASEADDR SDIF
-#define BOARD_SDMMC_SDIO_HOST_IRQ      SDIO_IRQn
-/* @brief card detect configuration */
-#define BOARD_SDMMC_SD_CD_TYPE                       kSD_DetectCardByHostCD
-#define BOARD_SDMMC_SD_CARD_DETECT_DEBOUNCE_DELAY_MS (100U)
-
-/* @brief mmc configuration */
-#define BOARD_SDMMC_MMC_VCC_SUPPLY         kMMC_VoltageWindows270to360
-#define BOARD_SDMMC_MMC_VCCQ_SUPPLY        kMMC_VoltageWindows270to360
-#define BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE (4U)
-
-/*!@ brief host interrupt priority*/
-#define BOARD_SDMMC_SD_HOST_IRQ_PRIORITY   (5U)
-#define BOARD_SDMMC_MMC_HOST_IRQ_PRIORITY  (5U)
-#define BOARD_SDMMC_SDIO_HOST_IRQ_PRIORITY (5U)
-/*!@brief dma descriptor buffer size */
-#define BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE (0x40U)
-
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus */
-
-/*******************************************************************************
- * API
- ******************************************************************************/
-/*!
- * @brief BOARD SD configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param userData user data for callback
- */
-#ifdef SD_ENABLED
-void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData);
-#endif
-
-/*!
- * @brief BOARD SDIO configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param cardInt card interrupt
- */
-#ifdef SDIO_ENABLED
-void BOARD_SDIO_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, sdio_int_t cardInt);
-#endif
-
-/*!
- * @brief BOARD MMC configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param userData user data for callback
- */
-#ifdef MMC_ENABLED
-void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority);
-
-#endif
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus */
-
-#endif /* _BOARD_H_ */

+ 0 - 149
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/usdhc/sdmmc_config.c

@@ -1,149 +0,0 @@
-/*
- * Copyright 2020 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "sdmmc_config.h"
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-
-/*******************************************************************************
- * Prototypes
- ******************************************************************************/
-void BOARD_SDCardPowerControl(bool enable);
-
-/*******************************************************************************
- * Variables
- ******************************************************************************/
-/*!brief sdmmc dma buffer */
-AT_NONCACHEABLE_SECTION_ALIGN(uint32_t s_sdmmcHostDmaBuffer[BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE],
-                              SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE);
-#if defined SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER && SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER
-/* two cache line length for sdmmc host driver maintain unalign transfer */
-SDK_ALIGN(static uint8_t s_sdmmcCacheLineAlignBuffer[BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE * 2U],
-          BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE);
-#endif
-#if defined(SDIO_ENABLED) || defined(SD_ENABLED)
-static sd_detect_card_t s_cd;
-static sd_io_voltage_t s_ioVoltage = {
-    .type = BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE,
-    .func = NULL,
-};
-#endif
-sdmmchost_t s_host;
-#ifdef SDIO_ENABLED
-static sdio_card_int_t s_sdioInt;
-#endif
-
-/*******************************************************************************
- * Code
- ******************************************************************************/
-uint32_t BOARD_USDHC1ClockConfiguration(void)
-{
-    return 0;
-}
-
-#if defined(SDIO_ENABLED) || defined(SD_ENABLED)
-void BOARD_SDCardPowerControl(bool enable)
-{
-}
-
-void BOARD_SD_Pin_Config(uint32_t freq)
-{
-}
-#endif
-
-#ifdef SD_ENABLED
-void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData)
-{
-    assert(card);
-
-    s_host.dmaDesBuffer         = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    s_host.enableCacheControl   = BOARD_SDMMC_HOST_CACHE_CONTROL;
-#if defined SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER && SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER
-    s_host.cacheAlignBuffer     = s_sdmmcCacheLineAlignBuffer;
-    s_host.cacheAlignBufferSize = BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE * 2U;
-#endif
-
-    ((sd_card_t *)card)->host                                = &s_host;
-    ((sd_card_t *)card)->host->hostController.base           = BOARD_SDMMC_SD_HOST_BASEADDR;
-    ((sd_card_t *)card)->host->hostController.sourceClock_Hz = BOARD_USDHC1ClockConfiguration();
-
-    ((sd_card_t *)card)->usrParam.cd         = &s_cd;
-    ((sd_card_t *)card)->usrParam.pwr        = BOARD_SDCardPowerControl;
-    ((sd_card_t *)card)->usrParam.ioStrength = BOARD_SD_Pin_Config;
-    ((sd_card_t *)card)->usrParam.ioVoltage  = &s_ioVoltage;
-    ((sd_card_t *)card)->usrParam.maxFreq    = BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ;
-
-    NVIC_SetPriority(BOARD_SDMMC_SD_HOST_IRQ, hostIRQPriority);
-}
-#endif
-
-#ifdef SDIO_ENABLED
-void BOARD_SDIO_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, sdio_int_t cardInt)
-{
-    assert(card);
-
-    s_host.dmaDesBuffer         = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    s_host.enableCacheControl   = BOARD_SDMMC_HOST_CACHE_CONTROL;
-#if defined SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER && SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER
-    s_host.cacheAlignBuffer     = s_sdmmcCacheLineAlignBuffer;
-    s_host.cacheAlignBufferSize = BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE * 2U;
-#endif
-
-    ((sdio_card_t *)card)->host                                = &s_host;
-    ((sdio_card_t *)card)->host->hostController.base           = BOARD_SDMMC_SDIO_HOST_BASEADDR;
-    ((sdio_card_t *)card)->host->hostController.sourceClock_Hz = BOARD_USDHC1ClockConfiguration();
-
-    ((sdio_card_t *)card)->usrParam.cd         = &s_cd;
-    ((sdio_card_t *)card)->usrParam.pwr        = BOARD_SDCardPowerControl;
-    ((sdio_card_t *)card)->usrParam.ioStrength = BOARD_SD_Pin_Config;
-    ((sdio_card_t *)card)->usrParam.ioVoltage  = &s_ioVoltage;
-    ((sdio_card_t *)card)->usrParam.maxFreq    = BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ;
-    if (cardInt != NULL)
-    {
-        s_sdioInt.cardInterrupt                 = cardInt;
-        ((sdio_card_t *)card)->usrParam.sdioInt = &s_sdioInt;
-    }
-
-    BOARD_SDCardPowerResetInit();
-    BOARD_SDCardDetectInit(cd, NULL);
-
-    NVIC_SetPriority(BOARD_SDMMC_SDIO_HOST_IRQ, hostIRQPriority);
-}
-#endif
-
-#ifdef MMC_ENABLED
-static void BOARD_MMC_Pin_Config(uint32_t freq)
-{
-}
-
-void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority)
-{
-    assert(card);
-
-    s_host.dmaDesBuffer         = s_sdmmcHostDmaBuffer;
-    s_host.dmaDesBufferWordsNum = BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE;
-    s_host.enableCacheControl   = BOARD_SDMMC_HOST_CACHE_CONTROL;
-#if defined SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER && SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER
-    s_host.cacheAlignBuffer     = s_sdmmcCacheLineAlignBuffer;
-    s_host.cacheAlignBufferSize = BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE * 2U;
-#endif
-
-    ((mmc_card_t *)card)->host                                = &s_host;
-    ((mmc_card_t *)card)->host->hostController.base           = BOARD_SDMMC_MMC_HOST_BASEADDR;
-    ((mmc_card_t *)card)->host->hostController.sourceClock_Hz = BOARD_USDHC1ClockConfiguration();
-    ((mmc_card_t *)card)->usrParam.ioStrength                 = BOARD_MMC_Pin_Config;
-    ((mmc_card_t *)card)->usrParam.maxFreq                    = BOARD_SDMMC_MMC_HOST_SUPPORT_HS200_FREQ;
-
-    ((mmc_card_t *)card)->hostVoltageWindowVCC  = BOARD_SDMMC_MMC_VCC_SUPPLY;
-    ((mmc_card_t *)card)->hostVoltageWindowVCCQ = BOARD_SDMMC_MMC_VCCQ_SUPPLY;
-
-    NVIC_SetPriority(BOARD_SDMMC_MMC_HOST_IRQ, hostIRQPriority);
-}
-#endif

+ 0 - 115
bsp/lpc55sxx/Libraries/LPC55S6X/middleware/sdmmc/template/usdhc/sdmmc_config.h

@@ -1,115 +0,0 @@
-/*
- * Copyright 2021 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _SDMMC_CONFIG_H_
-#define _SDMMC_CONFIG_H_
-
-#ifdef SD_ENABLED
-#include "fsl_sd.h"
-#endif
-#ifdef MMC_ENABLED
-#include "fsl_mmc.h"
-#endif
-#ifdef SDIO_ENABLED
-#include "fsl_sdio.h"
-#endif
-#include "clock_config.h"
-#include "fsl_sdmmc_host.h"
-#include "fsl_sdmmc_common.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-/* @brief host basic configuration */
-#define BOARD_SDMMC_SD_HOST_BASEADDR   USDHC1
-#define BOARD_SDMMC_SD_HOST_IRQ        USDHC1_IRQn
-#define BOARD_SDMMC_MMC_HOST_BASEADDR  USDHC1
-#define BOARD_SDMMC_MMC_HOST_IRQ       USDHC1_IRQn
-#define BOARD_SDMMC_SDIO_HOST_BASEADDR USDHC1
-#define BOARD_SDMMC_SDIO_HOST_IRQ      USDHC1_IRQn
-/* @brief card detect configuration */
-#define BOARD_SDMMC_SD_CD_GPIO_BASE        GPIO2
-#define BOARD_SDMMC_SD_CD_GPIO_PIN         28u
-#define BOARD_SDMMC_SD_CD_IRQ_PRIORITY     6U
-#define BOARD_SDMMC_SD_CD_IRQ              GPIO2_Combined_16_31_IRQn
-#define BOARD_SDMMC_SD_CD_INTTERUPT_TYPE   kGPIO_IntRisingOrFallingEdge
-#define BOARD_SDMMC_SD_CD_INSERT_LEVEL     (0U)
-#define BOARD_SDMMC_SD_CD_PORT_IRQ_HANDLER GPIO2_Combined_16_31_IRQHandler
-/* @brief card detect type
- *
- * Note: Please pay attention, DAT3 card detection cannot works during the card access,
- * since the DAT3 will be used for data transfer, thus the functionality of card detect will be disabled. Using card
- * detect pin for card detection is recommended.
- */
-#define BOARD_SDMMC_SD_CD_TYPE                       kSD_DetectCardByGpioCD
-#define BOARD_SDMMC_SD_CARD_DETECT_DEBOUNCE_DELAY_MS (100U)
-/*! @brief SD power reset */
-#define BOARD_SDMMC_SD_POWER_RESET_GPIO_BASE GPIO1
-#define BOARD_SDMMC_SD_POWER_RESET_GPIO_PIN  5U
-/*! @brief SD IO voltage */
-#define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlByHost
-
-#define BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ (200000000U)
-#define BOARD_SDMMC_MMC_HOST_SUPPORT_HS200_FREQ (180000000U)
-/*! @brief mmc configuration */
-#define BOARD_SDMMC_MMC_VCC_SUPPLY  kMMC_VoltageWindows270to360
-#define BOARD_SDMMC_MMC_VCCQ_SUPPLY kMMC_VoltageWindows270to360
-/*! @brief align with cache line size */
-#define BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE (32U)
-
-/*!@ brief host interrupt priority*/
-#define BOARD_SDMMC_SD_HOST_IRQ_PRIORITY   (5U)
-#define BOARD_SDMMC_MMC_HOST_IRQ_PRIORITY  (5U)
-#define BOARD_SDMMC_SDIO_HOST_IRQ_PRIORITY (5U)
-/*!@brief dma descriptor buffer size */
-#define BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE (32U)
-/*! @brief cache maintain function enabled for RW buffer */
-#define BOARD_SDMMC_HOST_CACHE_CONTROL kSDMMCHOST_CacheControlRWBuffer
-
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus */
-
-/*******************************************************************************
- * API
- ******************************************************************************/
-/*!
- * @brief BOARD SD configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param userData user data for callback
- */
-#ifdef SD_ENABLED
-void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData);
-#endif
-
-/*!
- * @brief BOARD SDIO configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param cardInt card interrupt
- */
-#ifdef SDIO_ENABLED
-void BOARD_SDIO_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, sdio_int_t cardInt);
-#endif
-
-/*!
- * @brief BOARD MMC configurations.
- * @param card card descriptor
- * @param cd card detect callback
- * @param userData user data for callback
- */
-#ifdef MMC_ENABLED
-void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority);
-
-#endif
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus */
-
-#endif /* _BOARD_H_ */

+ 1 - 1
bsp/lpc55sxx/Libraries/drivers/SConscript

@@ -23,7 +23,7 @@ if  GetDepend('BSP_USING_SPI'):
     src += ['drv_spi.c']
 
 if  GetDepend('BSP_USING_SDIO'):
-    src += ['drv_sd.c']
+    src += ['drv_sdif.c']
 
 if  GetDepend('BSP_USING_I2C'):
     src += ['drv_i2c.c']

+ 0 - 265
bsp/lpc55sxx/Libraries/drivers/drv_sd.c

@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 2006-2023, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date           Author       Notes
- * 2017-08-08     Yang         the first version
- * 2019-07-19     Magicoe      The first version for LPC55S6x
- */
-
-#include <string.h>
-#include <board.h>
-
-#include "fsl_common.h"
-#include "fsl_iocon.h"
-
-#include "fsl_sdif.h"
-
-#include "fsl_sd.h"
-
-#include "drv_sd.h"
-
-#include <finsh.h>
-#include <dfs.h>
-#include <dfs_fs.h>
-#include "board.h"
-
-static struct mci_device *_mci_device;
-static uint8_t sdio_buffer[1024];
-
-#ifdef RT_USING_SDIO
-
-static rt_err_t rt_mci_init(rt_device_t dev)
-{
-    rt_err_t result = RT_EOK;
-
-    return result;
-}
-
-static rt_err_t rt_mci_open(rt_device_t dev, rt_uint16_t oflag)
-{
-    return RT_EOK;
-}
-
-static rt_err_t rt_mci_close(rt_device_t dev)
-{
-    return RT_EOK;
-}
-
-static rt_size_t rt_mci_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
-{
-    rt_uint8_t status = kStatus_Success;
-    struct mci_device *mci = (struct mci_device *)dev;
-    int ret;
-
-    ret = rt_mutex_take(&mci->lock, RT_WAITING_FOREVER);
-    if (ret == -RT_ETIMEOUT)
-    {
-        rt_kprintf("Take mutex time out.\n");
-        return ret;
-    }
-    else if (ret == -RT_ERROR)
-    {
-        rt_kprintf("Take mutex error.\n");
-        return ret;
-    }
-
-    {
-        /* non-aligned. */
-        uint32_t i;
-        rt_size_t sector_adr;
-        uint8_t* copy_buffer;
-
-        sector_adr = pos;
-        copy_buffer = (uint8_t*)buffer;
-
-        for(i=0; i<size; i++)
-        {
-            status = SD_ReadBlocks(&mci->card, sdio_buffer, sector_adr, 1);
-
-            memcpy(copy_buffer, sdio_buffer, mci->card.blockSize);
-            sector_adr ++;
-            copy_buffer += mci->card.blockSize;
-        }
-    }
-
-    rt_mutex_release(&_mci_device->lock);
-
-    if (status == kStatus_Success) return size;
-
-    return 0;
-}
-
-static rt_size_t rt_mci_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
-{
-    rt_uint8_t status = kStatus_Success;
-    struct mci_device *mci = (struct mci_device *)dev;
-    int ret;
-
-    ret = rt_mutex_take(&mci->lock, RT_WAITING_FOREVER);
-    if (ret == -RT_ETIMEOUT)
-    {
-        rt_kprintf("Take mutex time out.\n");
-        return ret;
-    }
-    else if (ret == -RT_ERROR)
-    {
-        rt_kprintf("Take mutex error.\n");
-        return ret;
-    }
-
-    {
-        /* non-aligned. */
-        uint32_t i;
-        rt_size_t sector_adr;
-        uint8_t* copy_buffer;
-
-        sector_adr = pos;
-        copy_buffer = (uint8_t*)buffer;
-
-        for(i = 0; i < size; i++)
-        {
-            memcpy(sdio_buffer, copy_buffer, mci->card.blockSize);
-
-            status = SD_WriteBlocks(&mci->card, sdio_buffer, sector_adr, 1);
-
-            sector_adr ++;
-            copy_buffer += mci->card.blockSize;
-
-        }
-    }
-
-    /* release and exit */
-    rt_mutex_release(&_mci_device->lock);
-
-    if (status == kStatus_Success) return size;
-
-    return 0;
-}
-
-static rt_err_t rt_mci_control(rt_device_t dev, int cmd, void *args)
-{
-    struct mci_device *mci = (struct mci_device *)dev;
-
-    RT_ASSERT(dev != RT_NULL);
-
-    if (cmd == RT_DEVICE_CTRL_BLK_GETGEOME)
-    {
-        struct rt_device_blk_geometry *geometry;
-
-        geometry = (struct rt_device_blk_geometry *)args;
-        if (geometry == RT_NULL) return -RT_ERROR;
-
-        geometry->bytes_per_sector = mci->card.blockSize;
-        geometry->block_size = mci->card.csd.eraseSectorSize;
-        geometry->sector_count = mci->card.blockCount;
-    }
-
-    return RT_EOK;
-}
-
-/*! @brief SDMMC host detect card configuration */
-static const sdmmchost_detect_card_t s_sdCardDetect = {
-    .cdType = BOARD_SD_DETECT_TYPE,
-    .cdTimeOut_ms = (~0U),
-};
-
-/*! @brief Card descriptor. */
-sd_card_t g_sd;
-int rt_hw_mci_init(void)
-{
-    _mci_device = (struct mci_device *)rt_malloc(sizeof(struct mci_device));
-    if (_mci_device == RT_NULL)
-    {
-        rt_kprintf("mci_hw_init _mci_device rt_malloc failed!\n");
-        return -RT_ERROR;
-    }
-    rt_memset(_mci_device, 0, sizeof(struct mci_device));
-
-    /* attach main clock to SDIF */
-    CLOCK_AttachClk(kMAIN_CLK_to_SDIO_CLK);
-    /* need call this function to clear the halt bit in clock divider register */
-    CLOCK_SetClkDiv(kCLOCK_DivSdioClk, (uint32_t)(SystemCoreClock / FSL_FEATURE_SDIF_MAX_SOURCE_CLOCK + 1U), true);
-
-    _mci_device->card = g_sd;
-
-    /* Save host information. */
-    _mci_device->card.host.base = SDIF;
-    _mci_device->card.host.sourceClock_Hz = CLOCK_GetFreq(kCLOCK_SDio);
-    _mci_device->card.usrParam.cd = &s_sdCardDetect;
-#if 1
-    rt_kprintf("\r\nNeed wait a few seconds to SD init, Better Set SystemTick as 1000\r\n");
-    rt_kprintf("SDCard Freq %d\r\n", _mci_device->card.host.sourceClock_Hz);
-#endif
-    if (kStatus_Success != SD_HostInit(&_mci_device->card))
-    {
-        memset(&_mci_device->card, 0U, sizeof(_mci_device->card));
-        rt_kprintf("SD_Init failed!\n");
-        return -RT_ERROR;
-    }
-
-    /* power off card */
-    SD_PowerOffCard(_mci_device->card.host.base, _mci_device->card.usrParam.pwr);
-
-    /* check SD card insert */
-    if(BOARD_SDIF_CD_STATUS() == true)
-    {
-        rt_kprintf("\r\nCard detect fail.\r\n");
-        return kStatus_Fail;
-    }
-
-    /* wait card insert */
-    if (SD_WaitCardDetectStatus(_mci_device->card.host.base, &s_sdCardDetect, true) == kStatus_Success)
-    {
-        /* reset host once card re-plug in */
-        SD_HostReset(&(_mci_device->card.host));
-        /* power on the card */
-        SD_PowerOnCard(_mci_device->card.host.base, _mci_device->card.usrParam.pwr);
-    }
-    else
-    {
-        rt_kprintf("\r\nCard detect fail.\r\n");
-        return kStatus_Fail;
-    }
-
-    /* Init card. */
-    if (SD_CardInit(&_mci_device->card))
-    {
-        rt_kprintf("\r\nSD card init failed.\r\n");
-        return kStatus_Fail;
-    }
-
-    /* initialize mutex lock */
-    rt_mutex_init(&_mci_device->lock, "sdcard0", RT_IPC_FLAG_PRIO);
-    /* create finish event */
-    _mci_device->finish_event = rt_event_create("sdcard0", RT_IPC_FLAG_FIFO);
-
-    /* register sdcard device */
-    _mci_device->parent.type    = RT_Device_Class_Block;
-
-    _mci_device->geometry.bytes_per_sector = 0;
-    _mci_device->geometry.sector_count = 0;
-    _mci_device->geometry.block_size = 0;
-
-    _mci_device->parent.init    = rt_mci_init;
-    _mci_device->parent.open    = rt_mci_open;
-    _mci_device->parent.close   = rt_mci_close;
-    _mci_device->parent.read    = rt_mci_read;
-    _mci_device->parent.write   = rt_mci_write;
-    _mci_device->parent.control = rt_mci_control;
-
-    /* no private, no callback */
-    _mci_device->parent.user_data = RT_NULL;
-    _mci_device->parent.rx_indicate = RT_NULL;
-    _mci_device->parent.tx_complete = RT_NULL;
-
-    rt_device_register(&_mci_device->parent, "sdcard0",
-                       RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE );
-
-    return 0;
-}
-INIT_DEVICE_EXPORT(rt_hw_mci_init);
-
-#endif /* endif RT_USING_SDIO */

+ 0 - 29
bsp/lpc55sxx/Libraries/drivers/drv_sd.h

@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2006-2023, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date           Author       Notes
- * 2019-07-19     Magicoe      The first version for LPC55S6x
- */
-
-#ifndef __DRV_SD_H__
-#define __DRV_SD_H__
-
-#include <rtthread.h>
-#include "rtdef.h"
-
-struct mci_device
-{
-    struct rt_device                parent;      /**< RT-Thread device struct */
-    struct rt_device_blk_geometry   geometry;    /**< sector size, sector count */
-    sd_card_t                       card;        /**< Card descriptor */
-    rt_event_t finish_event;                     /**< data send finish event*/
-    rt_bool_t data_error;                        /**< data send error*/
-    struct rt_mutex lock;
-};
-
-extern int rt_hw_mci_init(void);
-
-#endif // __DRV_SD_H__

+ 326 - 0
bsp/lpc55sxx/Libraries/drivers/drv_sdif.c

@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2006-2023, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2017-08-08     Yang         the first version
+ * 2019-07-19     Magicoe      The first version for LPC55S6x
+ * 2023-02-0      Alex Yang    update driver
+ */
+
+#include "board.h"
+#include <rtdevice.h>
+#include "fsl_sdif.h"
+
+
+#ifdef RT_USING_SDIO
+
+//#define MMCSD_DEBUG
+
+#ifdef MMCSD_DEBUG
+#define MMCSD_DGB       rt_kprintf
+#else
+#define MMCSD_DGB(fmt, ...)
+#endif
+
+#define SDMMCHOST_RESET_TIMEOUT_VALUE (1000000U)
+
+struct lpc_mmcsd
+{
+    struct rt_mmcsd_host *host;
+    SDIF_Type *SDIFx;
+    uint32_t sdmmcHostDmaBuffer[0x40];
+};
+
+
+static void SDMMCHOST_ErrorRecovery(SDIF_Type *base)
+{
+    (void)SDIF_Reset(base, kSDIF_ResetAll, SDMMCHOST_RESET_TIMEOUT_VALUE);
+    /* the host controller clock will be disabled by the reset operation, so re-send the clock sync command to enable
+    the output clock */
+    sdif_command_t clockSync = {
+        .flags = kSDIF_WaitPreTransferComplete | kSDIF_CmdUpdateClockRegisterOnly, .index = 0U, .argument = 0U};
+    (void)SDIF_SendCommand(base, &clockSync, 0U);
+}
+
+
+
+static void lpc_sdmmc_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req)
+{
+
+    struct lpc_mmcsd *mmcsd;
+    struct rt_mmcsd_cmd *cmd;
+    struct rt_mmcsd_data *data;
+    rt_uint32_t *buf = NULL;
+
+    status_t error;
+
+    mmcsd = (struct lpc_mmcsd *) host->private_data;
+    cmd = req->cmd;
+    data = cmd->data;
+
+    sdif_dma_config_t dmaConfig;
+
+    dmaConfig.enableFixBurstLen     = false;
+    dmaConfig.mode                  = kSDIF_ChainDMAMode;
+    dmaConfig.dmaDesBufferStartAddr = mmcsd->sdmmcHostDmaBuffer;
+    dmaConfig.dmaDesBufferLen       = 0x40;
+    dmaConfig.dmaDesSkipLen         = 0U;
+
+    sdif_transfer_t fsl_content = {0};
+    sdif_command_t fsl_command = {0};
+    sdif_data_t fsl_data = {0};
+
+    fsl_content.command = &fsl_command;
+    fsl_content.data = &fsl_data;
+
+   // MMCSD_DGB("ARG:0x%X, CODE:0x%X\r\n", cmd->arg, cmd->cmd_code);
+
+
+    fsl_command.index = cmd->cmd_code;
+    fsl_command.argument = cmd->arg;
+
+    if (cmd->cmd_code == STOP_TRANSMISSION)
+        fsl_command.type = kCARD_CommandTypeAbort;
+    else
+        fsl_command.type = kCARD_CommandTypeNormal;
+
+    switch (cmd->flags & RESP_MASK)
+    {
+    case RESP_NONE:
+        fsl_command.responseType = kCARD_ResponseTypeNone;
+        break;
+    case RESP_R1:
+        fsl_command.responseType = kCARD_ResponseTypeR1;
+        break;
+    case RESP_R1B:
+        fsl_command.responseType = kCARD_ResponseTypeR1b;
+        break;
+    case RESP_R2:
+        fsl_command.responseType = kCARD_ResponseTypeR2;
+        break;
+    case RESP_R3:
+        fsl_command.responseType = kCARD_ResponseTypeR3;
+        break;
+    case RESP_R4:
+        fsl_command.responseType = kCARD_ResponseTypeR4;
+        break;
+    case RESP_R6:
+        fsl_command.responseType = kCARD_ResponseTypeR6;
+        break;
+    case RESP_R7:
+        fsl_command.responseType = kCARD_ResponseTypeR7;
+        break;
+    case RESP_R5:
+        fsl_command.responseType = kCARD_ResponseTypeR5;
+        break;
+    default:
+        RT_ASSERT(NULL);
+    }
+
+    fsl_command.flags = 0;
+    fsl_content.command = &fsl_command;
+
+    if (data)
+    {
+
+        if (req->stop != NULL)
+            fsl_data.enableAutoCommand12 = true;
+        else
+            fsl_data.enableAutoCommand12 = false;
+
+        fsl_data.enableIgnoreError = false;
+        fsl_data.blockSize = data->blksize;
+        fsl_data.blockCount = data->blks;
+
+        if ((cmd->cmd_code == WRITE_BLOCK) || (cmd->cmd_code == WRITE_MULTIPLE_BLOCK))
+        {
+            if (buf)
+            {
+                MMCSD_DGB(" write(data->buf to buf) ");
+                rt_memcpy(buf, data->buf, fsl_data.blockSize * fsl_data.blockCount);
+                fsl_data.txData = (uint32_t const *)buf;
+            }
+            else
+            {
+                fsl_data.txData = (uint32_t const *)data->buf;
+            }
+
+            fsl_data.rxData = NULL;
+        }
+        else
+        {
+            if (buf)
+            {
+                fsl_data.rxData = (uint32_t *)buf;
+            }
+            else
+            {
+                fsl_data.rxData = (uint32_t *)data->buf;
+            }
+
+            fsl_data.txData = NULL;
+        }
+
+        fsl_content.data = &fsl_data;
+    }
+    else
+    {
+        fsl_content.data = NULL;
+    }
+
+    error = SDIF_TransferBlocking(mmcsd->SDIFx, &dmaConfig, &fsl_content);
+    if (error != kStatus_Success)
+    {
+        SDMMCHOST_ErrorRecovery(mmcsd->SDIFx);
+        MMCSD_DGB(" ***SDIF_TransferBlocking error: %d*** --> \n", error);
+        cmd->err = -RT_ERROR;
+    }
+
+    if (buf)
+    {
+        if (fsl_data.rxData)
+        {
+            MMCSD_DGB("read copy buf to data->buf ");
+            rt_memcpy(data->buf, buf, fsl_data.blockSize * fsl_data.blockCount);
+        }
+
+        rt_free_align(buf);
+    }
+
+    if ((cmd->flags & RESP_MASK) == RESP_R2)
+    {
+        cmd->resp[3] = fsl_command.response[0];
+        cmd->resp[2] = fsl_command.response[1];
+        cmd->resp[1] = fsl_command.response[2];
+        cmd->resp[0] = fsl_command.response[3];
+     //   MMCSD_DGB(" resp 0x%08X 0x%08X 0x%08X 0x%08X\n", cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
+
+    }
+    else
+    {
+        cmd->resp[0] = fsl_command.response[0];
+       // MMCSD_DGB(" resp 0x%08X\n", cmd->resp[0]);
+    }
+
+    mmcsd_req_complete(host);
+
+}
+
+
+
+
+
+
+
+
+static void lpc_sdmmc_set_iocfg(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg)
+{
+    //rt_kprintf("%s\r\n", __FUNCTION__);
+    struct lpc_mmcsd *mmcsd;
+
+    mmcsd = (struct lpc_mmcsd *) host->private_data;
+
+    uint32_t sdxc_clock = io_cfg->clock;
+
+    MMCSD_DGB("sdxc_clock:%d\r\n", sdxc_clock);
+    MMCSD_DGB("bus_width:%d\r\n", io_cfg->bus_width);
+
+    if (sdxc_clock != 0U)
+    {
+        SDIF_SetCardClock(mmcsd->SDIFx, CLOCK_GetSdioClkFreq(), sdxc_clock);
+
+        switch (io_cfg->bus_width)
+        {
+        case MMCSD_BUS_WIDTH_4:
+            SDIF_SetCardBusWidth(mmcsd->SDIFx, kSDIF_Bus4BitWidth);
+            break;
+        case MMCSD_BUS_WIDTH_8:
+            SDIF_SetCardBusWidth(mmcsd->SDIFx, kSDIF_Bus8BitWidth);
+            break;
+        default:
+            SDIF_SetCardBusWidth(mmcsd->SDIFx, kSDIF_Bus1BitWidth);
+            break;
+        }
+    }
+
+    rt_thread_mdelay(20);
+}
+
+static const struct rt_mmcsd_host_ops lpc_mmcsd_host_ops =
+{
+    .request = lpc_sdmmc_request,
+    .set_iocfg = lpc_sdmmc_set_iocfg,
+    .get_card_status = NULL,
+    .enable_sdio_irq = NULL, // Do not use the interrupt mode, use DMA instead
+};
+
+
+
+
+int rt_hw_sdio_init(void)
+{
+    struct rt_mmcsd_host *host = NULL;
+    struct lpc_mmcsd *mmcsd = NULL;
+
+    host = mmcsd_alloc_host();
+    if (!host)
+    {
+        return -RT_ERROR;
+    }
+
+    mmcsd = rt_malloc(sizeof(struct lpc_mmcsd));
+    if (!mmcsd)
+    {
+        rt_kprintf("alloc mci failed\n");
+        goto err;
+    }
+
+    rt_memset(mmcsd, 0, sizeof(struct lpc_mmcsd));
+    mmcsd->SDIFx = SDIF;
+
+    host->ops = &lpc_mmcsd_host_ops;
+    host->freq_min = 375000;
+    host->freq_max = 50000000;
+    host->valid_ocr = VDD_30_31 | VDD_31_32 | VDD_32_33 | VDD_33_34;
+    host->flags = MMCSD_MUTBLKWRITE | MMCSD_BUSWIDTH_4 | MMCSD_SUP_HIGHSPEED | MMCSD_SUP_SDIO_IRQ;
+
+    host->max_seg_size = 65535;
+    host->max_dma_segs = 2;
+    host->max_blk_size = 512;
+    host->max_blk_count = 4096;
+
+    mmcsd->host = host;
+
+    /* Perform necessary initialization */
+    CLOCK_AttachClk(kMAIN_CLK_to_SDIO_CLK);
+    CLOCK_SetClkDiv(kCLOCK_DivSdioClk, (uint32_t)(SystemCoreClock / FSL_FEATURE_SDIF_MAX_SOURCE_CLOCK + 1U), true);
+
+    MMCSD_DGB("SDIO clock:%dHz\r\n", CLOCK_GetSdioClkFreq());
+
+    sdif_config_t sdif_config = {0};
+
+    sdif_config.responseTimeout       = 0xFFU;
+    sdif_config.cardDetDebounce_Clock = 0xFFFFFFU;
+    sdif_config.dataTimeout           = 0xFFFFFFU;
+    SDIF_Init(mmcsd->SDIFx, &sdif_config);
+
+    SDIF_EnableCardPower(mmcsd->SDIFx, false);
+    SDIF_EnableCardPower(mmcsd->SDIFx, true);
+
+    host->private_data = mmcsd;
+
+    mmcsd_change(host);
+
+    return 0;
+
+err:
+    mmcsd_free_host(host);
+
+    return -RT_ENOMEM;
+}
+INIT_DEVICE_EXPORT(rt_hw_sdio_init);
+
+#endif /* endif RT_USING_SDIO */

+ 50 - 8
bsp/lpc55sxx/lpc55s69_nxp_evk/.config

@@ -60,6 +60,7 @@ CONFIG_RT_USING_MESSAGEQUEUE=y
 #
 # Memory Management
 #
+CONFIG_RT_PAGE_MAX_ORDER=11
 CONFIG_RT_USING_MEMPOOL=y
 CONFIG_RT_USING_SMALL_MEM=y
 # CONFIG_RT_USING_SLAB is not set
@@ -107,8 +108,7 @@ CONFIG_FINSH_USING_MSH=y
 CONFIG_FINSH_THREAD_NAME="tshell"
 CONFIG_FINSH_THREAD_PRIORITY=20
 CONFIG_FINSH_THREAD_STACK_SIZE=4096
-CONFIG_FINSH_USING_HISTORY=y
-CONFIG_FINSH_HISTORY_LINES=5
+# CONFIG_FINSH_USING_HISTORY is not set
 CONFIG_FINSH_USING_SYMTAB=y
 CONFIG_FINSH_CMD_SIZE=80
 CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
@@ -116,7 +116,41 @@ CONFIG_FINSH_USING_DESCRIPTION=y
 # CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
 # CONFIG_FINSH_USING_AUTH is not set
 CONFIG_FINSH_ARG_MAX=10
-# CONFIG_RT_USING_DFS is not set
+CONFIG_RT_USING_DFS=y
+CONFIG_DFS_USING_POSIX=y
+CONFIG_DFS_USING_WORKDIR=y
+CONFIG_DFS_FILESYSTEMS_MAX=4
+CONFIG_DFS_FILESYSTEM_TYPES_MAX=4
+CONFIG_DFS_FD_MAX=16
+# CONFIG_RT_USING_DFS_MNTTABLE is not set
+CONFIG_RT_USING_DFS_ELMFAT=y
+
+#
+# elm-chan's FatFs, Generic FAT Filesystem Module
+#
+CONFIG_RT_DFS_ELM_CODE_PAGE=437
+CONFIG_RT_DFS_ELM_WORD_ACCESS=y
+# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
+# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
+# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
+CONFIG_RT_DFS_ELM_USE_LFN_3=y
+CONFIG_RT_DFS_ELM_USE_LFN=3
+CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y
+# CONFIG_RT_DFS_ELM_LFN_UNICODE_1 is not set
+# CONFIG_RT_DFS_ELM_LFN_UNICODE_2 is not set
+# CONFIG_RT_DFS_ELM_LFN_UNICODE_3 is not set
+CONFIG_RT_DFS_ELM_LFN_UNICODE=0
+CONFIG_RT_DFS_ELM_MAX_LFN=255
+CONFIG_RT_DFS_ELM_DRIVES=2
+CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
+# CONFIG_RT_DFS_ELM_USE_ERASE is not set
+CONFIG_RT_DFS_ELM_REENTRANT=y
+CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
+CONFIG_RT_USING_DFS_DEVFS=y
+# CONFIG_RT_USING_DFS_ROMFS is not set
+# CONFIG_RT_USING_DFS_CROMFS is not set
+# CONFIG_RT_USING_DFS_RAMFS is not set
+# CONFIG_RT_USING_DFS_TMPFS is not set
 # CONFIG_RT_USING_FAL is not set
 
 #
@@ -148,8 +182,16 @@ CONFIG_RT_USING_PIN=y
 # CONFIG_RT_USING_MTD_NAND is not set
 # CONFIG_RT_USING_PM is not set
 # CONFIG_RT_USING_FDT is not set
-# CONFIG_RT_USING_RTC is not set
-# CONFIG_RT_USING_SDIO is not set
+CONFIG_RT_USING_RTC=y
+# CONFIG_RT_USING_ALARM is not set
+# CONFIG_RT_USING_SOFT_RTC is not set
+CONFIG_RT_USING_SDIO=y
+CONFIG_RT_SDIO_STACK_SIZE=512
+CONFIG_RT_SDIO_THREAD_PRIORITY=15
+CONFIG_RT_MMCSD_STACK_SIZE=1024
+CONFIG_RT_MMCSD_THREAD_PREORITY=22
+CONFIG_RT_MMCSD_MAX_PARTITION=16
+# CONFIG_RT_SDIO_DEBUG is not set
 # CONFIG_RT_USING_SPI is not set
 # CONFIG_RT_USING_WDT is not set
 # CONFIG_RT_USING_AUDIO is not set
@@ -511,6 +553,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
 # CONFIG_PKG_USING_TFDB is not set
 # CONFIG_PKG_USING_QPC is not set
 # CONFIG_PKG_USING_AGILE_UPGRADE is not set
+# CONFIG_PKG_USING_FLASH_BLOB is not set
 
 #
 # peripheral libraries and drivers
@@ -753,7 +796,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
 # CONFIG_PKG_USING_SOEM is not set
 # CONFIG_PKG_USING_QPARAM is not set
 # CONFIG_PKG_USING_CorevMCU_CLI is not set
-# CONFIG_PKG_USING_GET_IRQ_PRIORITY is not set
 
 #
 # Arduino libraries
@@ -982,8 +1024,8 @@ CONFIG_HW_I2C4_BAUDRATE_100kHZ=y
 # CONFIG_HW_I2C4_BAUDRATE_400kHZ is not set
 # CONFIG_BSP_USING_SPI is not set
 # CONFIG_BSP_USING_ADC is not set
-# CONFIG_BSP_USING_SDIO is not set
-# CONFIG_BSP_USING_RTC is not set
+CONFIG_BSP_USING_SDIO=y
+CONFIG_BSP_USING_RTC=y
 # CONFIG_BSP_USING_WDT is not set
 # CONFIG_BSP_USING_HWTIMER is not set
 # CONFIG_BSP_USING_PWM is not set

+ 0 - 2
bsp/lpc55sxx/lpc55s69_nxp_evk/applications/SConscript

@@ -11,8 +11,6 @@ if rtconfig.PLATFORM in ['gcc']:
 else:
     CPPDEFINES = []
 
-if  GetDepend('BSP_USING_SDIO'):
-    src += ['mnt.c']
 
 group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)
 

+ 14 - 1
bsp/lpc55sxx/lpc55s69_nxp_evk/applications/main.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2023, RT-Thread Development Team
  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: Apache-2.0
@@ -13,6 +13,7 @@
  */
 
 #include <rtdevice.h>
+#include "dfs_fs.h"
 #include "drv_pin.h"
 
 /* defined the LED pin: GPIO1_IO4 */
@@ -33,6 +34,18 @@ int main(void)
 #endif
 
     rt_pin_mode(LEDB_PIN, PIN_MODE_OUTPUT);  /* Set GPIO as Output */
+
+#ifdef RT_USING_SDIO
+    rt_thread_mdelay(2000);
+    if (dfs_mount("sd", "/", "elm", 0, NULL) == 0)
+    {
+        rt_kprintf("sd mounted to /\n");
+    }
+    else
+    {
+        rt_kprintf("sd mount to / failed\n");
+    }
+#endif
     while (1)
     {
         rt_pin_write(LEDB_PIN, PIN_HIGH);    /* Set GPIO output 1 */

+ 0 - 32
bsp/lpc55sxx/lpc55s69_nxp_evk/applications/mnt.c

@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- *  sdio filesystem support
- * Change Logs:
- * Date         Author        Notes
- * 2021-10-10   supperthomas  first version
- */
-#include "dfs_fs.h"
-#include <rtthread.h>
-#include <rtdevice.h>
-
-#ifdef BSP_USING_SDIO
-
-/**
-  * @brief  SDIO filesystem init
-  * @param  void
-  * @retval 0: filesystem init success, -1: filesystem init failed
-  */
-
-static int sdio_fs_init(void)
-{
-    int result = 0;
-    dfs_mount("sdcard0", "/", "elm", 0, 0);
-    return result;
-}
-
-INIT_ENV_EXPORT(sdio_fs_init);
-
-#endif /* BSP_USING_SDIO */

+ 0 - 110
bsp/lpc55sxx/lpc55s69_nxp_evk/applications/tfm_ps.c

@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date           Author       Notes
- * 2020-01-10     Kevin/Karl   Add PS demo
- *
- */
-
-#include <rtdevice.h>
-#include <string.h>
-#include "tfm_ns_lock.h"
-#include "psa_protected_storage.h"
-
-#define TEST_UID_A      2U
-#define ASSET_A         "THEQUICKBROWNFOXJUMPSOVERALAZYDOG"
-#define ASSET_A_SIZE    (sizeof( ASSET_A ) - 1)
-#define RESETDATA       "THISIS"
-#define RESETDATA_SIZE  (sizeof( RESETDATA ) - 1)
-#define READ_LENGTH     (ASSET_A_SIZE > RESETDATA_SIZE ? \
-                         ASSET_A_SIZE : RESETDATA_SIZE)
-
-void protected_storage_demo_thread(void * parameters)
-{
-    psa_ps_status_t status;
-    const psa_ps_uid_t uid = TEST_UID_A;
-    const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
-    uint8_t write_data[] = ASSET_A;
-    const uint32_t data_length = ASSET_A_SIZE;
-    uint8_t rewrite_data[] = RESETDATA;
-    const uint32_t reset_data_length = RESETDATA_SIZE;
-    uint8_t get_data[READ_LENGTH];
-    uint32_t counter = 0;
-
-    tfm_ns_lock_init();
-
-    for ( ; ; )
-    {
-        /* Call TF-M protected storage service and set the asset. */
-        status = psa_ps_set(uid, data_length, write_data, flags);
-        if (status != PSA_PS_SUCCESS)
-        {
-            rt_kprintf("[Protected Storage Asset A Set Round %ld] Fail\r\n", counter);
-            for( ; ; );
-        }
-
-        rt_kprintf("[Protected Storage Asset A Set Round %ld] Success\r\n", counter);
-
-        /* Read the asset. */
-        status = psa_ps_get(uid, 0, data_length, get_data);
-        if (status != PSA_PS_SUCCESS)
-        {
-            rt_kprintf("[Protected Storage Asset A Get Round %ld] Fail\r\n", counter);
-            for ( ; ; );
-        }
-
-        rt_kprintf("[Protected Storage Asset A Get Round %ld] Success\r\n", counter);
-
-        /* Check the read data. */
-        if (memcmp(write_data, get_data, sizeof(write_data) - 1) != 0)
-        {
-            rt_kprintf("[Protected Storage Asset A Get Round %ld] Get the wrong data\r\n", counter);
-            for ( ; ; );
-        }
-
-        /* Change the asset. */
-        status = psa_ps_set(uid, reset_data_length, rewrite_data, flags);
-        if (status != PSA_PS_SUCCESS)
-        {
-            rt_kprintf("[Protected Storage Asset A Reset Round %ld] Fail\r\n", counter);
-        }
-
-        rt_kprintf("[Protected Storage Asset A Reset Round %ld] Success\r\n", counter);
-
-        /* Read the asset. */
-        status = psa_ps_get(uid, 0, reset_data_length, get_data);
-        if (status != PSA_PS_SUCCESS)
-        {
-            rt_kprintf("[Protected Storage Asset A Get Round %ld] Fail\r\n", counter);
-            for ( ; ; );
-        }
-
-        rt_kprintf("[Protected Storage Asset A Get Round %ld] Success\r\n", counter);
-
-        /* Check the read data. */
-        if (memcmp(rewrite_data, get_data, sizeof(rewrite_data) - 1) != 0)
-        {
-            rt_kprintf("[Protected Storage Asset A Get Round %ld] Get the wrong data\r\n", counter);
-            for ( ; ; );
-        }
-
-        /* Remove the asset. */
-        status = psa_ps_remove(uid);
-        if (status != PSA_PS_SUCCESS)
-        {
-            rt_kprintf("[Protected Storage Asset A Remove Round %ld] Fail\r\n", counter);
-            for ( ; ; );
-        }
-
-        rt_kprintf("[Protected Storage Asset A Remove Round %ld] Success\r\n\n", counter);
-
-        /* Wait for a second. */
-        rt_thread_mdelay(1000);
-        counter++;
-    }
-}
-
-// end file

+ 1 - 1
bsp/lpc55sxx/lpc55s69_nxp_evk/project.ewd

@@ -437,7 +437,7 @@
                 </option>
                 <option>
                     <name>CMSISDAPSelectedCPUBehaviour</name>
-                    <state>0</state>
+                    <state></state>
                 </option>
                 <option>
                     <name>ICpuName</name>

+ 1494 - 1426
bsp/lpc55sxx/lpc55s69_nxp_evk/project.ewp

@@ -1,1429 +1,1497 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <project>
-  <fileVersion>3</fileVersion>
-  <configuration>
-    <name>rtthread</name>
-    <toolchain>
-      <name>ARM</name>
-    </toolchain>
-    <debug>1</debug>
-    <settings>
-      <name>General</name>
-      <archiveVersion>3</archiveVersion>
-      <data>
-        <version>35</version>
-        <wantNonLocal>1</wantNonLocal>
+    <fileVersion>3</fileVersion>
+    <configuration>
+        <name>rtthread</name>
+        <toolchain>
+            <name>ARM</name>
+        </toolchain>
         <debug>1</debug>
-        <option>
-          <name>BrowseInfoPath</name>
-          <state>rtthread\BrowseInfo</state>
-        </option>
-        <option>
-          <name>ExePath</name>
-          <state>build\iar\Exe</state>
-        </option>
-        <option>
-          <name>ObjPath</name>
-          <state>build\iar\Obj</state>
-        </option>
-        <option>
-          <name>ListPath</name>
-          <state>build\iar\List</state>
-        </option>
-        <option>
-          <name>GEndianMode</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>Input description</name>
-          <state>Automatic choice of formatter, without multibyte support.</state>
-        </option>
-        <option>
-          <name>Output description</name>
-          <state>Automatic choice of formatter, without multibyte support.</state>
-        </option>
-        <option>
-          <name>GOutputBinary</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OGCoreOrChip</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>GRuntimeLibSelect</name>
-          <version>0</version>
-          <state>1</state>
-        </option>
-        <option>
-          <name>GRuntimeLibSelectSlave</name>
-          <version>0</version>
-          <state>1</state>
-        </option>
-        <option>
-          <name>RTDescription</name>
-          <state>A compact configuration of the C/C++14 runtime library. No locale interface, C locale, no file descriptor support, no multibytes in printf and scanf, and no hex floats in strtod.</state>
-        </option>
-        <option>
-          <name>OGProductVersion</name>
-          <state>6.30.6.53380</state>
-        </option>
-        <option>
-          <name>OGLastSavedByProductVersion</name>
-          <state>9.30.1.50052</state>
-        </option>
-        <option>
-          <name>OGChipSelectEditMenu</name>
-          <state>LPC55S69_core0	NXP LPC55S69_core0</state>
-        </option>
-        <option>
-          <name>GenLowLevelInterface</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>GEndianModeBE</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>OGBufferedTerminalOutput</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>GenStdoutInterface</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>RTConfigPath2</name>
-          <state>$TOOLKIT_DIR$\inc\c\DLib_Config_Normal.h</state>
-        </option>
-        <option>
-          <name>GBECoreSlave</name>
-          <version>32</version>
-          <state>41</state>
-        </option>
-        <option>
-          <name>OGUseCmsis</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>OGUseCmsisDspLib</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>GRuntimeLibThreads</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CoreVariant</name>
-          <version>32</version>
-          <state>61</state>
-        </option>
-        <option>
-          <name>GFPUDeviceSlave</name>
-          <state>LPC55S69_core0	NXP LPC55S69_core0</state>
-        </option>
-        <option>
-          <name>FPU2</name>
-          <version>0</version>
-          <state>6</state>
-        </option>
-        <option>
-          <name>NrRegs</name>
-          <version>0</version>
-          <state>1</state>
-        </option>
-        <option>
-          <name>NEON</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>GFPUCoreSlave2</name>
-          <version>32</version>
-          <state>61</state>
-        </option>
-        <option>
-          <name>OGCMSISPackSelectDevice</name>
-        </option>
-        <option>
-          <name>OgLibHeap</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OGLibAdditionalLocale</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OGPrintfVariant</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OGPrintfMultibyteSupport</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OGScanfVariant</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OGScanfMultibyteSupport</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>GenLocaleTags</name>
-          <state />
-        </option>
-        <option>
-          <name>GenLocaleDisplayOnly</name>
-          <state />
-        </option>
-        <option>
-          <name>DSPExtension</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>TrustZone</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>TrustZoneModes</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OGAarch64Abi</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OG_32_64Device</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>BuildFilesPath</name>
-          <state>rtthread</state>
-        </option>
-        <option>
-          <name>PointerAuthentication</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>FPU64</name>
-          <state>1</state>
-        </option>
-      </data>
-    </settings>
-    <settings>
-      <name>ICCARM</name>
-      <archiveVersion>2</archiveVersion>
-      <data>
-        <version>37</version>
-        <wantNonLocal>1</wantNonLocal>
-        <debug>1</debug>
-        <option>
-          <name>CCOptimizationNoSizeConstraints</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCDefines</name>
-          <state>CPU_LPC55S69JBD100_cm33_core0</state>
-          <state>CLOCKS_PER_SEC=RT_TICK_PER_SECOND</state>
-          <state>RT_USING_DLIBC</state>
-          <state>RT_USING_LIBC</state>
-          <state>_DLIB_ADD_EXTRA_SYMBOLS=0</state>
-          <state>DEBUG</state>
-          <state>__RTTHREAD__</state>
-        </option>
-        <option>
-          <name>CCPreprocFile</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCPreprocComments</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCPreprocLine</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCListCFile</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCListCMnemonics</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCListCMessages</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCListAssFile</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCListAssSource</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCEnableRemarks</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCDiagSuppress</name>
-          <state>Pa082,Pa050,Pe167</state>
-        </option>
-        <option>
-          <name>CCDiagRemark</name>
-          <state />
-        </option>
-        <option>
-          <name>CCDiagWarning</name>
-          <state />
-        </option>
-        <option>
-          <name>CCDiagError</name>
-          <state />
-        </option>
-        <option>
-          <name>CCObjPrefix</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCAllowList</name>
-          <version>1</version>
-          <state>00000000</state>
-        </option>
-        <option>
-          <name>CCDebugInfo</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IEndianMode</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IProcessor</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IExtraOptionsCheck</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IExtraOptions</name>
-          <state />
-        </option>
-        <option>
-          <name>CCLangConformance</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCSignedPlainChar</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCRequirePrototypes</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCDiagWarnAreErr</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCCompilerRuntimeInfo</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IFpuProcessor</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>OutputFile</name>
-          <state>$FILE_BNAME$.o</state>
-        </option>
-        <option>
-          <name>CCLibConfigHeader</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>PreInclude</name>
-          <state />
-        </option>
-        <option>
-          <name>CCIncludePath2</name>
-          <state />
-          <state>$PROJ_DIR$\board\MCUX_Config\board</state>
-          <state>$PROJ_DIR$\..\..\..\components\drivers\include</state>
-          <state>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33</state>
-          <state>$PROJ_DIR$\..\..\..\components\finsh</state>
-          <state>$PROJ_DIR$\..\..\..\components\libc\compilers\common\extension</state>
-          <state>$PROJ_DIR$\..\..\..\components\libc\posix\ipc</state>
-          <state>$PROJ_DIR$\..\..\..\components\libc\posix\io\stdio</state>
-          <state>$PROJ_DIR$\..\Libraries\drivers\config</state>
-          <state>$PROJ_DIR$\.</state>
-          <state>$PROJ_DIR$\..\Libraries\CMSIS\Core\Include</state>
-          <state>$PROJ_DIR$\board</state>
-          <state>$PROJ_DIR$\..\..\..\components\libc\compilers\common\extension\fcntl\octal</state>
-          <state>$PROJ_DIR$\..\..\..\components\libc\compilers\common\include</state>
-          <state>$PROJ_DIR$\..\Libraries\drivers</state>
-          <state>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers</state>
-          <state>$PROJ_DIR$\applications</state>
-          <state>$PROJ_DIR$\..\..\..\components\libc\posix\io\poll</state>
-          <state>$PROJ_DIR$\..\..\..\include</state>
-          <state>$PROJ_DIR$\..\..\..\libcpu\arm\common</state>
-          <state>$PROJ_DIR$\..\Libraries\LPC55S6X\middleware\sdmmc\inc</state>
-          <state>$PROJ_DIR$\..\Libraries\LPC55S6X\middleware\sdmmc\port</state>
-          <state>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X</state>
-          <state>$PROJ_DIR$\..\Libraries\LPC55S6X\components\codec</state>
-        </option>
-        <option>
-          <name>CCStdIncCheck</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCCodeSection</name>
-          <state>.text</state>
-        </option>
-        <option>
-          <name>IProcessorMode2</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCOptLevel</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCOptStrategy</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCOptLevelSlave</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCPosIndRopi</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCPosIndRwpi</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCPosIndNoDynInit</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IccLang</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IccCDialect</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IccAllowVLA</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IccStaticDestr</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IccCppInlineSemantics</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IccCmsis</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IccFloatSemantics</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCNoLiteralPool</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCOptStrategySlave</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCGuardCalls</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCEncSource</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCEncOutput</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CCEncOutputBom</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCEncInput</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IccExceptions2</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IccRTTI2</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OICompilerExtraOption</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CCStackProtection</name>
-          <state>0</state>
-        </option>
-      </data>
-    </settings>
-    <settings>
-      <name>AARM</name>
-      <archiveVersion>2</archiveVersion>
-      <data>
-        <version>11</version>
-        <wantNonLocal>1</wantNonLocal>
-        <debug>1</debug>
-        <option>
-          <name>AObjPrefix</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>AEndian</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>ACaseSensitivity</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>MacroChars</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AWarnEnable</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AWarnWhat</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AWarnOne</name>
-          <state />
-        </option>
-        <option>
-          <name>AWarnRange1</name>
-          <state />
-        </option>
-        <option>
-          <name>AWarnRange2</name>
-          <state />
-        </option>
-        <option>
-          <name>ADebug</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>AltRegisterNames</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>ADefines</name>
-          <state />
-        </option>
-        <option>
-          <name>AList</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AListHeader</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>AListing</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>Includes</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>MacDefs</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>MacExps</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>MacExec</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OnlyAssed</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>MultiLine</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>PageLengthCheck</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>PageLength</name>
-          <state>80</state>
-        </option>
-        <option>
-          <name>TabSpacing</name>
-          <state>8</state>
-        </option>
-        <option>
-          <name>AXRef</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AXRefDefines</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AXRefInternal</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AXRefDual</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AProcessor</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>AFpuProcessor</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>AOutputFile</name>
-          <state>$FILE_BNAME$.o</state>
-        </option>
-        <option>
-          <name>ALimitErrorsCheck</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>ALimitErrorsEdit</name>
-          <state>100</state>
-        </option>
-        <option>
-          <name>AIgnoreStdInclude</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AUserIncludes</name>
-          <state />
-        </option>
-        <option>
-          <name>AExtraOptionsCheckV2</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>AExtraOptionsV2</name>
-          <state />
-        </option>
-        <option>
-          <name>AsmNoLiteralPool</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>PreInclude</name>
-          <state />
-        </option>
-      </data>
-    </settings>
-    <settings>
-      <name>OBJCOPY</name>
-      <archiveVersion>0</archiveVersion>
-      <data>
-        <version>1</version>
-        <wantNonLocal>1</wantNonLocal>
-        <debug>1</debug>
-        <option>
-          <name>OOCOutputFormat</name>
-          <version>3</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OCOutputOverride</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>OOCOutputFile</name>
-          <state>template.srec</state>
-        </option>
-        <option>
-          <name>OOCCommandLineProducer</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>OOCObjCopyEnable</name>
-          <state>0</state>
-        </option>
-      </data>
-    </settings>
-    <settings>
-      <name>CUSTOM</name>
-      <archiveVersion>3</archiveVersion>
-      <data>
-        <extensions />
-        <cmdline />
-        <hasPrio>1</hasPrio>
-        <buildSequence>inputOutputBased</buildSequence>
-      </data>
-    </settings>
-    <settings>
-      <name>BUILDACTION</name>
-      <archiveVersion>1</archiveVersion>
-      <data>
-        <prebuild />
-        <postbuild />
-      </data>
-    </settings>
-    <settings>
-      <name>ILINK</name>
-      <archiveVersion>0</archiveVersion>
-      <data>
-        <version>27</version>
-        <wantNonLocal>1</wantNonLocal>
-        <debug>1</debug>
-        <option>
-          <name>IlinkLibIOConfig</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkInputFileSlave</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkOutputFile</name>
-          <state>rtthread.out</state>
-        </option>
-        <option>
-          <name>IlinkDebugInfoEnable</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkKeepSymbols</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkRawBinaryFile</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkRawBinarySymbol</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkRawBinarySegment</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkRawBinaryAlign</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkDefines</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkConfigDefines</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkMapFile</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogFile</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogInitialization</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogModule</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogSection</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogVeneer</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkIcfOverride</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkIcfFile</name>
-          <state>$PROJ_DIR$\board\linker_scripts\LPC55S69_cm33_core0_flash.icf</state>
-        </option>
-        <option>
-          <name>IlinkIcfFileSlave</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkEnableRemarks</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkSuppressDiags</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkTreatAsRem</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkTreatAsWarn</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkTreatAsErr</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkWarningsAreErrors</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkUseExtraOptions</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkExtraOptions</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkLowLevelInterfaceSlave</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkAutoLibEnable</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkAdditionalLibs</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkOverrideProgramEntryLabel</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkProgramEntryLabelSelect</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkProgramEntryLabel</name>
-          <state>__iar_program_start</state>
-        </option>
-        <option>
-          <name>DoFill</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>FillerByte</name>
-          <state>0xFF</state>
-        </option>
-        <option>
-          <name>FillerStart</name>
-          <state>0x0</state>
-        </option>
-        <option>
-          <name>FillerEnd</name>
-          <state>0x0</state>
-        </option>
-        <option>
-          <name>CrcSize</name>
-          <version>0</version>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CrcAlign</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CrcPoly</name>
-          <state>0x11021</state>
-        </option>
-        <option>
-          <name>CrcCompl</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CrcBitOrder</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>CrcInitialValue</name>
-          <state>0x0</state>
-        </option>
-        <option>
-          <name>DoCrc</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkBE8Slave</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkBufferedTerminalOutput</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkStdoutInterfaceSlave</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CrcFullSize</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkIElfToolPostProcess</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkLogAutoLibSelect</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogRedirSymbols</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogUnusedFragments</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkCrcReverseByteOrder</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkCrcUseAsInput</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkOptInline</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkOptExceptionsAllow</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkOptExceptionsForce</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkCmsis</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkOptMergeDuplSections</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkOptUseVfe</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkOptForceVfe</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkStackAnalysisEnable</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkStackControlFile</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkStackCallGraphFile</name>
-          <state />
-        </option>
-        <option>
-          <name>CrcAlgorithm</name>
-          <version>1</version>
-          <state>1</state>
-        </option>
-        <option>
-          <name>CrcUnitSize</name>
-          <version>0</version>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkThreadsSlave</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLogCallGraph</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkIcfFile_AltDefault</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkEncInput</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkEncOutput</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkEncOutputBom</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkHeapSelect</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkLocaleSelect</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkTrustzoneImportLibraryOut</name>
-          <state>template_import_lib.o</state>
-        </option>
-        <option>
-          <name>OILinkExtraOption</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkRawBinaryFile2</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkRawBinarySymbol2</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkRawBinarySegment2</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkRawBinaryAlign2</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkLogCrtRoutineSelection</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkLogFragmentInfo</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkLogInlining</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkLogMerging</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkDemangle</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkWrapperFileEnable</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IlinkWrapperFile</name>
-          <state />
-        </option>
-        <option>
-          <name>IlinkProcessor</name>
-          <state>1</state>
-        </option>
-        <option>
-          <name>IlinkFpuProcessor</name>
-          <state>1</state>
-        </option>
-      </data>
-    </settings>
-    <settings>
-      <name>IARCHIVE</name>
-      <archiveVersion>0</archiveVersion>
-      <data>
-        <version>0</version>
-        <wantNonLocal>1</wantNonLocal>
-        <debug>1</debug>
-        <option>
-          <name>IarchiveInputs</name>
-          <state />
-        </option>
-        <option>
-          <name>IarchiveOverride</name>
-          <state>0</state>
-        </option>
-        <option>
-          <name>IarchiveOutput</name>
-          <state>###Unitialized###</state>
-        </option>
-      </data>
-    </settings>
-  </configuration>
-  <group>
-    <name>Applications</name>
-    <file>
-      <name>$PROJ_DIR$\applications\main.c</name>
-    </file>
-  </group>
-  <group>
-    <name>Compiler</name>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cctype.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cstdio.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cstdlib.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cstring.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\ctime.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cwchar.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\environ.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_close.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_lseek.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_mem.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_open.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_read.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_remove.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_write.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscalls.c</name>
-    </file>
-  </group>
-  <group>
-    <name>CPU</name>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\libcpu\arm\common\div0.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\libcpu\arm\common\showmem.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\context_iar.S</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\cpuport.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\syscall_iar.S</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\trustzone.c</name>
-    </file>
-  </group>
-  <group>
-    <name>DeviceDrivers</name>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\i2c\i2c_core.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\i2c\i2c_dev.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\completion.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\dataqueue.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\pipe.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\ringblk_buf.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\ringbuffer.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\waitqueue.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\workqueue.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\misc\pin.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\drivers\serial\serial.c</name>
-    </file>
-  </group>
-  <group>
-    <name>Drivers</name>
-    <file>
-      <name>$PROJ_DIR$\board\MCUX_Config\board\clock_config.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\board\MCUX_Config\board\pin_mux.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\board\board.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\drivers\drv_i2c.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\drivers\drv_key.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\drivers\drv_led.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\drivers\drv_mma8562.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\drivers\drv_pin.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\drivers\drv_uart.c</name>
-    </file>
-  </group>
-  <group>
-    <name>Finsh</name>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\finsh\shell.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\finsh\msh.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\finsh\msh_parse.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\components\finsh\cmd.c</name>
-    </file>
-  </group>
-  <group>
-    <name>Kernel</name>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\clock.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\components.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\device.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\idle.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\ipc.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\irq.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\kservice.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\mem.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\mempool.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\object.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\scheduler.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\thread.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\..\..\src\timer.c</name>
-    </file>
-  </group>
-  <group>
-    <name>Libraries</name>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_hashcrypt.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_usart_dma.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_spi_dma.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_cmp.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_utick.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_common_arm.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_power.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2s_dma.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_gpio.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\iar\startup_LPC55S69_cm33_core0.s</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_casper.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_clock.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_reset.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_sctimer.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_common.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_rtc.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_crc.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_sdif.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_plu.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_mrt.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2s.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_spi.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_ctimer.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_gint.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_dma.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_sysctl.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_flexcomm.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_pint.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_powerquad_basic.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_usart.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_puf.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_rng.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_lpadc.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_inputmux.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2c_dma.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2c.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_wwdt.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\system_LPC55S69_cm33_core0.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_anactrl.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_iap.c</name>
-    </file>
-    <file>
-      <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_ostimer.c</name>
-    </file>
-  </group>
-  <group>
-    <name>POSIX</name>
-  </group>
+        <settings>
+            <name>General</name>
+            <archiveVersion>3</archiveVersion>
+            <data>
+                <version>35</version>
+                <wantNonLocal>1</wantNonLocal>
+                <debug>1</debug>
+                <option>
+                    <name>BrowseInfoPath</name>
+                    <state>rtthread\BrowseInfo</state>
+                </option>
+                <option>
+                    <name>ExePath</name>
+                    <state>build\iar\Exe</state>
+                </option>
+                <option>
+                    <name>ObjPath</name>
+                    <state>build\iar\Obj</state>
+                </option>
+                <option>
+                    <name>ListPath</name>
+                    <state>build\iar\List</state>
+                </option>
+                <option>
+                    <name>GEndianMode</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>Input description</name>
+                    <state>Automatic choice of formatter, without multibyte support.</state>
+                </option>
+                <option>
+                    <name>Output description</name>
+                    <state>Automatic choice of formatter, without multibyte support.</state>
+                </option>
+                <option>
+                    <name>GOutputBinary</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OGCoreOrChip</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>GRuntimeLibSelect</name>
+                    <version>0</version>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>GRuntimeLibSelectSlave</name>
+                    <version>0</version>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>RTDescription</name>
+                    <state>A compact configuration of the C/C++14 runtime library. No locale interface, C locale, no file descriptor support, no multibytes in printf and scanf, and no hex floats in strtod.</state>
+                </option>
+                <option>
+                    <name>OGProductVersion</name>
+                    <state>6.30.6.53380</state>
+                </option>
+                <option>
+                    <name>OGLastSavedByProductVersion</name>
+                    <state>9.30.1.50052</state>
+                </option>
+                <option>
+                    <name>OGChipSelectEditMenu</name>
+                    <state>LPC55S69_core0	NXP LPC55S69_core0</state>
+                </option>
+                <option>
+                    <name>GenLowLevelInterface</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>GEndianModeBE</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>OGBufferedTerminalOutput</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>GenStdoutInterface</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>RTConfigPath2</name>
+                    <state>$TOOLKIT_DIR$\inc\c\DLib_Config_Normal.h</state>
+                </option>
+                <option>
+                    <name>GBECoreSlave</name>
+                    <version>32</version>
+                    <state>61</state>
+                </option>
+                <option>
+                    <name>OGUseCmsis</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>OGUseCmsisDspLib</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>GRuntimeLibThreads</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CoreVariant</name>
+                    <version>32</version>
+                    <state>61</state>
+                </option>
+                <option>
+                    <name>GFPUDeviceSlave</name>
+                    <state>LPC55S69_core0	NXP LPC55S69_core0</state>
+                </option>
+                <option>
+                    <name>FPU2</name>
+                    <version>0</version>
+                    <state>6</state>
+                </option>
+                <option>
+                    <name>NrRegs</name>
+                    <version>0</version>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>NEON</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>GFPUCoreSlave2</name>
+                    <version>32</version>
+                    <state>61</state>
+                </option>
+                <option>
+                    <name>OGCMSISPackSelectDevice</name>
+                </option>
+                <option>
+                    <name>OgLibHeap</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OGLibAdditionalLocale</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OGPrintfVariant</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OGPrintfMultibyteSupport</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OGScanfVariant</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OGScanfMultibyteSupport</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>GenLocaleTags</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>GenLocaleDisplayOnly</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>DSPExtension</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>TrustZone</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>TrustZoneModes</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OGAarch64Abi</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OG_32_64Device</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>BuildFilesPath</name>
+                    <state>rtthread</state>
+                </option>
+                <option>
+                    <name>PointerAuthentication</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>FPU64</name>
+                    <state>1</state>
+                </option>
+            </data>
+        </settings>
+        <settings>
+            <name>ICCARM</name>
+            <archiveVersion>2</archiveVersion>
+            <data>
+                <version>37</version>
+                <wantNonLocal>1</wantNonLocal>
+                <debug>1</debug>
+                <option>
+                    <name>CCOptimizationNoSizeConstraints</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCDefines</name>
+                    <state>CPU_LPC55S69JBD100_cm33_core0</state>
+                    <state>CLOCKS_PER_SEC=RT_TICK_PER_SECOND</state>
+                    <state>RT_USING_DLIBC</state>
+                    <state>RT_USING_LIBC</state>
+                    <state>_DLIB_ADD_EXTRA_SYMBOLS=0</state>
+                    <state>_DLIB_FILE_DESCRIPTOR</state>
+                    <state>DEBUG</state>
+                    <state>__RTTHREAD__</state>
+                </option>
+                <option>
+                    <name>CCPreprocFile</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCPreprocComments</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCPreprocLine</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCListCFile</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCListCMnemonics</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCListCMessages</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCListAssFile</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCListAssSource</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCEnableRemarks</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCDiagSuppress</name>
+                    <state>Pa082,Pa050,Pe167</state>
+                </option>
+                <option>
+                    <name>CCDiagRemark</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>CCDiagWarning</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>CCDiagError</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>CCObjPrefix</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCAllowList</name>
+                    <version>1</version>
+                    <state>00000000</state>
+                </option>
+                <option>
+                    <name>CCDebugInfo</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IEndianMode</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IProcessor</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IExtraOptionsCheck</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IExtraOptions</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>CCLangConformance</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCSignedPlainChar</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCRequirePrototypes</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCDiagWarnAreErr</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCCompilerRuntimeInfo</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IFpuProcessor</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>OutputFile</name>
+                    <state>$FILE_BNAME$.o</state>
+                </option>
+                <option>
+                    <name>CCLibConfigHeader</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>PreInclude</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>CCIncludePath2</name>
+                    <state>$PROJ_DIR$\..\..\..\components\dfs\filesystems\devfs</state>
+                    <state>$PROJ_DIR$\board\MCUX_Config\board</state>
+                    <state>$PROJ_DIR$\..\..\..\components\drivers\include</state>
+                    <state>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33</state>
+                    <state>$PROJ_DIR$\..\..\..\components\finsh</state>
+                    <state>$PROJ_DIR$\..\..\..\components\libc\compilers\common\extension</state>
+                    <state>$PROJ_DIR$\..\..\..\components\libc\posix\ipc</state>
+                    <state>$PROJ_DIR$\..\..\..\components\dfs\include</state>
+                    <state>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X</state>
+                    <state>$PROJ_DIR$\..\Libraries\drivers\config</state>
+                    <state>$PROJ_DIR$\.</state>
+                    <state>$PROJ_DIR$\..\Libraries\CMSIS\Core\Include</state>
+                    <state>$PROJ_DIR$\..\..\..\components\utilities\libadt</state>
+                    <state>$PROJ_DIR$\board</state>
+                    <state>$PROJ_DIR$\..\..\..\components\libc\compilers\common\extension\fcntl\octal</state>
+                    <state>$PROJ_DIR$\..\..\..\components\libc\compilers\common\include</state>
+                    <state>$PROJ_DIR$\..\Libraries\drivers</state>
+                    <state>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers</state>
+                    <state>$PROJ_DIR$\applications</state>
+                    <state>$PROJ_DIR$\..\..\..\components\dfs\filesystems\elmfat</state>
+                    <state>$PROJ_DIR$\..\..\..\components\libc\posix\io\poll</state>
+                    <state>$PROJ_DIR$\..\..\..\include</state>
+                    <state>$PROJ_DIR$\..\..\..\libcpu\arm\common</state>
+                    <state>$PROJ_DIR$\..\Libraries\LPC55S6X\middleware\sdmmc\inc</state>
+                    <state>$PROJ_DIR$\..\Libraries\LPC55S6X\middleware\sdmmc\port</state>
+                    <state>$PROJ_DIR$\..\..\..\components\libc\posix\io\stdio</state>
+                    <state>$PROJ_DIR$\..\Libraries\LPC55S6X\components\codec</state>
+                </option>
+                <option>
+                    <name>CCStdIncCheck</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCCodeSection</name>
+                    <state>.text</state>
+                </option>
+                <option>
+                    <name>IProcessorMode2</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCOptLevel</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCOptStrategy</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCOptLevelSlave</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCPosIndRopi</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCPosIndRwpi</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCPosIndNoDynInit</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IccLang</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IccCDialect</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IccAllowVLA</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IccStaticDestr</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IccCppInlineSemantics</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IccCmsis</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IccFloatSemantics</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCNoLiteralPool</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCOptStrategySlave</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCGuardCalls</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCEncSource</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCEncOutput</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CCEncOutputBom</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCEncInput</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IccExceptions2</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IccRTTI2</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OICompilerExtraOption</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CCStackProtection</name>
+                    <state>0</state>
+                </option>
+            </data>
+        </settings>
+        <settings>
+            <name>AARM</name>
+            <archiveVersion>2</archiveVersion>
+            <data>
+                <version>11</version>
+                <wantNonLocal>1</wantNonLocal>
+                <debug>1</debug>
+                <option>
+                    <name>AObjPrefix</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>AEndian</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>ACaseSensitivity</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>MacroChars</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AWarnEnable</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AWarnWhat</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AWarnOne</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>AWarnRange1</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>AWarnRange2</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>ADebug</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>AltRegisterNames</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>ADefines</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>AList</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AListHeader</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>AListing</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>Includes</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>MacDefs</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>MacExps</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>MacExec</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OnlyAssed</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>MultiLine</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>PageLengthCheck</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>PageLength</name>
+                    <state>80</state>
+                </option>
+                <option>
+                    <name>TabSpacing</name>
+                    <state>8</state>
+                </option>
+                <option>
+                    <name>AXRef</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AXRefDefines</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AXRefInternal</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AXRefDual</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AProcessor</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>AFpuProcessor</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>AOutputFile</name>
+                    <state>$FILE_BNAME$.o</state>
+                </option>
+                <option>
+                    <name>ALimitErrorsCheck</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>ALimitErrorsEdit</name>
+                    <state>100</state>
+                </option>
+                <option>
+                    <name>AIgnoreStdInclude</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AUserIncludes</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>AExtraOptionsCheckV2</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>AExtraOptionsV2</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>AsmNoLiteralPool</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>PreInclude</name>
+                    <state></state>
+                </option>
+            </data>
+        </settings>
+        <settings>
+            <name>OBJCOPY</name>
+            <archiveVersion>0</archiveVersion>
+            <data>
+                <version>1</version>
+                <wantNonLocal>1</wantNonLocal>
+                <debug>1</debug>
+                <option>
+                    <name>OOCOutputFormat</name>
+                    <version>3</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OCOutputOverride</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>OOCOutputFile</name>
+                    <state>template.srec</state>
+                </option>
+                <option>
+                    <name>OOCCommandLineProducer</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>OOCObjCopyEnable</name>
+                    <state>0</state>
+                </option>
+            </data>
+        </settings>
+        <settings>
+            <name>CUSTOM</name>
+            <archiveVersion>3</archiveVersion>
+            <data>
+                <extensions></extensions>
+                <cmdline></cmdline>
+                <hasPrio>1</hasPrio>
+                <buildSequence>inputOutputBased</buildSequence>
+            </data>
+        </settings>
+        <settings>
+            <name>BUILDACTION</name>
+            <archiveVersion>1</archiveVersion>
+            <data>
+                <prebuild></prebuild>
+                <postbuild></postbuild>
+            </data>
+        </settings>
+        <settings>
+            <name>ILINK</name>
+            <archiveVersion>0</archiveVersion>
+            <data>
+                <version>27</version>
+                <wantNonLocal>1</wantNonLocal>
+                <debug>1</debug>
+                <option>
+                    <name>IlinkLibIOConfig</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkInputFileSlave</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkOutputFile</name>
+                    <state>rtthread.out</state>
+                </option>
+                <option>
+                    <name>IlinkDebugInfoEnable</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkKeepSymbols</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkRawBinaryFile</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkRawBinarySymbol</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkRawBinarySegment</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkRawBinaryAlign</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkDefines</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkConfigDefines</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkMapFile</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogFile</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogInitialization</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogModule</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogSection</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogVeneer</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkIcfOverride</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkIcfFile</name>
+                    <state>$PROJ_DIR$\board\linker_scripts\LPC55S69_cm33_core0_flash.icf</state>
+                </option>
+                <option>
+                    <name>IlinkIcfFileSlave</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkEnableRemarks</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkSuppressDiags</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkTreatAsRem</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkTreatAsWarn</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkTreatAsErr</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkWarningsAreErrors</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkUseExtraOptions</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkExtraOptions</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkLowLevelInterfaceSlave</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkAutoLibEnable</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkAdditionalLibs</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkOverrideProgramEntryLabel</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkProgramEntryLabelSelect</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkProgramEntryLabel</name>
+                    <state>__iar_program_start</state>
+                </option>
+                <option>
+                    <name>DoFill</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>FillerByte</name>
+                    <state>0xFF</state>
+                </option>
+                <option>
+                    <name>FillerStart</name>
+                    <state>0x0</state>
+                </option>
+                <option>
+                    <name>FillerEnd</name>
+                    <state>0x0</state>
+                </option>
+                <option>
+                    <name>CrcSize</name>
+                    <version>0</version>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CrcAlign</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CrcPoly</name>
+                    <state>0x11021</state>
+                </option>
+                <option>
+                    <name>CrcCompl</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CrcBitOrder</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>CrcInitialValue</name>
+                    <state>0x0</state>
+                </option>
+                <option>
+                    <name>DoCrc</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkBE8Slave</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkBufferedTerminalOutput</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkStdoutInterfaceSlave</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CrcFullSize</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkIElfToolPostProcess</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkLogAutoLibSelect</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogRedirSymbols</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogUnusedFragments</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkCrcReverseByteOrder</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkCrcUseAsInput</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkOptInline</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkOptExceptionsAllow</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkOptExceptionsForce</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkCmsis</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkOptMergeDuplSections</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkOptUseVfe</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkOptForceVfe</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkStackAnalysisEnable</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkStackControlFile</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkStackCallGraphFile</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>CrcAlgorithm</name>
+                    <version>1</version>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>CrcUnitSize</name>
+                    <version>0</version>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkThreadsSlave</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLogCallGraph</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkIcfFile_AltDefault</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkEncInput</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkEncOutput</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkEncOutputBom</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkHeapSelect</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkLocaleSelect</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkTrustzoneImportLibraryOut</name>
+                    <state>template_import_lib.o</state>
+                </option>
+                <option>
+                    <name>OILinkExtraOption</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkRawBinaryFile2</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkRawBinarySymbol2</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkRawBinarySegment2</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkRawBinaryAlign2</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkLogCrtRoutineSelection</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkLogFragmentInfo</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkLogInlining</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkLogMerging</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkDemangle</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkWrapperFileEnable</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IlinkWrapperFile</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IlinkProcessor</name>
+                    <state>1</state>
+                </option>
+                <option>
+                    <name>IlinkFpuProcessor</name>
+                    <state>1</state>
+                </option>
+            </data>
+        </settings>
+        <settings>
+            <name>IARCHIVE</name>
+            <archiveVersion>0</archiveVersion>
+            <data>
+                <version>0</version>
+                <wantNonLocal>1</wantNonLocal>
+                <debug>1</debug>
+                <option>
+                    <name>IarchiveInputs</name>
+                    <state></state>
+                </option>
+                <option>
+                    <name>IarchiveOverride</name>
+                    <state>0</state>
+                </option>
+                <option>
+                    <name>IarchiveOutput</name>
+                    <state>###Unitialized###</state>
+                </option>
+            </data>
+        </settings>
+    </configuration>
+    <group>
+        <name>ADT</name>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\utilities\libadt\avl.c</name>
+        </file>
+    </group>
+    <group>
+        <name>Applications</name>
+        <file>
+            <name>$PROJ_DIR$\applications\main.c</name>
+        </file>
+    </group>
+    <group>
+        <name>Compiler</name>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cctype.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cstdio.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cstdlib.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cstring.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\ctime.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\common\cwchar.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\environ.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_close.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_lseek.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_mem.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_open.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_read.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_remove.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscall_write.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\libc\compilers\dlib\syscalls.c</name>
+        </file>
+    </group>
+    <group>
+        <name>CPU</name>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\context_iar.S</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\cpuport.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\libcpu\arm\common\div0.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\libcpu\arm\common\showmem.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\syscall_iar.S</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\libcpu\arm\cortex-m33\trustzone.c</name>
+        </file>
+    </group>
+    <group>
+        <name>DeviceDrivers</name>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\sdio\block_dev.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\completion.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\dataqueue.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\sdio\gpt.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\i2c\i2c_core.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\i2c\i2c_dev.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\sdio\mmc.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\sdio\mmcsd_core.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\misc\pin.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\pipe.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\ringblk_buf.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\ringbuffer.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\rtc\rtc.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\sdio\sd.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\sdio\sdio.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\serial\serial.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\waitqueue.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\drivers\ipc\workqueue.c</name>
+        </file>
+    </group>
+    <group>
+        <name>Drivers</name>
+        <file>
+            <name>$PROJ_DIR$\board\board.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\board\MCUX_Config\board\clock_config.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_i2c.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_key.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_led.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_mma8562.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_pin.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_rtc.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_sdif.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\drivers\drv_uart.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\board\MCUX_Config\board\pin_mux.c</name>
+        </file>
+    </group>
+    <group>
+        <name>Filesystem</name>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\filesystems\devfs\devfs.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\src\dfs.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\filesystems\elmfat\dfs_elm.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\src\dfs_file.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\src\dfs_fs.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\src\dfs_posix.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\filesystems\elmfat\ff.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\dfs\filesystems\elmfat\ffunicode.c</name>
+        </file>
+    </group>
+    <group>
+        <name>Finsh</name>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\finsh\cmd.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\finsh\msh.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\finsh\msh_file.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\finsh\msh_parse.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\components\finsh\shell.c</name>
+        </file>
+    </group>
+    <group>
+        <name>Kernel</name>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\clock.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\components.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\device.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\idle.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\ipc.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\irq.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\kservice.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\mem.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\mempool.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\object.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\scheduler.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\thread.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\..\..\src\timer.c</name>
+        </file>
+    </group>
+    <group>
+        <name>Libraries</name>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_anactrl.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_casper.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_clock.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_cmp.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_common.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_common_arm.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_crc.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_ctimer.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_dma.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_flexcomm.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_gint.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_gpio.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_hashcrypt.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2c.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2c_dma.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2s.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_i2s_dma.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_iap.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_inputmux.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_lpadc.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_mrt.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_ostimer.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_pint.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_plu.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_power.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_powerquad_basic.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_puf.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_reset.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_rng.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_rtc.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_sctimer.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_sdif.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_spi.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_spi_dma.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_sysctl.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_usart.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_usart_dma.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_utick.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\drivers\fsl_wwdt.c</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\iar\startup_LPC55S69_cm33_core0.s</name>
+        </file>
+        <file>
+            <name>$PROJ_DIR$\..\Libraries\LPC55S6X\LPC55S6X\system_LPC55S69_cm33_core0.c</name>
+        </file>
+    </group>
+    <group>
+        <name>POSIX</name>
+    </group>
 </project>

File diff suppressed because it is too large
+ 378 - 134
bsp/lpc55sxx/lpc55s69_nxp_evk/project.uvoptx


+ 106 - 10
bsp/lpc55sxx/lpc55s69_nxp_evk/project.uvprojx

@@ -340,7 +340,7 @@
               <MiscControls>--target=arm-arm-none-eabi</MiscControls>
               <Define>__STDC_LIMIT_MACROS, RT_USING_ARMLIBC, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__, DEBUG</Define>
               <Undefine></Undefine>
-              <IncludePath>..\..\..\components\libc\posix\ipc;board;..\..\..\components\drivers\include;board\MCUX_Config\board;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\Libraries\LPC55S6X\middleware\sdmmc\port;..\Libraries\drivers;..\..\..\components\libc\posix\io\poll;..\Libraries\drivers\config;..\..\..\components\finsh;..\..\..\components\libc\compilers\common\include;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m33;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\Libraries\LPC55S6X\middleware\sdmmc\inc;..\..\..\components\libc\posix\io\stdio;applications;..\Libraries\CMSIS\Core\Include;..\Libraries\LPC55S6X\components\codec;.;..\..\..\components\libc\compilers\common\extension;..\Libraries\LPC55S6X\LPC55S6X;..\Libraries\LPC55S6X\LPC55S6X\drivers;..\..\..\components\drivers\include;..\..\..\include</IncludePath>
+              <IncludePath>..\..\..\components\libc\posix\ipc;board;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board\MCUX_Config\board;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\Libraries\LPC55S6X\middleware\sdmmc\port;..\..\..\components\drivers\include;..\Libraries\drivers;..\..\..\components\dfs\include;..\..\..\components\libc\posix\io\poll;..\Libraries\drivers\config;..\..\..\components\dfs\filesystems\devfs;..\..\..\components\finsh;..\..\..\components\dfs\filesystems\elmfat;..\..\..\components\libc\compilers\common\include;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m33;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\Libraries\LPC55S6X\middleware\sdmmc\inc;..\..\..\components\libc\posix\io\stdio;..\..\..\components\utilities\libadt;applications;..\Libraries\CMSIS\Core\Include;..\Libraries\LPC55S6X\components\codec;.;..\..\..\components\libc\compilers\common\extension;..\Libraries\LPC55S6X\LPC55S6X;..\Libraries\LPC55S6X\LPC55S6X\drivers;..\..\..\components\drivers\include;..\..\..\include</IncludePath>
             </VariousControls>
           </Cads>
           <Aads>
@@ -381,6 +381,16 @@
         </TargetArmAds>
       </TargetOption>
       <Groups>
+        <Group>
+          <GroupName>ADT</GroupName>
+          <Files>
+            <File>
+              <FileName>avl.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\utilities\libadt\avl.c</FilePath>
+            </File>
+          </Files>
+        </Group>
         <Group>
           <GroupName>Applications</GroupName>
           <Files>
@@ -524,6 +534,41 @@
               <FileType>1</FileType>
               <FilePath>..\..\..\components\drivers\misc\pin.c</FilePath>
             </File>
+            <File>
+              <FileName>rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\drivers\rtc\rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>block_dev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\drivers\sdio\block_dev.c</FilePath>
+            </File>
+            <File>
+              <FileName>gpt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\drivers\sdio\gpt.c</FilePath>
+            </File>
+            <File>
+              <FileName>mmc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\drivers\sdio\mmc.c</FilePath>
+            </File>
+            <File>
+              <FileName>mmcsd_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\drivers\sdio\mmcsd_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>sd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\drivers\sdio\sd.c</FilePath>
+            </File>
+            <File>
+              <FileName>sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\drivers\sdio\sdio.c</FilePath>
+            </File>
             <File>
               <FileName>serial.c</FileName>
               <FileType>1</FileType>
@@ -574,6 +619,16 @@
               <FileType>1</FileType>
               <FilePath>..\Libraries\drivers\drv_pin.c</FilePath>
             </File>
+            <File>
+              <FileName>drv_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Libraries\drivers\drv_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>drv_sdif.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Libraries\drivers\drv_sdif.c</FilePath>
+            </File>
             <File>
               <FileName>drv_uart.c</FileName>
               <FileType>1</FileType>
@@ -581,6 +636,51 @@
             </File>
           </Files>
         </Group>
+        <Group>
+          <GroupName>Filesystem</GroupName>
+          <Files>
+            <File>
+              <FileName>devfs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\filesystems\devfs\devfs.c</FilePath>
+            </File>
+            <File>
+              <FileName>dfs_elm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\filesystems\elmfat\dfs_elm.c</FilePath>
+            </File>
+            <File>
+              <FileName>ff.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\filesystems\elmfat\ff.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffunicode.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\filesystems\elmfat\ffunicode.c</FilePath>
+            </File>
+            <File>
+              <FileName>dfs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\src\dfs.c</FilePath>
+            </File>
+            <File>
+              <FileName>dfs_file.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\src\dfs_file.c</FilePath>
+            </File>
+            <File>
+              <FileName>dfs_fs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\src\dfs_fs.c</FilePath>
+            </File>
+            <File>
+              <FileName>dfs_posix.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\dfs\src\dfs_posix.c</FilePath>
+            </File>
+          </Files>
+        </Group>
         <Group>
           <GroupName>Finsh</GroupName>
           <Files>
@@ -604,6 +704,11 @@
               <FileType>1</FileType>
               <FilePath>..\..\..\components\finsh\cmd.c</FilePath>
             </File>
+            <File>
+              <FileName>msh_file.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\components\finsh\msh_file.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>
@@ -896,13 +1001,4 @@
     <files/>
   </RTE>
 
-  <LayerInfo>
-    <Layers>
-      <Layer>
-        <LayName>project</LayName>
-        <LayPrjMark>1</LayPrjMark>
-      </Layer>
-    </Layers>
-  </LayerInfo>
-
 </Project>

+ 32 - 2
bsp/lpc55sxx/lpc55s69_nxp_evk/rtconfig.h

@@ -37,6 +37,7 @@
 
 /* Memory Management */
 
+#define RT_PAGE_MAX_ORDER 11
 #define RT_USING_MEMPOOL
 #define RT_USING_SMALL_MEM
 #define RT_USING_SMALL_MEM_AS_HEAP
@@ -67,13 +68,33 @@
 #define FINSH_THREAD_NAME "tshell"
 #define FINSH_THREAD_PRIORITY 20
 #define FINSH_THREAD_STACK_SIZE 4096
-#define FINSH_USING_HISTORY
-#define FINSH_HISTORY_LINES 5
 #define FINSH_USING_SYMTAB
 #define FINSH_CMD_SIZE 80
 #define MSH_USING_BUILT_IN_COMMANDS
 #define FINSH_USING_DESCRIPTION
 #define FINSH_ARG_MAX 10
+#define RT_USING_DFS
+#define DFS_USING_POSIX
+#define DFS_USING_WORKDIR
+#define DFS_FILESYSTEMS_MAX 4
+#define DFS_FILESYSTEM_TYPES_MAX 4
+#define DFS_FD_MAX 16
+#define RT_USING_DFS_ELMFAT
+
+/* elm-chan's FatFs, Generic FAT Filesystem Module */
+
+#define RT_DFS_ELM_CODE_PAGE 437
+#define RT_DFS_ELM_WORD_ACCESS
+#define RT_DFS_ELM_USE_LFN_3
+#define RT_DFS_ELM_USE_LFN 3
+#define RT_DFS_ELM_LFN_UNICODE_0
+#define RT_DFS_ELM_LFN_UNICODE 0
+#define RT_DFS_ELM_MAX_LFN 255
+#define RT_DFS_ELM_DRIVES 2
+#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
+#define RT_DFS_ELM_REENTRANT
+#define RT_DFS_ELM_MUTEX_TIMEOUT 3000
+#define RT_USING_DFS_DEVFS
 
 /* Device Drivers */
 
@@ -85,6 +106,13 @@
 #define RT_SERIAL_RB_BUFSZ 64
 #define RT_USING_I2C
 #define RT_USING_PIN
+#define RT_USING_RTC
+#define RT_USING_SDIO
+#define RT_SDIO_STACK_SIZE 512
+#define RT_SDIO_THREAD_PRIORITY 15
+#define RT_MMCSD_STACK_SIZE 1024
+#define RT_MMCSD_THREAD_PREORITY 22
+#define RT_MMCSD_MAX_PARTITION 16
 
 /* Using USB */
 
@@ -239,6 +267,8 @@
 #define BSP_USING_I2C
 #define BSP_USING_I2C4
 #define HW_I2C4_BAUDRATE_100kHZ
+#define BSP_USING_SDIO
+#define BSP_USING_RTC
 
 /* Onboard Peripheral Drivers */
 

Some files were not shown because too many files changed in this diff