update to CubeMX 6.14.0, FW_H7 1.12.1
This commit is contained in:
@ -56,7 +56,6 @@
|
||||
|
||||
(#) At this stage, you can perform SD read/write/erase operations after SD card initialization
|
||||
|
||||
|
||||
*** SD Card Initialization and configuration ***
|
||||
================================================
|
||||
[..]
|
||||
@ -211,7 +210,7 @@
|
||||
respectively HAL_SD_RegisterTransceiverCallback().
|
||||
|
||||
Use function HAL_SD_UnRegisterCallback() to reset a callback to the default
|
||||
weak (surcharged) function. It allows to reset following callbacks:
|
||||
weak (overridden) function. It allows to reset following callbacks:
|
||||
(+) TxCpltCallback : callback when a transmission transfer is completed.
|
||||
(+) RxCpltCallback : callback when a reception transfer is completed.
|
||||
(+) ErrorCallback : callback when error occurs.
|
||||
@ -227,9 +226,9 @@
|
||||
respectively HAL_SD_UnRegisterTransceiverCallback().
|
||||
|
||||
By default, after the HAL_SD_Init and if the state is HAL_SD_STATE_RESET
|
||||
all callbacks are reset to the corresponding legacy weak (surcharged) functions.
|
||||
all callbacks are reset to the corresponding legacy weak (overridden) functions.
|
||||
Exception done for MspInit and MspDeInit callbacks that are respectively
|
||||
reset to the legacy weak (surcharged) functions in the HAL_SD_Init
|
||||
reset to the legacy weak (overridden) functions in the HAL_SD_Init
|
||||
and HAL_SD_DeInit only when these callbacks are null (not registered beforehand).
|
||||
If not, MspInit or MspDeInit are not null, the HAL_SD_Init and HAL_SD_DeInit
|
||||
keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
|
||||
@ -244,7 +243,7 @@
|
||||
|
||||
When The compilation define USE_HAL_SD_REGISTER_CALLBACKS is set to 0 or
|
||||
not defined, the callback registering feature is not available
|
||||
and weak (surcharged) callbacks are used.
|
||||
and weak (overridden) callbacks are used.
|
||||
|
||||
@endverbatim
|
||||
******************************************************************************
|
||||
@ -261,6 +260,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (SDMMC1) || defined (SDMMC2)
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@ -439,7 +439,7 @@ HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd)
|
||||
tickstart = HAL_GetTick();
|
||||
while ((HAL_SD_GetCardState(hsd) != HAL_SD_CARD_TRANSFER))
|
||||
{
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
@ -607,7 +607,6 @@ HAL_StatusTypeDef HAL_SD_DeInit(SD_HandleTypeDef *hsd)
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the SD MSP.
|
||||
* @param hsd: Pointer to SD handle
|
||||
@ -704,7 +703,7 @@ HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint3
|
||||
|
||||
if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
|
||||
{
|
||||
add *= 512U;
|
||||
add *= BLOCKSIZE;
|
||||
}
|
||||
|
||||
/* Configure the SD DPSM (Data Path State Machine) */
|
||||
@ -746,10 +745,10 @@ HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint3
|
||||
dataremaining = config.DataLength;
|
||||
while (!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXOVERR | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT | SDMMC_FLAG_DATAEND))
|
||||
{
|
||||
if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXFIFOHF) && (dataremaining >= 32U))
|
||||
if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXFIFOHF) && (dataremaining >= SDMMC_FIFO_SIZE))
|
||||
{
|
||||
/* Read data from SDMMC Rx FIFO */
|
||||
for (count = 0U; count < 8U; count++)
|
||||
for (count = 0U; count < (SDMMC_FIFO_SIZE / 4U); count++)
|
||||
{
|
||||
data = SDMMC_ReadFIFO(hsd->Instance);
|
||||
*tempbuff = (uint8_t)(data & 0xFFU);
|
||||
@ -761,7 +760,7 @@ HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint3
|
||||
*tempbuff = (uint8_t)((data >> 24U) & 0xFFU);
|
||||
tempbuff++;
|
||||
}
|
||||
dataremaining -= 32U;
|
||||
dataremaining -= SDMMC_FIFO_SIZE;
|
||||
}
|
||||
|
||||
if (((HAL_GetTick() - tickstart) >= Timeout) || (Timeout == 0U))
|
||||
@ -889,7 +888,7 @@ HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, const uint8_t *pData
|
||||
|
||||
if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
|
||||
{
|
||||
add *= 512U;
|
||||
add *= BLOCKSIZE;
|
||||
}
|
||||
|
||||
/* Configure the SD DPSM (Data Path State Machine) */
|
||||
@ -932,10 +931,10 @@ HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, const uint8_t *pData
|
||||
while (!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_TXUNDERR | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT |
|
||||
SDMMC_FLAG_DATAEND))
|
||||
{
|
||||
if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_TXFIFOHE) && (dataremaining >= 32U))
|
||||
if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_TXFIFOHE) && (dataremaining >= SDMMC_FIFO_SIZE))
|
||||
{
|
||||
/* Write data to SDMMC Tx FIFO */
|
||||
for (count = 0U; count < 8U; count++)
|
||||
for (count = 0U; count < (SDMMC_FIFO_SIZE / 4U); count++)
|
||||
{
|
||||
data = (uint32_t)(*tempbuff);
|
||||
tempbuff++;
|
||||
@ -947,7 +946,7 @@ HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, const uint8_t *pData
|
||||
tempbuff++;
|
||||
(void)SDMMC_WriteFIFO(hsd->Instance, &data);
|
||||
}
|
||||
dataremaining -= 32U;
|
||||
dataremaining -= SDMMC_FIFO_SIZE;
|
||||
}
|
||||
|
||||
if (((HAL_GetTick() - tickstart) >= Timeout) || (Timeout == 0U))
|
||||
@ -1074,7 +1073,7 @@ HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, ui
|
||||
|
||||
if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
|
||||
{
|
||||
add *= 512U;
|
||||
add *= BLOCKSIZE;
|
||||
}
|
||||
|
||||
/* Configure the SD DPSM (Data Path State Machine) */
|
||||
@ -1169,7 +1168,7 @@ HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, const uint8_t *pD
|
||||
|
||||
if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
|
||||
{
|
||||
add *= 512U;
|
||||
add *= BLOCKSIZE;
|
||||
}
|
||||
|
||||
/* Configure the SD DPSM (Data Path State Machine) */
|
||||
@ -1266,7 +1265,7 @@ HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, u
|
||||
|
||||
if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
|
||||
{
|
||||
add *= 512U;
|
||||
add *= BLOCKSIZE;
|
||||
}
|
||||
|
||||
/* Configure the SD DPSM (Data Path State Machine) */
|
||||
@ -1310,7 +1309,6 @@ HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, u
|
||||
/* Enable transfer interrupts */
|
||||
__HAL_SD_ENABLE_IT(hsd, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_RXOVERR | SDMMC_IT_DATAEND));
|
||||
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
else
|
||||
@ -1365,7 +1363,7 @@ HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, const uint8_t *p
|
||||
|
||||
if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
|
||||
{
|
||||
add *= 512U;
|
||||
add *= BLOCKSIZE;
|
||||
}
|
||||
|
||||
/* Configure the SD DPSM (Data Path State Machine) */
|
||||
@ -1377,7 +1375,6 @@ HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, const uint8_t *p
|
||||
config.DPSM = SDMMC_DPSM_DISABLE;
|
||||
(void)SDMMC_ConfigData(hsd->Instance, &config);
|
||||
|
||||
|
||||
__SDMMC_CMDTRANS_ENABLE(hsd->Instance);
|
||||
|
||||
hsd->Instance->IDMABASE0 = (uint32_t) pData ;
|
||||
@ -1474,8 +1471,8 @@ HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, ui
|
||||
/* Get start and end block for high capacity cards */
|
||||
if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
|
||||
{
|
||||
start_add *= 512U;
|
||||
end_add *= 512U;
|
||||
start_add *= BLOCKSIZE;
|
||||
end_add *= BLOCKSIZE;
|
||||
}
|
||||
|
||||
/* According to sd-card spec 1.0 ERASE_GROUP_START (CMD32) and erase_group_end(CMD33) */
|
||||
@ -1765,7 +1762,7 @@ void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd)
|
||||
* @param hsd: Pointer to sd handle
|
||||
* @retval HAL state
|
||||
*/
|
||||
HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd)
|
||||
HAL_SD_StateTypeDef HAL_SD_GetState(const SD_HandleTypeDef *hsd)
|
||||
{
|
||||
return hsd->State;
|
||||
}
|
||||
@ -1776,7 +1773,7 @@ HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd)
|
||||
* the configuration information.
|
||||
* @retval SD Error Code
|
||||
*/
|
||||
uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd)
|
||||
uint32_t HAL_SD_GetError(const SD_HandleTypeDef *hsd)
|
||||
{
|
||||
return hsd->ErrorCode;
|
||||
}
|
||||
@ -1860,9 +1857,9 @@ __weak void HAL_SD_DriveTransceiver_1_8V_Callback(FlagStatus status)
|
||||
#if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U)
|
||||
/**
|
||||
* @brief Register a User SD Callback
|
||||
* To be used instead of the weak (surcharged) predefined callback
|
||||
* @note The HAL_SD_RegisterCallback() may be called before HAL_SD_Init() in
|
||||
* HAL_SD_STATE_RESET to register callbacks for HAL_SD_MSP_INIT_CB_ID
|
||||
* To be used instead of the weak (overridden) predefined callback
|
||||
* @note The HAL_SD_RegisterCallback() may be called before HAL_SD_Init() in
|
||||
* HAL_SD_STATE_RESET to register callbacks for HAL_SD_MSP_INIT_CB_ID
|
||||
* and HAL_SD_MSP_DEINIT_CB_ID.
|
||||
* @param hsd : SD handle
|
||||
* @param CallbackID : ID of the callback to be registered
|
||||
@ -1965,9 +1962,9 @@ HAL_StatusTypeDef HAL_SD_RegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_Callback
|
||||
|
||||
/**
|
||||
* @brief Unregister a User SD Callback
|
||||
* SD Callback is redirected to the weak (surcharged) predefined callback
|
||||
* @note The HAL_SD_UnRegisterCallback() may be called before HAL_SD_Init() in
|
||||
* HAL_SD_STATE_RESET to register callbacks for HAL_SD_MSP_INIT_CB_ID
|
||||
* SD Callback is redirected to the weak (overridden) predefined callback
|
||||
* @note The HAL_SD_UnRegisterCallback() may be called before HAL_SD_Init() in
|
||||
* HAL_SD_STATE_RESET to register callbacks for HAL_SD_MSP_INIT_CB_ID
|
||||
* and HAL_SD_MSP_DEINIT_CB_ID.
|
||||
* @param hsd : SD handle
|
||||
* @param CallbackID : ID of the callback to be unregistered
|
||||
@ -2062,7 +2059,7 @@ HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_Callba
|
||||
#if (USE_SD_TRANSCEIVER != 0U)
|
||||
/**
|
||||
* @brief Register a User SD Transceiver Callback
|
||||
* To be used instead of the weak (surcharged) predefined callback
|
||||
* To be used instead of the weak (overridden) predefined callback
|
||||
* @param hsd : SD handle
|
||||
* @param pCallback : pointer to the Callback function
|
||||
* @retval status
|
||||
@ -2100,7 +2097,7 @@ HAL_StatusTypeDef HAL_SD_RegisterTransceiverCallback(SD_HandleTypeDef *hsd, pSD_
|
||||
|
||||
/**
|
||||
* @brief Unregister a User SD Transceiver Callback
|
||||
* SD Callback is redirected to the weak (surcharged) predefined callback
|
||||
* SD Callback is redirected to the weak (overridden) predefined callback
|
||||
* @param hsd : SD handle
|
||||
* @retval status
|
||||
*/
|
||||
@ -2157,7 +2154,7 @@ HAL_StatusTypeDef HAL_SD_UnRegisterTransceiverCallback(SD_HandleTypeDef *hsd)
|
||||
* contains all CID register parameters
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID)
|
||||
HAL_StatusTypeDef HAL_SD_GetCardCID(const SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID)
|
||||
{
|
||||
pCID->ManufacturerID = (uint8_t)((hsd->CID[0] & 0xFF000000U) >> 24U);
|
||||
|
||||
@ -2236,8 +2233,8 @@ HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef
|
||||
hsd->SdCard.BlockNbr *= (1UL << ((pCSD->DeviceSizeMul & 0x07U) + 2U));
|
||||
hsd->SdCard.BlockSize = (1UL << (pCSD->RdBlockLen & 0x0FU));
|
||||
|
||||
hsd->SdCard.LogBlockNbr = (hsd->SdCard.BlockNbr) * ((hsd->SdCard.BlockSize) / 512U);
|
||||
hsd->SdCard.LogBlockSize = 512U;
|
||||
hsd->SdCard.LogBlockNbr = (hsd->SdCard.BlockNbr) * ((hsd->SdCard.BlockSize) / BLOCKSIZE);
|
||||
hsd->SdCard.LogBlockSize = BLOCKSIZE;
|
||||
}
|
||||
else if (hsd->SdCard.CardType == CARD_SDHC_SDXC)
|
||||
{
|
||||
@ -2246,7 +2243,7 @@ HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef
|
||||
|
||||
hsd->SdCard.BlockNbr = ((pCSD->DeviceSize + 1U) * 1024U);
|
||||
hsd->SdCard.LogBlockNbr = hsd->SdCard.BlockNbr;
|
||||
hsd->SdCard.BlockSize = 512U;
|
||||
hsd->SdCard.BlockSize = BLOCKSIZE;
|
||||
hsd->SdCard.LogBlockSize = hsd->SdCard.BlockSize;
|
||||
}
|
||||
else
|
||||
@ -2363,7 +2360,6 @@ HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusT
|
||||
status = HAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -2374,7 +2370,7 @@ HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusT
|
||||
* will contain the SD card status information
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo)
|
||||
HAL_StatusTypeDef HAL_SD_GetCardInfo(const SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo)
|
||||
{
|
||||
pCardInfo->CardType = (uint32_t)(hsd->SdCard.CardType);
|
||||
pCardInfo->CardVersion = (uint32_t)(hsd->SdCard.CardVersion);
|
||||
@ -2404,6 +2400,7 @@ HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t
|
||||
SDMMC_InitTypeDef Init;
|
||||
uint32_t errorstate;
|
||||
uint32_t sdmmc_clk;
|
||||
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
/* Check the parameters */
|
||||
@ -2833,7 +2830,7 @@ HAL_StatusTypeDef HAL_SD_ConfigSpeedBusOperation(SD_HandleTypeDef *hsd, uint32_t
|
||||
tickstart = HAL_GetTick();
|
||||
while ((HAL_SD_GetCardState(hsd) != HAL_SD_CARD_TRANSFER))
|
||||
{
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
@ -2893,11 +2890,12 @@ HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
/* DIsable All interrupts */
|
||||
__HAL_SD_DISABLE_IT(hsd, SDMMC_IT_DATAEND | SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | \
|
||||
SDMMC_IT_TXUNDERR | SDMMC_IT_RXOVERR);
|
||||
SDMMC_IT_TXUNDERR | SDMMC_IT_RXOVERR);
|
||||
__SDMMC_CMDTRANS_DISABLE(hsd->Instance);
|
||||
|
||||
/*we will send the CMD12 in all cases in order to stop the data transfers*/
|
||||
/*In case the data transfer just finished , the external memory will not respond and will return HAL_SD_ERROR_CMD_RSP_TIMEOUT*/
|
||||
/*In case the data transfer just finished , the external memory will not respond
|
||||
and will return HAL_SD_ERROR_CMD_RSP_TIMEOUT*/
|
||||
/*In case the data transfer aborted , the external memory will respond and will return HAL_SD_ERROR_NONE*/
|
||||
/*Other scenario will return HAL_ERROR*/
|
||||
|
||||
@ -2913,40 +2911,40 @@ HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
if (hsd->ErrorCode == HAL_SD_ERROR_NONE)
|
||||
{
|
||||
while(!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DABORT | SDMMC_FLAG_BUSYD0END))
|
||||
while (!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DABORT | SDMMC_FLAG_BUSYD0END))
|
||||
{
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
return HAL_TIMEOUT;
|
||||
}
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
return HAL_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hsd->ErrorCode == HAL_SD_ERROR_CMD_RSP_TIMEOUT)
|
||||
{
|
||||
while(!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DATAEND))
|
||||
while (!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DATAEND))
|
||||
{
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
return HAL_TIMEOUT;
|
||||
}
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
return HAL_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((hsd->Instance->DCTRL & SDMMC_DCTRL_DTDIR) == SDMMC_TRANSFER_DIR_TO_SDMMC)
|
||||
{
|
||||
while(!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DABORT | SDMMC_FLAG_DATAEND))
|
||||
while (!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DABORT | SDMMC_FLAG_DATAEND))
|
||||
{
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
return HAL_TIMEOUT;
|
||||
}
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
return HAL_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2962,7 +2960,7 @@ HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd)
|
||||
/*SDMMC ready for clear data flags*/
|
||||
__HAL_SD_CLEAR_FLAG(hsd, SDMMC_FLAG_BUSYD0END);
|
||||
__HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_DATA_FLAGS);
|
||||
/* If IDMA Context, disable Internal DMA */
|
||||
/* If IDMA Context, disable Internal DMA */
|
||||
hsd->Instance->IDMACTRL = SDMMC_DISABLE_IDMA;
|
||||
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
@ -2973,7 +2971,6 @@ HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd)
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Abort the current transfer and disable the SD (IT mode).
|
||||
* @param hsd: pointer to a SD_HandleTypeDef structure that contains
|
||||
@ -3031,7 +3028,6 @@ HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd)
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the sd card.
|
||||
* @param hsd: Pointer to SD handle
|
||||
@ -3237,7 +3233,7 @@ static uint32_t SD_PowerON(SD_HandleTypeDef *hsd)
|
||||
/* Check to CKSTOP */
|
||||
while ((hsd->Instance->STA & SDMMC_FLAG_CKSTOP) != SDMMC_FLAG_CKSTOP)
|
||||
{
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
return HAL_SD_ERROR_TIMEOUT;
|
||||
}
|
||||
@ -3267,7 +3263,7 @@ static uint32_t SD_PowerON(SD_HandleTypeDef *hsd)
|
||||
/* Check VSWEND Flag */
|
||||
while ((hsd->Instance->STA & SDMMC_FLAG_VSWEND) != SDMMC_FLAG_VSWEND)
|
||||
{
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
return HAL_SD_ERROR_TIMEOUT;
|
||||
}
|
||||
@ -3375,7 +3371,7 @@ static uint32_t SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus)
|
||||
}
|
||||
}
|
||||
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
return HAL_SD_ERROR_TIMEOUT;
|
||||
}
|
||||
@ -3403,7 +3399,7 @@ static uint32_t SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus)
|
||||
*pData = SDMMC_ReadFIFO(hsd->Instance);
|
||||
pData++;
|
||||
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
return HAL_SD_ERROR_TIMEOUT;
|
||||
}
|
||||
@ -3538,7 +3534,6 @@ static uint32_t SD_WideBus_Disable(SD_HandleTypeDef *hsd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Finds the SD card SCR register value.
|
||||
* @param hsd: Pointer to SD handle
|
||||
@ -3593,8 +3588,7 @@ static uint32_t SD_FindSCR(SD_HandleTypeDef *hsd, uint32_t *pSCR)
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
return HAL_SD_ERROR_TIMEOUT;
|
||||
}
|
||||
@ -3624,11 +3618,11 @@ static uint32_t SD_FindSCR(SD_HandleTypeDef *hsd, uint32_t *pSCR)
|
||||
/* Clear all the static flags */
|
||||
__HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_DATA_FLAGS);
|
||||
|
||||
*scr = (((tempscr[1] & SDMMC_0TO7BITS) << 24) | ((tempscr[1] & SDMMC_8TO15BITS) << 8) | \
|
||||
((tempscr[1] & SDMMC_16TO23BITS) >> 8) | ((tempscr[1] & SDMMC_24TO31BITS) >> 24));
|
||||
*scr = (((tempscr[1] & SDMMC_0TO7BITS) << 24U) | ((tempscr[1] & SDMMC_8TO15BITS) << 8U) | \
|
||||
((tempscr[1] & SDMMC_16TO23BITS) >> 8U) | ((tempscr[1] & SDMMC_24TO31BITS) >> 24U));
|
||||
scr++;
|
||||
*scr = (((tempscr[0] & SDMMC_0TO7BITS) << 24) | ((tempscr[0] & SDMMC_8TO15BITS) << 8) | \
|
||||
((tempscr[0] & SDMMC_16TO23BITS) >> 8) | ((tempscr[0] & SDMMC_24TO31BITS) >> 24));
|
||||
*scr = (((tempscr[0] & SDMMC_0TO7BITS) << 24U) | ((tempscr[0] & SDMMC_8TO15BITS) << 8U) | \
|
||||
((tempscr[0] & SDMMC_16TO23BITS) >> 8U) | ((tempscr[0] & SDMMC_24TO31BITS) >> 24U));
|
||||
|
||||
}
|
||||
|
||||
@ -3649,10 +3643,10 @@ static void SD_Read_IT(SD_HandleTypeDef *hsd)
|
||||
|
||||
tmp = hsd->pRxBuffPtr;
|
||||
|
||||
if (hsd->RxXferSize >= 32U)
|
||||
if (hsd->RxXferSize >= SDMMC_FIFO_SIZE)
|
||||
{
|
||||
/* Read data from SDMMC Rx FIFO */
|
||||
for (count = 0U; count < 8U; count++)
|
||||
for (count = 0U; count < (SDMMC_FIFO_SIZE / 4U); count++)
|
||||
{
|
||||
data = SDMMC_ReadFIFO(hsd->Instance);
|
||||
*tmp = (uint8_t)(data & 0xFFU);
|
||||
@ -3666,7 +3660,7 @@ static void SD_Read_IT(SD_HandleTypeDef *hsd)
|
||||
}
|
||||
|
||||
hsd->pRxBuffPtr = tmp;
|
||||
hsd->RxXferSize -= 32U;
|
||||
hsd->RxXferSize -= SDMMC_FIFO_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3684,10 +3678,10 @@ static void SD_Write_IT(SD_HandleTypeDef *hsd)
|
||||
|
||||
tmp = hsd->pTxBuffPtr;
|
||||
|
||||
if (hsd->TxXferSize >= 32U)
|
||||
if (hsd->TxXferSize >= SDMMC_FIFO_SIZE)
|
||||
{
|
||||
/* Write data to SDMMC Tx FIFO */
|
||||
for (count = 0U; count < 8U; count++)
|
||||
for (count = 0U; count < (SDMMC_FIFO_SIZE / 4U); count++)
|
||||
{
|
||||
data = (uint32_t)(*tmp);
|
||||
tmp++;
|
||||
@ -3701,7 +3695,7 @@ static void SD_Write_IT(SD_HandleTypeDef *hsd)
|
||||
}
|
||||
|
||||
hsd->pTxBuffPtr = tmp;
|
||||
hsd->TxXferSize -= 32U;
|
||||
hsd->TxXferSize -= SDMMC_FIFO_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3750,7 +3744,6 @@ uint32_t SD_SwitchSpeed(SD_HandleTypeDef *hsd, uint32_t SwitchSpeedMode)
|
||||
|
||||
(void)SDMMC_ConfigData(hsd->Instance, &sdmmc_datainitstructure);
|
||||
|
||||
|
||||
errorstate = SDMMC_CmdSwitch(hsd->Instance, SwitchSpeedMode);
|
||||
if (errorstate != HAL_SD_ERROR_NONE)
|
||||
{
|
||||
@ -3768,8 +3761,7 @@ uint32_t SD_SwitchSpeed(SD_HandleTypeDef *hsd, uint32_t SwitchSpeedMode)
|
||||
}
|
||||
loop ++;
|
||||
}
|
||||
|
||||
if ((HAL_GetTick() - Timeout) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - Timeout) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
@ -3885,7 +3877,7 @@ static uint32_t SD_UltraHighSpeed(SD_HandleTypeDef *hsd, uint32_t UltraHighSpeed
|
||||
loop ++;
|
||||
}
|
||||
|
||||
if ((HAL_GetTick() - Timeout) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - Timeout) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
@ -4015,7 +4007,7 @@ static uint32_t SD_DDR_Mode(SD_HandleTypeDef *hsd)
|
||||
loop ++;
|
||||
}
|
||||
|
||||
if ((HAL_GetTick() - Timeout) >= SDMMC_DATATIMEOUT)
|
||||
if ((HAL_GetTick() - Timeout) >= SDMMC_SWDATATIMEOUT)
|
||||
{
|
||||
hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;
|
||||
hsd->State = HAL_SD_STATE_READY;
|
||||
@ -4142,12 +4134,12 @@ __weak void HAL_SDEx_Write_DMADoubleBuf1CpltCallback(SD_HandleTypeDef *hsd)
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* HAL_SD_MODULE_ENABLED */
|
||||
#endif /* SDMMC1 || SDMMC2 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user