Skip to content

Commit a4f45b9

Browse files
committed
F7_HAL/mmc: Set the MMC relative address correctly.
This fix comes from the H7 HAL v1.9.0. Signed-off-by: Damien George <[email protected]>
1 parent 4b64949 commit a4f45b9

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_sdmmc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ uint32_t SDMMC_CmdSendSCR(SDMMC_TypeDef *SDMMCx);
994994
uint32_t SDMMC_CmdSendCID(SDMMC_TypeDef *SDMMCx);
995995
uint32_t SDMMC_CmdSendCSD(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
996996
uint32_t SDMMC_CmdSetRelAdd(SDMMC_TypeDef *SDMMCx, uint16_t *pRCA);
997+
uint32_t SDMMC_CmdSetRelAddMmc(SDMMC_TypeDef *SDMMCx, uint16_t RCA);
997998
uint32_t SDMMC_CmdSendStatus(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
998999
uint32_t SDMMC_CmdStatusRegister(SDMMC_TypeDef *SDMMCx);
9991000
uint32_t SDMMC_CmdOpCondition(SDMMC_TypeDef *SDMMCx, uint32_t Argument);

STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_mmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,7 @@ static uint32_t MMC_InitCard(MMC_HandleTypeDef *hmmc)
22932293

22942294
/* Send CMD3 SET_REL_ADDR with argument 0 */
22952295
/* MMC Card publishes its RCA. */
2296-
errorstate = SDMMC_CmdSetRelAdd(hmmc->Instance, &mmc_rca);
2296+
errorstate = SDMMC_CmdSetRelAddMmc(hmmc->Instance, mmc_rca);
22972297
if(errorstate != HAL_MMC_ERROR_NONE)
22982298
{
22992299
return errorstate;

STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_sdmmc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,31 @@ uint32_t SDMMC_CmdSetRelAdd(SDMMC_TypeDef *SDMMCx, uint16_t *pRCA)
10341034
return errorstate;
10351035
}
10361036

1037+
/**
1038+
* @brief Send the Set Relative Address command to MMC card (not SD card).
1039+
* @param SDMMCx Pointer to SDMMC register base
1040+
* @param RCA Card RCA
1041+
* @retval HAL status
1042+
*/
1043+
uint32_t SDMMC_CmdSetRelAddMmc(SDMMC_TypeDef *SDMMCx, uint16_t RCA)
1044+
{
1045+
SDMMC_CmdInitTypeDef sdmmc_cmdinit;
1046+
uint32_t errorstate;
1047+
1048+
/* Send CMD3 SD_CMD_SET_REL_ADDR */
1049+
sdmmc_cmdinit.Argument = ((uint32_t)RCA << 16U);
1050+
sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SET_REL_ADDR;
1051+
sdmmc_cmdinit.Response = SDMMC_RESPONSE_SHORT;
1052+
sdmmc_cmdinit.WaitForInterrupt = SDMMC_WAIT_NO;
1053+
sdmmc_cmdinit.CPSM = SDMMC_CPSM_ENABLE;
1054+
(void)SDMMC_SendCommand(SDMMCx, &sdmmc_cmdinit);
1055+
1056+
/* Check for error conditions */
1057+
errorstate = SDMMC_GetCmdResp1(SDMMCx, SDMMC_CMD_SET_REL_ADDR, SDMMC_CMDTIMEOUT);
1058+
1059+
return errorstate;
1060+
}
1061+
10371062
/**
10381063
* @brief Send the Status command and check the response.
10391064
* @param SDMMCx: Pointer to SDMMC register base

0 commit comments

Comments
 (0)