Lines Matching refs:hmmc
304 static uint32_t MMC_InitCard(MMC_HandleTypeDef *hmmc);
305 static uint32_t MMC_PowerON(MMC_HandleTypeDef *hmmc);
306 static uint32_t MMC_SendStatus(MMC_HandleTypeDef *hmmc, uint32_t *pCardStatus);
307 static void MMC_PowerOFF(MMC_HandleTypeDef *hmmc);
308 static void MMC_Write_IT(MMC_HandleTypeDef *hmmc);
309 static void MMC_Read_IT(MMC_HandleTypeDef *hmmc);
310 static uint32_t MMC_HighSpeed(MMC_HandleTypeDef *hmmc, FunctionalState state);
311 static uint32_t MMC_DDR_Mode(MMC_HandleTypeDef *hmmc, FunctionalState state);
312 static HAL_StatusTypeDef MMC_ReadExtCSD(MMC_HandleTypeDef *hmmc, uint32_t *pFieldData, uint16_t Fie…
314 static uint32_t MMC_PwrClassUpdate(MMC_HandleTypeDef *hmmc, uint32_t Wide, uint32_t Speed);
345 HAL_StatusTypeDef HAL_MMC_Init(MMC_HandleTypeDef *hmmc) in HAL_MMC_Init() argument
348 if (hmmc == NULL) in HAL_MMC_Init()
354 assert_param(IS_SDMMC_ALL_INSTANCE(hmmc->Instance)); in HAL_MMC_Init()
355 assert_param(IS_SDMMC_CLOCK_EDGE(hmmc->Init.ClockEdge)); in HAL_MMC_Init()
356 assert_param(IS_SDMMC_CLOCK_POWER_SAVE(hmmc->Init.ClockPowerSave)); in HAL_MMC_Init()
357 assert_param(IS_SDMMC_BUS_WIDE(hmmc->Init.BusWide)); in HAL_MMC_Init()
358 assert_param(IS_SDMMC_HARDWARE_FLOW_CONTROL(hmmc->Init.HardwareFlowControl)); in HAL_MMC_Init()
359 assert_param(IS_SDMMC_CLKDIV(hmmc->Init.ClockDiv)); in HAL_MMC_Init()
361 if (hmmc->State == HAL_MMC_STATE_RESET) in HAL_MMC_Init()
364 hmmc->Lock = HAL_UNLOCKED; in HAL_MMC_Init()
367 hmmc->TxCpltCallback = HAL_MMC_TxCpltCallback; in HAL_MMC_Init()
368 hmmc->RxCpltCallback = HAL_MMC_RxCpltCallback; in HAL_MMC_Init()
369 hmmc->ErrorCallback = HAL_MMC_ErrorCallback; in HAL_MMC_Init()
370 hmmc->AbortCpltCallback = HAL_MMC_AbortCallback; in HAL_MMC_Init()
371 hmmc->Read_DMALnkLstBufCpltCallback = HAL_MMCEx_Read_DMALnkLstBufCpltCallback; in HAL_MMC_Init()
372 hmmc->Write_DMALnkLstBufCpltCallback = HAL_MMCEx_Write_DMALnkLstBufCpltCallback; in HAL_MMC_Init()
374 if (hmmc->MspInitCallback == NULL) in HAL_MMC_Init()
376 hmmc->MspInitCallback = HAL_MMC_MspInit; in HAL_MMC_Init()
380 hmmc->MspInitCallback(hmmc); in HAL_MMC_Init()
383 HAL_MMC_MspInit(hmmc); in HAL_MMC_Init()
387 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_Init()
390 if (HAL_MMC_InitCard(hmmc) == HAL_ERROR) in HAL_MMC_Init()
396 hmmc->ErrorCode = HAL_DMA_ERROR_NONE; in HAL_MMC_Init()
399 hmmc->Context = MMC_CONTEXT_NONE; in HAL_MMC_Init()
402 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Init()
405 if (hmmc->Init.BusWide != SDMMC_BUS_WIDE_1B) in HAL_MMC_Init()
407 if (HAL_MMC_ConfigWideBusOperation(hmmc, hmmc->Init.BusWide) != HAL_OK) in HAL_MMC_Init()
423 HAL_StatusTypeDef HAL_MMC_InitCard(MMC_HandleTypeDef *hmmc) in HAL_MMC_InitCard() argument
439 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_InitCard()
440 hmmc->ErrorCode = SDMMC_ERROR_INVALID_PARAMETER; in HAL_MMC_InitCard()
450 (void)SDMMC_Init(hmmc->Instance, Init); in HAL_MMC_InitCard()
453 (void)SDMMC_PowerState_ON(hmmc->Instance); in HAL_MMC_InitCard()
468 errorstate = MMC_PowerON(hmmc); in HAL_MMC_InitCard()
471 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_InitCard()
472 hmmc->ErrorCode |= errorstate; in HAL_MMC_InitCard()
477 errorstate = MMC_InitCard(hmmc); in HAL_MMC_InitCard()
480 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_InitCard()
481 hmmc->ErrorCode |= errorstate; in HAL_MMC_InitCard()
486 errorstate = SDMMC_CmdBlockLength(hmmc->Instance, MMC_BLOCKSIZE); in HAL_MMC_InitCard()
490 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_InitCard()
491 hmmc->ErrorCode |= errorstate; in HAL_MMC_InitCard()
492 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_InitCard()
504 HAL_StatusTypeDef HAL_MMC_DeInit(MMC_HandleTypeDef *hmmc) in HAL_MMC_DeInit() argument
507 if (hmmc == NULL) in HAL_MMC_DeInit()
513 assert_param(IS_SDMMC_ALL_INSTANCE(hmmc->Instance)); in HAL_MMC_DeInit()
515 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_DeInit()
518 MMC_PowerOFF(hmmc); in HAL_MMC_DeInit()
521 if (hmmc->MspDeInitCallback == NULL) in HAL_MMC_DeInit()
523 hmmc->MspDeInitCallback = HAL_MMC_MspDeInit; in HAL_MMC_DeInit()
527 hmmc->MspDeInitCallback(hmmc); in HAL_MMC_DeInit()
530 HAL_MMC_MspDeInit(hmmc); in HAL_MMC_DeInit()
533 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_DeInit()
534 hmmc->State = HAL_MMC_STATE_RESET; in HAL_MMC_DeInit()
545 __weak void HAL_MMC_MspInit(MMC_HandleTypeDef *hmmc) in HAL_MMC_MspInit() argument
548 UNUSED(hmmc); in HAL_MMC_MspInit()
560 __weak void HAL_MMC_MspDeInit(MMC_HandleTypeDef *hmmc) in HAL_MMC_MspDeInit() argument
563 UNUSED(hmmc); in HAL_MMC_MspDeInit()
601 HAL_StatusTypeDef HAL_MMC_ReadBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, in HAL_MMC_ReadBlocks() argument
616 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_ReadBlocks()
620 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_ReadBlocks()
622 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_ReadBlocks()
624 if ((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_ReadBlocks()
626 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_ReadBlocks()
631 if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) in HAL_MMC_ReadBlocks()
637 hmmc->ErrorCode |= HAL_MMC_ERROR_BLOCK_LEN_ERR; in HAL_MMC_ReadBlocks()
644 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_ReadBlocks()
649 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_ReadBlocks()
652 hmmc->Instance->DCTRL = 0U; in HAL_MMC_ReadBlocks()
654 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_ReadBlocks()
666 (void)SDMMC_ConfigData(hmmc->Instance, &config); in HAL_MMC_ReadBlocks()
667 __SDMMC_CMDTRANS_ENABLE(hmmc->Instance); in HAL_MMC_ReadBlocks()
672 hmmc->Context = MMC_CONTEXT_READ_MULTIPLE_BLOCK; in HAL_MMC_ReadBlocks()
675 errorstate = SDMMC_CmdReadMultiBlock(hmmc->Instance, add); in HAL_MMC_ReadBlocks()
679 hmmc->Context = MMC_CONTEXT_READ_SINGLE_BLOCK; in HAL_MMC_ReadBlocks()
682 errorstate = SDMMC_CmdReadSingleBlock(hmmc->Instance, add); in HAL_MMC_ReadBlocks()
687 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks()
688 hmmc->ErrorCode |= errorstate; in HAL_MMC_ReadBlocks()
689 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks()
695 while (!__HAL_MMC_GET_FLAG(hmmc, in HAL_MMC_ReadBlocks()
698 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXFIFOHF) && (dataremaining >= SDMMC_FIFO_SIZE)) in HAL_MMC_ReadBlocks()
703 data = SDMMC_ReadFIFO(hmmc->Instance); in HAL_MMC_ReadBlocks()
719 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks()
720 hmmc->ErrorCode |= HAL_MMC_ERROR_TIMEOUT; in HAL_MMC_ReadBlocks()
721 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks()
725 __SDMMC_CMDTRANS_DISABLE(hmmc->Instance); in HAL_MMC_ReadBlocks()
728 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DATAEND) && (NumberOfBlocks > 1U)) in HAL_MMC_ReadBlocks()
731 errorstate = SDMMC_CmdStopTransfer(hmmc->Instance); in HAL_MMC_ReadBlocks()
735 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks()
736 hmmc->ErrorCode |= errorstate; in HAL_MMC_ReadBlocks()
737 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks()
743 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DTIMEOUT)) in HAL_MMC_ReadBlocks()
746 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks()
747 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_TIMEOUT; in HAL_MMC_ReadBlocks()
748 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks()
751 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DCRCFAIL)) in HAL_MMC_ReadBlocks()
754 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks()
755 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_CRC_FAIL; in HAL_MMC_ReadBlocks()
756 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks()
759 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXOVERR)) in HAL_MMC_ReadBlocks()
762 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks()
763 hmmc->ErrorCode |= HAL_MMC_ERROR_RX_OVERRUN; in HAL_MMC_ReadBlocks()
764 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks()
773 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_ReadBlocks()
775 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks()
781 hmmc->ErrorCode |= HAL_MMC_ERROR_BUSY; in HAL_MMC_ReadBlocks()
798 HAL_StatusTypeDef HAL_MMC_WriteBlocks(MMC_HandleTypeDef *hmmc, const uint8_t *pData, uint32_t Block… in HAL_MMC_WriteBlocks() argument
812 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_WriteBlocks()
816 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_WriteBlocks()
818 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_WriteBlocks()
820 if ((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_WriteBlocks()
822 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_WriteBlocks()
827 …if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) & 0x0… in HAL_MMC_WriteBlocks()
832 hmmc->ErrorCode |= HAL_MMC_ERROR_BLOCK_LEN_ERR; in HAL_MMC_WriteBlocks()
839 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_WriteBlocks()
844 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_WriteBlocks()
847 hmmc->Instance->DCTRL = 0U; in HAL_MMC_WriteBlocks()
849 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_WriteBlocks()
861 (void)SDMMC_ConfigData(hmmc->Instance, &config); in HAL_MMC_WriteBlocks()
862 __SDMMC_CMDTRANS_ENABLE(hmmc->Instance); in HAL_MMC_WriteBlocks()
867 hmmc->Context = MMC_CONTEXT_WRITE_MULTIPLE_BLOCK; in HAL_MMC_WriteBlocks()
870 errorstate = SDMMC_CmdWriteMultiBlock(hmmc->Instance, add); in HAL_MMC_WriteBlocks()
874 hmmc->Context = MMC_CONTEXT_WRITE_SINGLE_BLOCK; in HAL_MMC_WriteBlocks()
877 errorstate = SDMMC_CmdWriteSingleBlock(hmmc->Instance, add); in HAL_MMC_WriteBlocks()
882 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks()
883 hmmc->ErrorCode |= errorstate; in HAL_MMC_WriteBlocks()
884 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks()
890 while (!__HAL_MMC_GET_FLAG(hmmc, in HAL_MMC_WriteBlocks()
893 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_TXFIFOHE) && (dataremaining >= SDMMC_FIFO_SIZE)) in HAL_MMC_WriteBlocks()
906 (void)SDMMC_WriteFIFO(hmmc->Instance, &data); in HAL_MMC_WriteBlocks()
914 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks()
915 hmmc->ErrorCode |= errorstate; in HAL_MMC_WriteBlocks()
916 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks()
920 __SDMMC_CMDTRANS_DISABLE(hmmc->Instance); in HAL_MMC_WriteBlocks()
923 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DATAEND) && (NumberOfBlocks > 1U)) in HAL_MMC_WriteBlocks()
926 errorstate = SDMMC_CmdStopTransfer(hmmc->Instance); in HAL_MMC_WriteBlocks()
930 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks()
931 hmmc->ErrorCode |= errorstate; in HAL_MMC_WriteBlocks()
932 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks()
938 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DTIMEOUT)) in HAL_MMC_WriteBlocks()
941 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks()
942 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_TIMEOUT; in HAL_MMC_WriteBlocks()
943 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks()
946 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DCRCFAIL)) in HAL_MMC_WriteBlocks()
949 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks()
950 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_CRC_FAIL; in HAL_MMC_WriteBlocks()
951 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks()
954 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_TXUNDERR)) in HAL_MMC_WriteBlocks()
957 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks()
958 hmmc->ErrorCode |= HAL_MMC_ERROR_TX_UNDERRUN; in HAL_MMC_WriteBlocks()
959 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks()
968 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_WriteBlocks()
970 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks()
976 hmmc->ErrorCode |= HAL_MMC_ERROR_BUSY; in HAL_MMC_WriteBlocks()
994 HAL_StatusTypeDef HAL_MMC_ReadBlocks_IT(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, in HAL_MMC_ReadBlocks_IT() argument
1003 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_ReadBlocks_IT()
1007 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_ReadBlocks_IT()
1009 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_ReadBlocks_IT()
1011 if ((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_ReadBlocks_IT()
1013 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_ReadBlocks_IT()
1018 …if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) & 0x0… in HAL_MMC_ReadBlocks_IT()
1023 hmmc->ErrorCode |= HAL_MMC_ERROR_BLOCK_LEN_ERR; in HAL_MMC_ReadBlocks_IT()
1030 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_ReadBlocks_IT()
1035 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_ReadBlocks_IT()
1038 hmmc->Instance->DCTRL = 0U; in HAL_MMC_ReadBlocks_IT()
1040 hmmc->pRxBuffPtr = pData; in HAL_MMC_ReadBlocks_IT()
1041 hmmc->RxXferSize = MMC_BLOCKSIZE * NumberOfBlocks; in HAL_MMC_ReadBlocks_IT()
1043 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_ReadBlocks_IT()
1055 (void)SDMMC_ConfigData(hmmc->Instance, &config); in HAL_MMC_ReadBlocks_IT()
1056 __SDMMC_CMDTRANS_ENABLE(hmmc->Instance); in HAL_MMC_ReadBlocks_IT()
1061 hmmc->Context = (MMC_CONTEXT_READ_MULTIPLE_BLOCK | MMC_CONTEXT_IT); in HAL_MMC_ReadBlocks_IT()
1064 errorstate = SDMMC_CmdReadMultiBlock(hmmc->Instance, add); in HAL_MMC_ReadBlocks_IT()
1068 hmmc->Context = (MMC_CONTEXT_READ_SINGLE_BLOCK | MMC_CONTEXT_IT); in HAL_MMC_ReadBlocks_IT()
1071 errorstate = SDMMC_CmdReadSingleBlock(hmmc->Instance, add); in HAL_MMC_ReadBlocks_IT()
1077 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks_IT()
1078 hmmc->ErrorCode |= errorstate; in HAL_MMC_ReadBlocks_IT()
1079 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks_IT()
1083 …__HAL_MMC_ENABLE_IT(hmmc, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_RXOVERR | SDMMC_IT_DAT… in HAL_MMC_ReadBlocks_IT()
1107 HAL_StatusTypeDef HAL_MMC_WriteBlocks_IT(MMC_HandleTypeDef *hmmc, const uint8_t *pData, in HAL_MMC_WriteBlocks_IT() argument
1116 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_WriteBlocks_IT()
1120 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_WriteBlocks_IT()
1122 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_WriteBlocks_IT()
1124 if ((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_WriteBlocks_IT()
1126 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_WriteBlocks_IT()
1131 …if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) & 0x0… in HAL_MMC_WriteBlocks_IT()
1136 hmmc->ErrorCode |= HAL_MMC_ERROR_BLOCK_LEN_ERR; in HAL_MMC_WriteBlocks_IT()
1143 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_WriteBlocks_IT()
1148 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_WriteBlocks_IT()
1151 hmmc->Instance->DCTRL = 0U; in HAL_MMC_WriteBlocks_IT()
1153 hmmc->pTxBuffPtr = pData; in HAL_MMC_WriteBlocks_IT()
1154 hmmc->TxXferSize = MMC_BLOCKSIZE * NumberOfBlocks; in HAL_MMC_WriteBlocks_IT()
1156 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_WriteBlocks_IT()
1168 (void)SDMMC_ConfigData(hmmc->Instance, &config); in HAL_MMC_WriteBlocks_IT()
1170 __SDMMC_CMDTRANS_ENABLE(hmmc->Instance); in HAL_MMC_WriteBlocks_IT()
1175 hmmc->Context = (MMC_CONTEXT_WRITE_MULTIPLE_BLOCK | MMC_CONTEXT_IT); in HAL_MMC_WriteBlocks_IT()
1178 errorstate = SDMMC_CmdWriteMultiBlock(hmmc->Instance, add); in HAL_MMC_WriteBlocks_IT()
1182 hmmc->Context = (MMC_CONTEXT_WRITE_SINGLE_BLOCK | MMC_CONTEXT_IT); in HAL_MMC_WriteBlocks_IT()
1185 errorstate = SDMMC_CmdWriteSingleBlock(hmmc->Instance, add); in HAL_MMC_WriteBlocks_IT()
1190 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks_IT()
1191 hmmc->ErrorCode |= errorstate; in HAL_MMC_WriteBlocks_IT()
1192 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks_IT()
1197 …__HAL_MMC_ENABLE_IT(hmmc, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_TXUNDERR | SDMMC_IT_DA… in HAL_MMC_WriteBlocks_IT()
1221 HAL_StatusTypeDef HAL_MMC_ReadBlocks_DMA(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, in HAL_MMC_ReadBlocks_DMA() argument
1230 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_ReadBlocks_DMA()
1234 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_ReadBlocks_DMA()
1236 hmmc->ErrorCode = HAL_DMA_ERROR_NONE; in HAL_MMC_ReadBlocks_DMA()
1238 if ((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_ReadBlocks_DMA()
1240 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_ReadBlocks_DMA()
1245 …if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) & 0x0… in HAL_MMC_ReadBlocks_DMA()
1250 hmmc->ErrorCode |= HAL_MMC_ERROR_BLOCK_LEN_ERR; in HAL_MMC_ReadBlocks_DMA()
1257 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_ReadBlocks_DMA()
1262 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_ReadBlocks_DMA()
1265 hmmc->Instance->DCTRL = 0U; in HAL_MMC_ReadBlocks_DMA()
1267 hmmc->pRxBuffPtr = pData; in HAL_MMC_ReadBlocks_DMA()
1268 hmmc->RxXferSize = MMC_BLOCKSIZE * NumberOfBlocks; in HAL_MMC_ReadBlocks_DMA()
1270 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_ReadBlocks_DMA()
1282 (void)SDMMC_ConfigData(hmmc->Instance, &config); in HAL_MMC_ReadBlocks_DMA()
1284 __SDMMC_CMDTRANS_ENABLE(hmmc->Instance); in HAL_MMC_ReadBlocks_DMA()
1285 hmmc->Instance->IDMABASER = (uint32_t) pData ; in HAL_MMC_ReadBlocks_DMA()
1286 hmmc->Instance->IDMACTRL = SDMMC_ENABLE_IDMA_SINGLE_BUFF; in HAL_MMC_ReadBlocks_DMA()
1291 hmmc->Context = (MMC_CONTEXT_READ_MULTIPLE_BLOCK | MMC_CONTEXT_DMA); in HAL_MMC_ReadBlocks_DMA()
1294 errorstate = SDMMC_CmdReadMultiBlock(hmmc->Instance, add); in HAL_MMC_ReadBlocks_DMA()
1298 hmmc->Context = (MMC_CONTEXT_READ_SINGLE_BLOCK | MMC_CONTEXT_DMA); in HAL_MMC_ReadBlocks_DMA()
1301 errorstate = SDMMC_CmdReadSingleBlock(hmmc->Instance, add); in HAL_MMC_ReadBlocks_DMA()
1306 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ReadBlocks_DMA()
1307 hmmc->ErrorCode = errorstate; in HAL_MMC_ReadBlocks_DMA()
1308 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ReadBlocks_DMA()
1313 …__HAL_MMC_ENABLE_IT(hmmc, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_RXOVERR | SDMMC_IT_DAT… in HAL_MMC_ReadBlocks_DMA()
1336 HAL_StatusTypeDef HAL_MMC_WriteBlocks_DMA(MMC_HandleTypeDef *hmmc, const uint8_t *pData, in HAL_MMC_WriteBlocks_DMA() argument
1345 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_WriteBlocks_DMA()
1349 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_WriteBlocks_DMA()
1351 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_WriteBlocks_DMA()
1353 if ((BlockAdd + NumberOfBlocks) > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_WriteBlocks_DMA()
1355 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_WriteBlocks_DMA()
1360 …if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) & 0x0… in HAL_MMC_WriteBlocks_DMA()
1365 hmmc->ErrorCode |= HAL_MMC_ERROR_BLOCK_LEN_ERR; in HAL_MMC_WriteBlocks_DMA()
1372 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_WriteBlocks_DMA()
1377 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_WriteBlocks_DMA()
1380 hmmc->Instance->DCTRL = 0U; in HAL_MMC_WriteBlocks_DMA()
1382 hmmc->pTxBuffPtr = pData; in HAL_MMC_WriteBlocks_DMA()
1383 hmmc->TxXferSize = MMC_BLOCKSIZE * NumberOfBlocks; in HAL_MMC_WriteBlocks_DMA()
1385 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_WriteBlocks_DMA()
1397 (void)SDMMC_ConfigData(hmmc->Instance, &config); in HAL_MMC_WriteBlocks_DMA()
1399 __SDMMC_CMDTRANS_ENABLE(hmmc->Instance); in HAL_MMC_WriteBlocks_DMA()
1401 hmmc->Instance->IDMABASER = (uint32_t) pData ; in HAL_MMC_WriteBlocks_DMA()
1402 hmmc->Instance->IDMACTRL = SDMMC_ENABLE_IDMA_SINGLE_BUFF; in HAL_MMC_WriteBlocks_DMA()
1407 hmmc->Context = (MMC_CONTEXT_WRITE_MULTIPLE_BLOCK | MMC_CONTEXT_DMA); in HAL_MMC_WriteBlocks_DMA()
1410 errorstate = SDMMC_CmdWriteMultiBlock(hmmc->Instance, add); in HAL_MMC_WriteBlocks_DMA()
1414 hmmc->Context = (MMC_CONTEXT_WRITE_SINGLE_BLOCK | MMC_CONTEXT_DMA); in HAL_MMC_WriteBlocks_DMA()
1417 errorstate = SDMMC_CmdWriteSingleBlock(hmmc->Instance, add); in HAL_MMC_WriteBlocks_DMA()
1422 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_WriteBlocks_DMA()
1423 hmmc->ErrorCode |= errorstate; in HAL_MMC_WriteBlocks_DMA()
1424 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_WriteBlocks_DMA()
1429 …__HAL_MMC_ENABLE_IT(hmmc, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_TXUNDERR | SDMMC_IT_DA… in HAL_MMC_WriteBlocks_DMA()
1448 HAL_StatusTypeDef HAL_MMC_Erase(MMC_HandleTypeDef *hmmc, uint32_t BlockStartAdd, uint32_t BlockEndA… in HAL_MMC_Erase() argument
1454 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_Erase()
1456 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_Erase()
1460 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_Erase()
1464 if (end_add > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_Erase()
1466 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_Erase()
1471 if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) in HAL_MMC_Erase()
1477 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_Erase()
1482 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_Erase()
1485 if (((hmmc->MmcCard.Class) & SDMMC_CCCC_ERASE) == 0U) in HAL_MMC_Erase()
1488 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_Erase()
1489 hmmc->ErrorCode |= HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE; in HAL_MMC_Erase()
1490 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Erase()
1494 if ((SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1) & SDMMC_CARD_LOCKED) == SDMMC_CARD_LOCKED) in HAL_MMC_Erase()
1497 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_Erase()
1498 hmmc->ErrorCode |= HAL_MMC_ERROR_LOCK_UNLOCK_FAILED; in HAL_MMC_Erase()
1499 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Erase()
1503 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_Erase()
1510 errorstate = SDMMC_CmdEraseStartAdd(hmmc->Instance, start_add); in HAL_MMC_Erase()
1514 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_Erase()
1515 hmmc->ErrorCode |= errorstate; in HAL_MMC_Erase()
1516 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Erase()
1521 errorstate = SDMMC_CmdEraseEndAdd(hmmc->Instance, end_add); in HAL_MMC_Erase()
1525 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_Erase()
1526 hmmc->ErrorCode |= errorstate; in HAL_MMC_Erase()
1527 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Erase()
1532 errorstate = SDMMC_CmdErase(hmmc->Instance, 0UL); in HAL_MMC_Erase()
1536 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_Erase()
1537 hmmc->ErrorCode |= errorstate; in HAL_MMC_Erase()
1538 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Erase()
1542 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Erase()
1557 void HAL_MMC_IRQHandler(MMC_HandleTypeDef *hmmc) in HAL_MMC_IRQHandler() argument
1560 uint32_t context = hmmc->Context; in HAL_MMC_IRQHandler()
1563 …if ((__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXFIFOHF) != RESET) && ((context & MMC_CONTEXT_IT) != 0U)) in HAL_MMC_IRQHandler()
1565 MMC_Read_IT(hmmc); in HAL_MMC_IRQHandler()
1568 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DATAEND) != RESET) in HAL_MMC_IRQHandler()
1570 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_DATAEND); in HAL_MMC_IRQHandler()
1572 __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_DATAEND | SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | \ in HAL_MMC_IRQHandler()
1576 __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_IDMABTC); in HAL_MMC_IRQHandler()
1577 __SDMMC_CMDTRANS_DISABLE(hmmc->Instance); in HAL_MMC_IRQHandler()
1581 hmmc->Instance->DLEN = 0; in HAL_MMC_IRQHandler()
1582 hmmc->Instance->DCTRL = 0; in HAL_MMC_IRQHandler()
1583 hmmc->Instance->IDMACTRL = SDMMC_DISABLE_IDMA ; in HAL_MMC_IRQHandler()
1588 errorstate = SDMMC_CmdStopTransfer(hmmc->Instance); in HAL_MMC_IRQHandler()
1591 hmmc->ErrorCode |= errorstate; in HAL_MMC_IRQHandler()
1593 hmmc->ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1595 HAL_MMC_ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1601 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_IRQHandler()
1603 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_IRQHandler()
1607 hmmc->TxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1609 HAL_MMC_TxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1615 hmmc->RxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1617 HAL_MMC_RxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1626 errorstate = SDMMC_CmdStopTransfer(hmmc->Instance); in HAL_MMC_IRQHandler()
1629 hmmc->ErrorCode |= errorstate; in HAL_MMC_IRQHandler()
1631 hmmc->ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1633 HAL_MMC_ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1639 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_IRQHandler()
1641 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_IRQHandler()
1645 hmmc->RxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1647 HAL_MMC_RxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1653 hmmc->TxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1655 HAL_MMC_TxCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1665 …else if ((__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_TXFIFOHE) != RESET) && ((context & MMC_CONTEXT_IT) !… in HAL_MMC_IRQHandler()
1667 MMC_Write_IT(hmmc); in HAL_MMC_IRQHandler()
1670 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DCRCFAIL | in HAL_MMC_IRQHandler()
1674 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_IT_DCRCFAIL) != RESET) in HAL_MMC_IRQHandler()
1676 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_CRC_FAIL; in HAL_MMC_IRQHandler()
1678 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_IT_DTIMEOUT) != RESET) in HAL_MMC_IRQHandler()
1680 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_TIMEOUT; in HAL_MMC_IRQHandler()
1682 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_IT_RXOVERR) != RESET) in HAL_MMC_IRQHandler()
1684 hmmc->ErrorCode |= HAL_MMC_ERROR_RX_OVERRUN; in HAL_MMC_IRQHandler()
1686 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_IT_TXUNDERR) != RESET) in HAL_MMC_IRQHandler()
1688 hmmc->ErrorCode |= HAL_MMC_ERROR_TX_UNDERRUN; in HAL_MMC_IRQHandler()
1692 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_IRQHandler()
1695 __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_DATAEND | SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | \ in HAL_MMC_IRQHandler()
1698 __SDMMC_CMDTRANS_DISABLE(hmmc->Instance); in HAL_MMC_IRQHandler()
1699 hmmc->Instance->DCTRL |= SDMMC_DCTRL_FIFORST; in HAL_MMC_IRQHandler()
1700 hmmc->Instance->CMD |= SDMMC_CMD_CMDSTOP; in HAL_MMC_IRQHandler()
1701 hmmc->ErrorCode |= SDMMC_CmdStopTransfer(hmmc->Instance); in HAL_MMC_IRQHandler()
1702 hmmc->Instance->CMD &= ~(SDMMC_CMD_CMDSTOP); in HAL_MMC_IRQHandler()
1703 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_DABORT); in HAL_MMC_IRQHandler()
1708 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_IRQHandler()
1710 hmmc->ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1712 HAL_MMC_ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1717 if (hmmc->ErrorCode != HAL_MMC_ERROR_NONE) in HAL_MMC_IRQHandler()
1720 __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_IDMABTC); in HAL_MMC_IRQHandler()
1721 hmmc->Instance->IDMACTRL = SDMMC_DISABLE_IDMA; in HAL_MMC_IRQHandler()
1724 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_IRQHandler()
1726 hmmc->ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1728 HAL_MMC_ErrorCallback(hmmc); in HAL_MMC_IRQHandler()
1738 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_IDMABTC) != RESET) in HAL_MMC_IRQHandler()
1740 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_IT_IDMABTC); in HAL_MMC_IRQHandler()
1745 hmmc->Write_DMALnkLstBufCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1747 HAL_MMCEx_Write_DMALnkLstBufCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1753 hmmc->Read_DMALnkLstBufCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1755 HAL_MMCEx_Read_DMALnkLstBufCpltCallback(hmmc); in HAL_MMC_IRQHandler()
1771 HAL_MMC_StateTypeDef HAL_MMC_GetState(const MMC_HandleTypeDef *hmmc) in HAL_MMC_GetState() argument
1773 return hmmc->State; in HAL_MMC_GetState()
1782 uint32_t HAL_MMC_GetError(const MMC_HandleTypeDef *hmmc) in HAL_MMC_GetError() argument
1784 return hmmc->ErrorCode; in HAL_MMC_GetError()
1792 __weak void HAL_MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc) in HAL_MMC_TxCpltCallback() argument
1795 UNUSED(hmmc); in HAL_MMC_TxCpltCallback()
1807 __weak void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc) in HAL_MMC_RxCpltCallback() argument
1810 UNUSED(hmmc); in HAL_MMC_RxCpltCallback()
1822 __weak void HAL_MMC_ErrorCallback(MMC_HandleTypeDef *hmmc) in HAL_MMC_ErrorCallback() argument
1825 UNUSED(hmmc); in HAL_MMC_ErrorCallback()
1837 __weak void HAL_MMC_AbortCallback(MMC_HandleTypeDef *hmmc) in HAL_MMC_AbortCallback() argument
1840 UNUSED(hmmc); in HAL_MMC_AbortCallback()
1868 HAL_StatusTypeDef HAL_MMC_RegisterCallback(MMC_HandleTypeDef *hmmc, HAL_MMC_CallbackIDTypeDef Callb… in HAL_MMC_RegisterCallback() argument
1876 hmmc->ErrorCode |= HAL_MMC_ERROR_INVALID_CALLBACK; in HAL_MMC_RegisterCallback()
1880 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_RegisterCallback()
1885 hmmc->TxCpltCallback = pCallback; in HAL_MMC_RegisterCallback()
1888 hmmc->RxCpltCallback = pCallback; in HAL_MMC_RegisterCallback()
1891 hmmc->ErrorCallback = pCallback; in HAL_MMC_RegisterCallback()
1894 hmmc->AbortCpltCallback = pCallback; in HAL_MMC_RegisterCallback()
1897 hmmc->Read_DMALnkLstBufCpltCallback = pCallback; in HAL_MMC_RegisterCallback()
1900 hmmc->Write_DMALnkLstBufCpltCallback = pCallback; in HAL_MMC_RegisterCallback()
1903 hmmc->MspInitCallback = pCallback; in HAL_MMC_RegisterCallback()
1906 hmmc->MspDeInitCallback = pCallback; in HAL_MMC_RegisterCallback()
1910 hmmc->ErrorCode |= HAL_MMC_ERROR_INVALID_CALLBACK; in HAL_MMC_RegisterCallback()
1916 else if (hmmc->State == HAL_MMC_STATE_RESET) in HAL_MMC_RegisterCallback()
1921 hmmc->MspInitCallback = pCallback; in HAL_MMC_RegisterCallback()
1924 hmmc->MspDeInitCallback = pCallback; in HAL_MMC_RegisterCallback()
1928 hmmc->ErrorCode |= HAL_MMC_ERROR_INVALID_CALLBACK; in HAL_MMC_RegisterCallback()
1937 hmmc->ErrorCode |= HAL_MMC_ERROR_INVALID_CALLBACK; in HAL_MMC_RegisterCallback()
1964 HAL_StatusTypeDef HAL_MMC_UnRegisterCallback(MMC_HandleTypeDef *hmmc, HAL_MMC_CallbackIDTypeDef Cal… in HAL_MMC_UnRegisterCallback() argument
1968 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_UnRegisterCallback()
1973 hmmc->TxCpltCallback = HAL_MMC_TxCpltCallback; in HAL_MMC_UnRegisterCallback()
1976 hmmc->RxCpltCallback = HAL_MMC_RxCpltCallback; in HAL_MMC_UnRegisterCallback()
1979 hmmc->ErrorCallback = HAL_MMC_ErrorCallback; in HAL_MMC_UnRegisterCallback()
1982 hmmc->AbortCpltCallback = HAL_MMC_AbortCallback; in HAL_MMC_UnRegisterCallback()
1985 hmmc->Read_DMALnkLstBufCpltCallback = HAL_MMCEx_Read_DMALnkLstBufCpltCallback; in HAL_MMC_UnRegisterCallback()
1988 hmmc->Write_DMALnkLstBufCpltCallback = HAL_MMCEx_Write_DMALnkLstBufCpltCallback; in HAL_MMC_UnRegisterCallback()
1991 hmmc->MspInitCallback = HAL_MMC_MspInit; in HAL_MMC_UnRegisterCallback()
1994 hmmc->MspDeInitCallback = HAL_MMC_MspDeInit; in HAL_MMC_UnRegisterCallback()
1998 hmmc->ErrorCode |= HAL_MMC_ERROR_INVALID_CALLBACK; in HAL_MMC_UnRegisterCallback()
2004 else if (hmmc->State == HAL_MMC_STATE_RESET) in HAL_MMC_UnRegisterCallback()
2009 hmmc->MspInitCallback = HAL_MMC_MspInit; in HAL_MMC_UnRegisterCallback()
2012 hmmc->MspDeInitCallback = HAL_MMC_MspDeInit; in HAL_MMC_UnRegisterCallback()
2016 hmmc->ErrorCode |= HAL_MMC_ERROR_INVALID_CALLBACK; in HAL_MMC_UnRegisterCallback()
2025 hmmc->ErrorCode |= HAL_MMC_ERROR_INVALID_CALLBACK; in HAL_MMC_UnRegisterCallback()
2061 HAL_StatusTypeDef HAL_MMC_GetCardCID(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCIDTypeDef *pCID) in HAL_MMC_GetCardCID() argument
2063 pCID->ManufacturerID = (uint8_t)((hmmc->CID[0] & 0xFF000000U) >> 24U); in HAL_MMC_GetCardCID()
2065 pCID->OEM_AppliID = (uint16_t)((hmmc->CID[0] & 0x00FFFF00U) >> 8U); in HAL_MMC_GetCardCID()
2067 pCID->ProdName1 = (((hmmc->CID[0] & 0x000000FFU) << 24U) | ((hmmc->CID[1] & 0xFFFFFF00U) >> 8U)); in HAL_MMC_GetCardCID()
2069 pCID->ProdName2 = (uint8_t)(hmmc->CID[1] & 0x000000FFU); in HAL_MMC_GetCardCID()
2071 pCID->ProdRev = (uint8_t)((hmmc->CID[2] & 0xFF000000U) >> 24U); in HAL_MMC_GetCardCID()
2073 pCID->ProdSN = (((hmmc->CID[2] & 0x00FFFFFFU) << 8U) | ((hmmc->CID[3] & 0xFF000000U) >> 24U)); in HAL_MMC_GetCardCID()
2075 pCID->Reserved1 = (uint8_t)((hmmc->CID[3] & 0x00F00000U) >> 20U); in HAL_MMC_GetCardCID()
2077 pCID->ManufactDate = (uint16_t)((hmmc->CID[3] & 0x000FFF00U) >> 8U); in HAL_MMC_GetCardCID()
2079 pCID->CID_CRC = (uint8_t)((hmmc->CID[3] & 0x000000FEU) >> 1U); in HAL_MMC_GetCardCID()
2094 HAL_StatusTypeDef HAL_MMC_GetCardCSD(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCSDTypeDef *pCSD) in HAL_MMC_GetCardCSD() argument
2098 pCSD->CSDStruct = (uint8_t)((hmmc->CSD[0] & 0xC0000000U) >> 30U); in HAL_MMC_GetCardCSD()
2100 pCSD->SysSpecVersion = (uint8_t)((hmmc->CSD[0] & 0x3C000000U) >> 26U); in HAL_MMC_GetCardCSD()
2102 pCSD->Reserved1 = (uint8_t)((hmmc->CSD[0] & 0x03000000U) >> 24U); in HAL_MMC_GetCardCSD()
2104 pCSD->TAAC = (uint8_t)((hmmc->CSD[0] & 0x00FF0000U) >> 16U); in HAL_MMC_GetCardCSD()
2106 pCSD->NSAC = (uint8_t)((hmmc->CSD[0] & 0x0000FF00U) >> 8U); in HAL_MMC_GetCardCSD()
2108 pCSD->MaxBusClkFrec = (uint8_t)(hmmc->CSD[0] & 0x000000FFU); in HAL_MMC_GetCardCSD()
2110 pCSD->CardComdClasses = (uint16_t)((hmmc->CSD[1] & 0xFFF00000U) >> 20U); in HAL_MMC_GetCardCSD()
2112 pCSD->RdBlockLen = (uint8_t)((hmmc->CSD[1] & 0x000F0000U) >> 16U); in HAL_MMC_GetCardCSD()
2114 pCSD->PartBlockRead = (uint8_t)((hmmc->CSD[1] & 0x00008000U) >> 15U); in HAL_MMC_GetCardCSD()
2116 pCSD->WrBlockMisalign = (uint8_t)((hmmc->CSD[1] & 0x00004000U) >> 14U); in HAL_MMC_GetCardCSD()
2118 pCSD->RdBlockMisalign = (uint8_t)((hmmc->CSD[1] & 0x00002000U) >> 13U); in HAL_MMC_GetCardCSD()
2120 pCSD->DSRImpl = (uint8_t)((hmmc->CSD[1] & 0x00001000U) >> 12U); in HAL_MMC_GetCardCSD()
2124 if (MMC_ReadExtCSD(hmmc, &block_nbr, 212, 0x0FFFFFFFU) != HAL_OK) /* Field SEC_COUNT [215:212] */ in HAL_MMC_GetCardCSD()
2129 if (hmmc->MmcCard.CardType == MMC_LOW_CAPACITY_CARD) in HAL_MMC_GetCardCSD()
2131 … pCSD->DeviceSize = (((hmmc->CSD[1] & 0x000003FFU) << 2U) | ((hmmc->CSD[2] & 0xC0000000U) >> 30U)); in HAL_MMC_GetCardCSD()
2133 pCSD->MaxRdCurrentVDDMin = (uint8_t)((hmmc->CSD[2] & 0x38000000U) >> 27U); in HAL_MMC_GetCardCSD()
2135 pCSD->MaxRdCurrentVDDMax = (uint8_t)((hmmc->CSD[2] & 0x07000000U) >> 24U); in HAL_MMC_GetCardCSD()
2137 pCSD->MaxWrCurrentVDDMin = (uint8_t)((hmmc->CSD[2] & 0x00E00000U) >> 21U); in HAL_MMC_GetCardCSD()
2139 pCSD->MaxWrCurrentVDDMax = (uint8_t)((hmmc->CSD[2] & 0x001C0000U) >> 18U); in HAL_MMC_GetCardCSD()
2141 pCSD->DeviceSizeMul = (uint8_t)((hmmc->CSD[2] & 0x00038000U) >> 15U); in HAL_MMC_GetCardCSD()
2143 hmmc->MmcCard.BlockNbr = (pCSD->DeviceSize + 1U) ; in HAL_MMC_GetCardCSD()
2144 hmmc->MmcCard.BlockNbr *= (1UL << ((pCSD->DeviceSizeMul & 0x07U) + 2U)); in HAL_MMC_GetCardCSD()
2145 hmmc->MmcCard.BlockSize = (1UL << (pCSD->RdBlockLen & 0x0FU)); in HAL_MMC_GetCardCSD()
2147 …hmmc->MmcCard.LogBlockNbr = (hmmc->MmcCard.BlockNbr) * ((hmmc->MmcCard.BlockSize) / MMC_BLOCKSIZE); in HAL_MMC_GetCardCSD()
2148 hmmc->MmcCard.LogBlockSize = MMC_BLOCKSIZE; in HAL_MMC_GetCardCSD()
2150 else if (hmmc->MmcCard.CardType == MMC_HIGH_CAPACITY_CARD) in HAL_MMC_GetCardCSD()
2152 hmmc->MmcCard.BlockNbr = block_nbr; in HAL_MMC_GetCardCSD()
2153 hmmc->MmcCard.LogBlockNbr = hmmc->MmcCard.BlockNbr; in HAL_MMC_GetCardCSD()
2154 hmmc->MmcCard.BlockSize = MMC_BLOCKSIZE; in HAL_MMC_GetCardCSD()
2155 hmmc->MmcCard.LogBlockSize = hmmc->MmcCard.BlockSize; in HAL_MMC_GetCardCSD()
2160 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_GetCardCSD()
2161 hmmc->ErrorCode |= HAL_MMC_ERROR_UNSUPPORTED_FEATURE; in HAL_MMC_GetCardCSD()
2162 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetCardCSD()
2166 pCSD->EraseGrSize = (uint8_t)((hmmc->CSD[2] & 0x00004000U) >> 14U); in HAL_MMC_GetCardCSD()
2168 pCSD->EraseGrMul = (uint8_t)((hmmc->CSD[2] & 0x00003F80U) >> 7U); in HAL_MMC_GetCardCSD()
2170 pCSD->WrProtectGrSize = (uint8_t)(hmmc->CSD[2] & 0x0000007FU); in HAL_MMC_GetCardCSD()
2172 pCSD->WrProtectGrEnable = (uint8_t)((hmmc->CSD[3] & 0x80000000U) >> 31U); in HAL_MMC_GetCardCSD()
2174 pCSD->ManDeflECC = (uint8_t)((hmmc->CSD[3] & 0x60000000U) >> 29U); in HAL_MMC_GetCardCSD()
2176 pCSD->WrSpeedFact = (uint8_t)((hmmc->CSD[3] & 0x1C000000U) >> 26U); in HAL_MMC_GetCardCSD()
2178 pCSD->MaxWrBlockLen = (uint8_t)((hmmc->CSD[3] & 0x03C00000U) >> 22U); in HAL_MMC_GetCardCSD()
2180 pCSD->WriteBlockPaPartial = (uint8_t)((hmmc->CSD[3] & 0x00200000U) >> 21U); in HAL_MMC_GetCardCSD()
2184 pCSD->ContentProtectAppli = (uint8_t)((hmmc->CSD[3] & 0x00010000U) >> 16U); in HAL_MMC_GetCardCSD()
2186 pCSD->FileFormatGroup = (uint8_t)((hmmc->CSD[3] & 0x00008000U) >> 15U); in HAL_MMC_GetCardCSD()
2188 pCSD->CopyFlag = (uint8_t)((hmmc->CSD[3] & 0x00004000U) >> 14U); in HAL_MMC_GetCardCSD()
2190 pCSD->PermWrProtect = (uint8_t)((hmmc->CSD[3] & 0x00002000U) >> 13U); in HAL_MMC_GetCardCSD()
2192 pCSD->TempWrProtect = (uint8_t)((hmmc->CSD[3] & 0x00001000U) >> 12U); in HAL_MMC_GetCardCSD()
2194 pCSD->FileFormat = (uint8_t)((hmmc->CSD[3] & 0x00000C00U) >> 10U); in HAL_MMC_GetCardCSD()
2196 pCSD->ECC = (uint8_t)((hmmc->CSD[3] & 0x00000300U) >> 8U); in HAL_MMC_GetCardCSD()
2198 pCSD->CSD_CRC = (uint8_t)((hmmc->CSD[3] & 0x000000FEU) >> 1U); in HAL_MMC_GetCardCSD()
2212 HAL_StatusTypeDef HAL_MMC_GetCardInfo(MMC_HandleTypeDef *hmmc, HAL_MMC_CardInfoTypeDef *pCardInfo) in HAL_MMC_GetCardInfo() argument
2214 pCardInfo->CardType = (uint32_t)(hmmc->MmcCard.CardType); in HAL_MMC_GetCardInfo()
2215 pCardInfo->Class = (uint32_t)(hmmc->MmcCard.Class); in HAL_MMC_GetCardInfo()
2216 pCardInfo->RelCardAdd = (uint32_t)(hmmc->MmcCard.RelCardAdd); in HAL_MMC_GetCardInfo()
2217 pCardInfo->BlockNbr = (uint32_t)(hmmc->MmcCard.BlockNbr); in HAL_MMC_GetCardInfo()
2218 pCardInfo->BlockSize = (uint32_t)(hmmc->MmcCard.BlockSize); in HAL_MMC_GetCardInfo()
2219 pCardInfo->LogBlockNbr = (uint32_t)(hmmc->MmcCard.LogBlockNbr); in HAL_MMC_GetCardInfo()
2220 pCardInfo->LogBlockSize = (uint32_t)(hmmc->MmcCard.LogBlockSize); in HAL_MMC_GetCardInfo()
2234 HAL_StatusTypeDef HAL_MMC_GetCardExtCSD(MMC_HandleTypeDef *hmmc, uint32_t *pExtCSD, uint32_t Timeou… in HAL_MMC_GetCardExtCSD() argument
2244 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_GetCardExtCSD()
2248 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_GetCardExtCSD()
2250 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in HAL_MMC_GetCardExtCSD()
2252 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_GetCardExtCSD()
2255 hmmc->Instance->DCTRL = 0; in HAL_MMC_GetCardExtCSD()
2267 (void)SDMMC_ConfigData(hmmc->Instance, &config); in HAL_MMC_GetCardExtCSD()
2268 __SDMMC_CMDTRANS_ENABLE(hmmc->Instance); in HAL_MMC_GetCardExtCSD()
2271 errorstate = SDMMC_CmdSendEXTCSD(hmmc->Instance, 0); in HAL_MMC_GetCardExtCSD()
2275 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_GetCardExtCSD()
2276 hmmc->ErrorCode |= errorstate; in HAL_MMC_GetCardExtCSD()
2277 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetCardExtCSD()
2282 while (!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXOVERR | in HAL_MMC_GetCardExtCSD()
2285 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXFIFOHF)) in HAL_MMC_GetCardExtCSD()
2290 *tmp_buf = SDMMC_ReadFIFO(hmmc->Instance); in HAL_MMC_GetCardExtCSD()
2298 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_GetCardExtCSD()
2299 hmmc->ErrorCode |= HAL_MMC_ERROR_TIMEOUT; in HAL_MMC_GetCardExtCSD()
2300 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetCardExtCSD()
2305 __SDMMC_CMDTRANS_DISABLE(hmmc->Instance); in HAL_MMC_GetCardExtCSD()
2308 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DTIMEOUT)) in HAL_MMC_GetCardExtCSD()
2311 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_GetCardExtCSD()
2312 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_TIMEOUT; in HAL_MMC_GetCardExtCSD()
2313 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetCardExtCSD()
2316 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DCRCFAIL)) in HAL_MMC_GetCardExtCSD()
2319 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_GetCardExtCSD()
2320 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_CRC_FAIL; in HAL_MMC_GetCardExtCSD()
2321 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetCardExtCSD()
2324 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXOVERR)) in HAL_MMC_GetCardExtCSD()
2327 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_GetCardExtCSD()
2328 hmmc->ErrorCode |= HAL_MMC_ERROR_RX_OVERRUN; in HAL_MMC_GetCardExtCSD()
2329 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetCardExtCSD()
2338 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_GetCardExtCSD()
2339 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetCardExtCSD()
2356 HAL_StatusTypeDef HAL_MMC_ConfigWideBusOperation(MMC_HandleTypeDef *hmmc, uint32_t WideMode) in HAL_MMC_ConfigWideBusOperation() argument
2367 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_ConfigWideBusOperation()
2370 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_BUSSPEED) != 0U) in HAL_MMC_ConfigWideBusOperation()
2372 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_DDR) != 0U) in HAL_MMC_ConfigWideBusOperation()
2374 errorstate = MMC_PwrClassUpdate(hmmc, WideMode, SDMMC_SPEED_MODE_DDR); in HAL_MMC_ConfigWideBusOperation()
2378 errorstate = MMC_PwrClassUpdate(hmmc, WideMode, SDMMC_SPEED_MODE_HIGH); in HAL_MMC_ConfigWideBusOperation()
2383 errorstate = MMC_PwrClassUpdate(hmmc, WideMode, SDMMC_SPEED_MODE_DEFAULT); in HAL_MMC_ConfigWideBusOperation()
2390 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70200U); in HAL_MMC_ConfigWideBusOperation()
2394 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70100U); in HAL_MMC_ConfigWideBusOperation()
2398 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70000U); in HAL_MMC_ConfigWideBusOperation()
2413 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in HAL_MMC_ConfigWideBusOperation()
2420 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in HAL_MMC_ConfigWideBusOperation()
2435 Init = hmmc->Init; in HAL_MMC_ConfigWideBusOperation()
2437 (void)SDMMC_Init(hmmc->Instance, Init); in HAL_MMC_ConfigWideBusOperation()
2452 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ConfigWideBusOperation()
2457 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ConfigWideBusOperation()
2458 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigWideBusOperation()
2477 HAL_StatusTypeDef HAL_MMC_ConfigSpeedBusOperation(MMC_HandleTypeDef *hmmc, uint32_t SpeedMode) in HAL_MMC_ConfigSpeedBusOperation() argument
2488 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_ConfigSpeedBusOperation()
2491 device_type = (hmmc->Ext_CSD[49] & 0x000000FFU); in HAL_MMC_ConfigSpeedBusOperation()
2497 if (((hmmc->Instance->CLKCR & SDMMC_CLKCR_WIDBUS) != 0U) && ((device_type & 0x04U) != 0U)) in HAL_MMC_ConfigSpeedBusOperation()
2500 errorstate = MMC_HighSpeed(hmmc, ENABLE); in HAL_MMC_ConfigSpeedBusOperation()
2503 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2507 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_CLKDIV) != 0U) in HAL_MMC_ConfigSpeedBusOperation()
2510 errorstate = MMC_DDR_Mode(hmmc, ENABLE); in HAL_MMC_ConfigSpeedBusOperation()
2513 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2521 errorstate = MMC_HighSpeed(hmmc, ENABLE); in HAL_MMC_ConfigSpeedBusOperation()
2524 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2535 if (((hmmc->Instance->CLKCR & SDMMC_CLKCR_WIDBUS) != 0U) && ((device_type & 0x04U) != 0U)) in HAL_MMC_ConfigSpeedBusOperation()
2538 errorstate = MMC_HighSpeed(hmmc, ENABLE); in HAL_MMC_ConfigSpeedBusOperation()
2541 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2545 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_CLKDIV) != 0U) in HAL_MMC_ConfigSpeedBusOperation()
2548 errorstate = MMC_DDR_Mode(hmmc, ENABLE); in HAL_MMC_ConfigSpeedBusOperation()
2551 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2559 hmmc->ErrorCode |= HAL_MMC_ERROR_UNSUPPORTED_FEATURE; in HAL_MMC_ConfigSpeedBusOperation()
2569 errorstate = MMC_HighSpeed(hmmc, ENABLE); in HAL_MMC_ConfigSpeedBusOperation()
2572 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2578 hmmc->ErrorCode |= HAL_MMC_ERROR_UNSUPPORTED_FEATURE; in HAL_MMC_ConfigSpeedBusOperation()
2585 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_DDR) != 0U) in HAL_MMC_ConfigSpeedBusOperation()
2588 errorstate = MMC_DDR_Mode(hmmc, DISABLE); in HAL_MMC_ConfigSpeedBusOperation()
2591 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2594 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_BUSSPEED) != 0U) in HAL_MMC_ConfigSpeedBusOperation()
2597 errorstate = MMC_HighSpeed(hmmc, DISABLE); in HAL_MMC_ConfigSpeedBusOperation()
2600 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSpeedBusOperation()
2606 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_ConfigSpeedBusOperation()
2613 while ((HAL_MMC_GetCardState(hmmc) != HAL_MMC_CARD_TRANSFER)) in HAL_MMC_ConfigSpeedBusOperation()
2617 hmmc->ErrorCode = HAL_MMC_ERROR_TIMEOUT; in HAL_MMC_ConfigSpeedBusOperation()
2618 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ConfigSpeedBusOperation()
2624 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ConfigSpeedBusOperation()
2633 HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState(MMC_HandleTypeDef *hmmc) in HAL_MMC_GetCardState() argument
2639 errorstate = MMC_SendStatus(hmmc, &resp1); in HAL_MMC_GetCardState()
2642 hmmc->ErrorCode |= errorstate; in HAL_MMC_GetCardState()
2656 HAL_StatusTypeDef HAL_MMC_Abort(MMC_HandleTypeDef *hmmc) in HAL_MMC_Abort() argument
2661 if (hmmc->State == HAL_MMC_STATE_BUSY) in HAL_MMC_Abort()
2664 __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_DATAEND | SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | \ in HAL_MMC_Abort()
2666 __SDMMC_CMDTRANS_DISABLE(hmmc->Instance); in HAL_MMC_Abort()
2674 hmmc->ErrorCode = SDMMC_CmdStopTransfer(hmmc->Instance); in HAL_MMC_Abort()
2675 error_code = hmmc->ErrorCode; in HAL_MMC_Abort()
2682 if ((hmmc->Instance->DCTRL & SDMMC_DCTRL_DTDIR) == SDMMC_TRANSFER_DIR_TO_CARD) in HAL_MMC_Abort()
2684 if (hmmc->ErrorCode == HAL_MMC_ERROR_NONE) in HAL_MMC_Abort()
2686 while (!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DABORT | SDMMC_FLAG_BUSYD0END)) in HAL_MMC_Abort()
2690 hmmc->ErrorCode = HAL_MMC_ERROR_TIMEOUT; in HAL_MMC_Abort()
2691 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Abort()
2697 if (hmmc->ErrorCode == HAL_MMC_ERROR_CMD_RSP_TIMEOUT) in HAL_MMC_Abort()
2699 while (!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DATAEND)) in HAL_MMC_Abort()
2703 hmmc->ErrorCode = HAL_MMC_ERROR_TIMEOUT; in HAL_MMC_Abort()
2704 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Abort()
2710 else if ((hmmc->Instance->DCTRL & SDMMC_DCTRL_DTDIR) == SDMMC_TRANSFER_DIR_TO_SDMMC) in HAL_MMC_Abort()
2712 while (!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DABORT | SDMMC_FLAG_DATAEND)) in HAL_MMC_Abort()
2716 hmmc->ErrorCode = HAL_MMC_ERROR_TIMEOUT; in HAL_MMC_Abort()
2717 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Abort()
2733 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_BUSYD0END); in HAL_MMC_Abort()
2734 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_Abort()
2736 hmmc->Instance->IDMACTRL = SDMMC_DISABLE_IDMA; in HAL_MMC_Abort()
2738 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Abort()
2741 hmmc->Context = MMC_CONTEXT_NONE; in HAL_MMC_Abort()
2751 HAL_StatusTypeDef HAL_MMC_Abort_IT(MMC_HandleTypeDef *hmmc) in HAL_MMC_Abort_IT() argument
2756 __HAL_MMC_DISABLE_IT(hmmc, SDMMC_IT_DATAEND | SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | \ in HAL_MMC_Abort_IT()
2760 hmmc->Instance->IDMACTRL = SDMMC_DISABLE_IDMA; in HAL_MMC_Abort_IT()
2763 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in HAL_MMC_Abort_IT()
2765 CardState = HAL_MMC_GetCardState(hmmc); in HAL_MMC_Abort_IT()
2766 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Abort_IT()
2770 hmmc->ErrorCode = SDMMC_CmdStopTransfer(hmmc->Instance); in HAL_MMC_Abort_IT()
2772 if (hmmc->ErrorCode != HAL_MMC_ERROR_NONE) in HAL_MMC_Abort_IT()
2779 hmmc->AbortCpltCallback(hmmc); in HAL_MMC_Abort_IT()
2781 HAL_MMC_AbortCallback(hmmc); in HAL_MMC_Abort_IT()
2807 HAL_StatusTypeDef HAL_MMC_EraseSequence(MMC_HandleTypeDef *hmmc, uint32_t EraseType, in HAL_MMC_EraseSequence() argument
2821 hmmc->ErrorCode |= HAL_MMC_ERROR_PARAM; in HAL_MMC_EraseSequence()
2826 if (end_add > (hmmc->MmcCard.LogBlockNbr)) in HAL_MMC_EraseSequence()
2828 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_OUT_OF_RANGE; in HAL_MMC_EraseSequence()
2833 …if (((hmmc->Ext_CSD[(MMC_EXT_CSD_DATA_SEC_SIZE_INDEX / 4)] >> MMC_EXT_CSD_DATA_SEC_SIZE_POS) & 0x0… in HAL_MMC_EraseSequence()
2838 hmmc->ErrorCode |= HAL_MMC_ERROR_ADDR_MISALIGNED; in HAL_MMC_EraseSequence()
2844 if (((hmmc->MmcCard.Class) & SDMMC_CCCC_ERASE) == 0U) in HAL_MMC_EraseSequence()
2846 hmmc->ErrorCode |= HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE; in HAL_MMC_EraseSequence()
2851 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_EraseSequence()
2854 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_EraseSequence()
2857 if ((SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1) & SDMMC_CARD_LOCKED) == SDMMC_CARD_LOCKED) in HAL_MMC_EraseSequence()
2859 hmmc->ErrorCode |= HAL_MMC_ERROR_LOCK_UNLOCK_FAILED; in HAL_MMC_EraseSequence()
2860 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_EraseSequence()
2865 if ((hmmc->MmcCard.CardType) != MMC_HIGH_CAPACITY_CARD) in HAL_MMC_EraseSequence()
2872 errorstate = SDMMC_CmdEraseStartAdd(hmmc->Instance, start_add); in HAL_MMC_EraseSequence()
2876 errorstate = SDMMC_CmdEraseEndAdd(hmmc->Instance, end_add); in HAL_MMC_EraseSequence()
2880 errorstate = SDMMC_CmdErase(hmmc->Instance, EraseType); in HAL_MMC_EraseSequence()
2886 … while ((!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_BUSYD0END)) && (errorstate == HAL_MMC_ERROR_NONE)) in HAL_MMC_EraseSequence()
2895 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_BUSYD0END); in HAL_MMC_EraseSequence()
2902 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_EraseSequence()
2908 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_EraseSequence()
2909 hmmc->ErrorCode |= errorstate; in HAL_MMC_EraseSequence()
2938 HAL_StatusTypeDef HAL_MMC_Sanitize(MMC_HandleTypeDef *hmmc) in HAL_MMC_Sanitize() argument
2946 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_Sanitize()
2949 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_Sanitize()
2952 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03A50100U); in HAL_MMC_Sanitize()
2956 … while ((!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_BUSYD0END)) && (errorstate == HAL_MMC_ERROR_NONE)) in HAL_MMC_Sanitize()
2965 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_BUSYD0END); in HAL_MMC_Sanitize()
2973 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in HAL_MMC_Sanitize()
2980 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in HAL_MMC_Sanitize()
3005 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_Sanitize()
3011 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_Sanitize()
3012 hmmc->ErrorCode |= errorstate; in HAL_MMC_Sanitize()
3049 HAL_StatusTypeDef HAL_MMC_ConfigSecRemovalType(MMC_HandleTypeDef *hmmc, uint32_t SRTMode) in HAL_MMC_ConfigSecRemovalType() argument
3060 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_ConfigSecRemovalType()
3063 if (HAL_MMC_GetSupportedSecRemovalType(hmmc, &srt) == HAL_OK) in HAL_MMC_ConfigSecRemovalType()
3066 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_ConfigSecRemovalType()
3073 errorstate = SDMMC_CmdSwitch(hmmc->Instance, (0x03100000U | (srt << 8U))); in HAL_MMC_ConfigSecRemovalType()
3080 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in HAL_MMC_ConfigSecRemovalType()
3087 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in HAL_MMC_ConfigSecRemovalType()
3116 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_ConfigSecRemovalType()
3127 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_ConfigSecRemovalType()
3128 hmmc->ErrorCode |= errorstate; in HAL_MMC_ConfigSecRemovalType()
3155 HAL_StatusTypeDef HAL_MMC_GetSupportedSecRemovalType(MMC_HandleTypeDef *hmmc, uint32_t *SupportedSR… in HAL_MMC_GetSupportedSecRemovalType() argument
3158 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_GetSupportedSecRemovalType()
3161 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_GetSupportedSecRemovalType()
3164 *SupportedSRT = (hmmc->Ext_CSD[4] & 0x0000000FU); /* Bits [3:0] of field 16 */ in HAL_MMC_GetSupportedSecRemovalType()
3167 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_GetSupportedSecRemovalType()
3182 HAL_StatusTypeDef HAL_MMC_SleepDevice(MMC_HandleTypeDef *hmmc) in HAL_MMC_SleepDevice() argument
3192 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_SleepDevice()
3195 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_SleepDevice()
3198 errorstate = SDMMC_CmdSwitch(hmmc->Instance, (0x03220100U)); in HAL_MMC_SleepDevice()
3205 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in HAL_MMC_SleepDevice()
3212 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in HAL_MMC_SleepDevice()
3231 errorstate = SDMMC_CmdSwitch(hmmc->Instance, (0x03220400U)); in HAL_MMC_SleepDevice()
3235 sleep_timeout = ((hmmc->Ext_CSD[(MMC_EXT_CSD_SLEEP_NOTIFICATION_TIME_INDEX / 4)] >> in HAL_MMC_SleepDevice()
3247 … while ((!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_BUSYD0END)) && (errorstate == HAL_MMC_ERROR_NONE)) in HAL_MMC_SleepDevice()
3256 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_BUSYD0END); in HAL_MMC_SleepDevice()
3264 errorstate = SDMMC_CmdSendStatus(hmmc->Instance, in HAL_MMC_SleepDevice()
3265 … (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U)); in HAL_MMC_SleepDevice()
3272 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in HAL_MMC_SleepDevice()
3291 (void)SDMMC_CmdSelDesel(hmmc->Instance, 0U); in HAL_MMC_SleepDevice()
3294 sleep_timeout = ((hmmc->Ext_CSD[(MMC_EXT_CSD_S_A_TIMEOUT_INDEX / 4)] >> in HAL_MMC_SleepDevice()
3305 if (HAL_MMC_GetCardState(hmmc) == HAL_MMC_CARD_STANDBY) in HAL_MMC_SleepDevice()
3308 errorstate = SDMMC_CmdSleepMmc(hmmc->Instance, in HAL_MMC_SleepDevice()
3309 … ((hmmc->MmcCard.RelCardAdd << 16U) | (0x1U << 15U))); in HAL_MMC_SleepDevice()
3313 … while ((!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_BUSYD0END)) && (errorstate == HAL_MMC_ERROR_NONE)) in HAL_MMC_SleepDevice()
3322 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_BUSYD0END); in HAL_MMC_SleepDevice()
3346 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_SleepDevice()
3352 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_SleepDevice()
3353 hmmc->ErrorCode |= errorstate; in HAL_MMC_SleepDevice()
3380 HAL_StatusTypeDef HAL_MMC_AwakeDevice(MMC_HandleTypeDef *hmmc) in HAL_MMC_AwakeDevice() argument
3390 if (hmmc->State == HAL_MMC_STATE_READY) in HAL_MMC_AwakeDevice()
3393 hmmc->State = HAL_MMC_STATE_BUSY; in HAL_MMC_AwakeDevice()
3396 …sleep_timeout = ((hmmc->Ext_CSD[(MMC_EXT_CSD_S_A_TIMEOUT_INDEX / 4)] >> MMC_EXT_CSD_S_A_TIMEOUT_PO… in HAL_MMC_AwakeDevice()
3408 errorstate = SDMMC_CmdSleepMmc(hmmc->Instance, (hmmc->MmcCard.RelCardAdd << 16U)); in HAL_MMC_AwakeDevice()
3412 … while ((!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_BUSYD0END)) && (errorstate == HAL_MMC_ERROR_NONE)) in HAL_MMC_AwakeDevice()
3421 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_FLAG_BUSYD0END); in HAL_MMC_AwakeDevice()
3425 if (HAL_MMC_GetCardState(hmmc) == HAL_MMC_CARD_STANDBY) in HAL_MMC_AwakeDevice()
3428 errorstate = SDMMC_CmdSelDesel(hmmc->Instance, (hmmc->MmcCard.RelCardAdd << 16U)); in HAL_MMC_AwakeDevice()
3431 if (HAL_MMC_GetCardState(hmmc) == HAL_MMC_CARD_TRANSFER) in HAL_MMC_AwakeDevice()
3434 errorstate = SDMMC_CmdSwitch(hmmc->Instance, (0x03220100U)); in HAL_MMC_AwakeDevice()
3441 errorstate = SDMMC_CmdSendStatus(hmmc->Instance, in HAL_MMC_AwakeDevice()
3442 … (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U)); in HAL_MMC_AwakeDevice()
3449 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in HAL_MMC_AwakeDevice()
3486 hmmc->State = HAL_MMC_STATE_READY; in HAL_MMC_AwakeDevice()
3492 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in HAL_MMC_AwakeDevice()
3493 hmmc->ErrorCode |= errorstate; in HAL_MMC_AwakeDevice()
3533 static uint32_t MMC_InitCard(MMC_HandleTypeDef *hmmc) in MMC_InitCard() argument
3541 if (SDMMC_GetPowerState(hmmc->Instance) == 0U) in MMC_InitCard()
3548 errorstate = SDMMC_CmdSendCID(hmmc->Instance); in MMC_InitCard()
3556 hmmc->CID[0U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in MMC_InitCard()
3557 hmmc->CID[1U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP2); in MMC_InitCard()
3558 hmmc->CID[2U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP3); in MMC_InitCard()
3559 hmmc->CID[3U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP4); in MMC_InitCard()
3564 errorstate = SDMMC_CmdSetRelAddMmc(hmmc->Instance, mmc_rca); in MMC_InitCard()
3571 hmmc->MmcCard.RelCardAdd = mmc_rca; in MMC_InitCard()
3574 errorstate = SDMMC_CmdSendCSD(hmmc->Instance, (uint32_t)(hmmc->MmcCard.RelCardAdd << 16U)); in MMC_InitCard()
3582 hmmc->CSD[0U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in MMC_InitCard()
3583 hmmc->CSD[1U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP2); in MMC_InitCard()
3584 hmmc->CSD[2U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP3); in MMC_InitCard()
3585 hmmc->CSD[3U] = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP4); in MMC_InitCard()
3589 hmmc->MmcCard.Class = (SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP2) >> 20U); in MMC_InitCard()
3592 …errorstate = SDMMC_CmdSelDesel(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << … in MMC_InitCard()
3599 if (HAL_MMC_GetCardCSD(hmmc, &CSD) != HAL_OK) in MMC_InitCard()
3601 return hmmc->ErrorCode; in MMC_InitCard()
3605 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in MMC_InitCard()
3608 hmmc->ErrorCode |= errorstate; in MMC_InitCard()
3613 if (HAL_MMC_GetCardExtCSD(hmmc, hmmc->Ext_CSD, SDMMC_DATATIMEOUT) != HAL_OK) in MMC_InitCard()
3615 return hmmc->ErrorCode; in MMC_InitCard()
3619 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in MMC_InitCard()
3622 hmmc->ErrorCode |= errorstate; in MMC_InitCard()
3626 Init = hmmc->Init; in MMC_InitCard()
3628 (void)SDMMC_Init(hmmc->Instance, Init); in MMC_InitCard()
3641 static uint32_t MMC_PowerON(MMC_HandleTypeDef *hmmc) in MMC_PowerON() argument
3649 errorstate = SDMMC_CmdGoIdleState(hmmc->Instance); in MMC_PowerON()
3663 errorstate = SDMMC_CmdOpCondition(hmmc->Instance, MMC_VOLTAGE_RANGE); in MMC_PowerON()
3670 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in MMC_PowerON()
3679 hmmc->MmcCard.CardType = MMC_HIGH_CAPACITY_CARD; in MMC_PowerON()
3683 hmmc->MmcCard.CardType = MMC_LOW_CAPACITY_CARD; in MMC_PowerON()
3694 static void MMC_PowerOFF(MMC_HandleTypeDef *hmmc) in MMC_PowerOFF() argument
3697 (void)SDMMC_PowerState_OFF(hmmc->Instance); in MMC_PowerOFF()
3707 static uint32_t MMC_SendStatus(MMC_HandleTypeDef *hmmc, uint32_t *pCardStatus) in MMC_SendStatus() argument
3717 errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(hmmc->MmcCard.RelCardAdd << 16U)); in MMC_SendStatus()
3724 *pCardStatus = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in MMC_SendStatus()
3737 static HAL_StatusTypeDef MMC_ReadExtCSD(MMC_HandleTypeDef *hmmc, uint32_t *pFieldData, in MMC_ReadExtCSD() argument
3747 hmmc->ErrorCode = HAL_MMC_ERROR_NONE; in MMC_ReadExtCSD()
3750 hmmc->Instance->DCTRL = 0; in MMC_ReadExtCSD()
3759 (void)SDMMC_ConfigData(hmmc->Instance, &config); in MMC_ReadExtCSD()
3762 errorstate = SDMMC_CmdSendEXTCSD(hmmc->Instance, 0); in MMC_ReadExtCSD()
3766 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in MMC_ReadExtCSD()
3767 hmmc->ErrorCode |= errorstate; in MMC_ReadExtCSD()
3768 hmmc->State = HAL_MMC_STATE_READY; in MMC_ReadExtCSD()
3773 while (!__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXOVERR | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT | in MMC_ReadExtCSD()
3776 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXFIFOHF)) in MMC_ReadExtCSD()
3781 tmp_data = SDMMC_ReadFIFO(hmmc->Instance); in MMC_ReadExtCSD()
3795 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in MMC_ReadExtCSD()
3796 hmmc->ErrorCode |= HAL_MMC_ERROR_TIMEOUT; in MMC_ReadExtCSD()
3797 hmmc->State = HAL_MMC_STATE_READY; in MMC_ReadExtCSD()
3803 if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DTIMEOUT)) in MMC_ReadExtCSD()
3806 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in MMC_ReadExtCSD()
3807 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_TIMEOUT; in MMC_ReadExtCSD()
3808 hmmc->State = HAL_MMC_STATE_READY; in MMC_ReadExtCSD()
3811 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_DCRCFAIL)) in MMC_ReadExtCSD()
3814 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in MMC_ReadExtCSD()
3815 hmmc->ErrorCode |= HAL_MMC_ERROR_DATA_CRC_FAIL; in MMC_ReadExtCSD()
3816 hmmc->State = HAL_MMC_STATE_READY; in MMC_ReadExtCSD()
3819 else if (__HAL_MMC_GET_FLAG(hmmc, SDMMC_FLAG_RXOVERR)) in MMC_ReadExtCSD()
3822 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_FLAGS); in MMC_ReadExtCSD()
3823 hmmc->ErrorCode |= HAL_MMC_ERROR_RX_OVERRUN; in MMC_ReadExtCSD()
3824 hmmc->State = HAL_MMC_STATE_READY; in MMC_ReadExtCSD()
3833 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in MMC_ReadExtCSD()
3836 hmmc->ErrorCode |= errorstate; in MMC_ReadExtCSD()
3840 __HAL_MMC_CLEAR_FLAG(hmmc, SDMMC_STATIC_DATA_FLAGS); in MMC_ReadExtCSD()
3842 hmmc->State = HAL_MMC_STATE_READY; in MMC_ReadExtCSD()
3853 static void MMC_Read_IT(MMC_HandleTypeDef *hmmc) in MMC_Read_IT() argument
3859 tmp = hmmc->pRxBuffPtr; in MMC_Read_IT()
3862 if (hmmc->RxXferSize >= SDMMC_FIFO_SIZE) in MMC_Read_IT()
3867 data = SDMMC_ReadFIFO(hmmc->Instance); in MMC_Read_IT()
3878 hmmc->pRxBuffPtr = tmp; in MMC_Read_IT()
3879 hmmc->RxXferSize -= SDMMC_FIFO_SIZE; in MMC_Read_IT()
3889 static void MMC_Write_IT(MMC_HandleTypeDef *hmmc) in MMC_Write_IT() argument
3895 tmp = hmmc->pTxBuffPtr; in MMC_Write_IT()
3897 if (hmmc->TxXferSize >= SDMMC_FIFO_SIZE) in MMC_Write_IT()
3910 (void)SDMMC_WriteFIFO(hmmc->Instance, &data); in MMC_Write_IT()
3913 hmmc->pTxBuffPtr = tmp; in MMC_Write_IT()
3914 hmmc->TxXferSize -= SDMMC_FIFO_SIZE; in MMC_Write_IT()
3924 static uint32_t MMC_HighSpeed(MMC_HandleTypeDef *hmmc, FunctionalState state) in MMC_HighSpeed() argument
3932 if (((hmmc->Instance->CLKCR & SDMMC_CLKCR_BUSSPEED) != 0U) && (state == DISABLE)) in MMC_HighSpeed()
3934 …errorstate = MMC_PwrClassUpdate(hmmc, (hmmc->Instance->CLKCR & SDMMC_CLKCR_WIDBUS), SDMMC_SPEED_MO… in MMC_HighSpeed()
3938 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B90000U); in MMC_HighSpeed()
3942 if (((hmmc->Instance->CLKCR & SDMMC_CLKCR_BUSSPEED) == 0U) && (state != DISABLE)) in MMC_HighSpeed()
3944 …errorstate = MMC_PwrClassUpdate(hmmc, (hmmc->Instance->CLKCR & SDMMC_CLKCR_WIDBUS), SDMMC_SPEED_MO… in MMC_HighSpeed()
3948 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B90100U); in MMC_HighSpeed()
3958 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in MMC_HighSpeed()
3965 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in MMC_HighSpeed()
3980 Init.ClockEdge = hmmc->Init.ClockEdge; in MMC_HighSpeed()
3981 Init.ClockPowerSave = hmmc->Init.ClockPowerSave; in MMC_HighSpeed()
3982 Init.BusWide = (hmmc->Instance->CLKCR & SDMMC_CLKCR_WIDBUS); in MMC_HighSpeed()
3983 Init.HardwareFlowControl = hmmc->Init.HardwareFlowControl; in MMC_HighSpeed()
3987 Init.ClockDiv = hmmc->Init.ClockDiv; in MMC_HighSpeed()
3988 (void)SDMMC_Init(hmmc->Instance, Init); in MMC_HighSpeed()
3990 CLEAR_BIT(hmmc->Instance->CLKCR, SDMMC_CLKCR_BUSSPEED); in MMC_HighSpeed()
4011 (void)SDMMC_Init(hmmc->Instance, Init); in MMC_HighSpeed()
4013 SET_BIT(hmmc->Instance->CLKCR, SDMMC_CLKCR_BUSSPEED); in MMC_HighSpeed()
4037 static uint32_t MMC_DDR_Mode(MMC_HandleTypeDef *hmmc, FunctionalState state) in MMC_DDR_Mode() argument
4043 if (((hmmc->Instance->CLKCR & SDMMC_CLKCR_DDR) != 0U) && (state == DISABLE)) in MMC_DDR_Mode()
4045 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_WIDBUS_0) != 0U) in MMC_DDR_Mode()
4047 errorstate = MMC_PwrClassUpdate(hmmc, SDMMC_BUS_WIDE_4B, SDMMC_SPEED_MODE_HIGH); in MMC_DDR_Mode()
4051 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70100U); in MMC_DDR_Mode()
4056 errorstate = MMC_PwrClassUpdate(hmmc, SDMMC_BUS_WIDE_8B, SDMMC_SPEED_MODE_HIGH); in MMC_DDR_Mode()
4060 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70200U); in MMC_DDR_Mode()
4065 if (((hmmc->Instance->CLKCR & SDMMC_CLKCR_DDR) == 0U) && (state != DISABLE)) in MMC_DDR_Mode()
4067 if ((hmmc->Instance->CLKCR & SDMMC_CLKCR_WIDBUS_0) != 0U) in MMC_DDR_Mode()
4069 errorstate = MMC_PwrClassUpdate(hmmc, SDMMC_BUS_WIDE_4B, SDMMC_SPEED_MODE_DDR); in MMC_DDR_Mode()
4073 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70500U); in MMC_DDR_Mode()
4078 errorstate = MMC_PwrClassUpdate(hmmc, SDMMC_BUS_WIDE_8B, SDMMC_SPEED_MODE_DDR); in MMC_DDR_Mode()
4082 errorstate = SDMMC_CmdSwitch(hmmc->Instance, 0x03B70600U); in MMC_DDR_Mode()
4093 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in MMC_DDR_Mode()
4100 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in MMC_DDR_Mode()
4117 CLEAR_BIT(hmmc->Instance->CLKCR, SDMMC_CLKCR_DDR); in MMC_DDR_Mode()
4121 SET_BIT(hmmc->Instance->CLKCR, SDMMC_CLKCR_DDR); in MMC_DDR_Mode()
4145 static uint32_t MMC_PwrClassUpdate(MMC_HandleTypeDef *hmmc, uint32_t Wide, uint32_t Speed) in MMC_PwrClassUpdate() argument
4158 …if (MMC_ReadExtCSD(hmmc, &power_class, 187, SDMMC_DATATIMEOUT) != HAL_OK) /* Field POWER_CLASS [18… in MMC_PwrClassUpdate()
4171 …supported_pwr_class = ((hmmc->Ext_CSD[(MMC_EXT_CSD_PWR_CL_DDR_52_INDEX / 4)] >> MMC_EXT_CSD_PWR_CL… in MMC_PwrClassUpdate()
4177 …supported_pwr_class = ((hmmc->Ext_CSD[(MMC_EXT_CSD_PWR_CL_52_INDEX / 4)] >> MMC_EXT_CSD_PWR_CL_52_… in MMC_PwrClassUpdate()
4183 …supported_pwr_class = ((hmmc->Ext_CSD[(MMC_EXT_CSD_PWR_CL_26_INDEX / 4)] >> MMC_EXT_CSD_PWR_CL_26_… in MMC_PwrClassUpdate()
4198 …errorstate = SDMMC_CmdSwitch(hmmc->Instance, (0x03BB0000U | ((supported_pwr_class & 0x0FU) << 8U))… in MMC_PwrClassUpdate()
4206 …errorstate = SDMMC_CmdSendStatus(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) <… in MMC_PwrClassUpdate()
4213 response = SDMMC_GetResponse(hmmc->Instance, SDMMC_RESP1); in MMC_PwrClassUpdate()
4247 __weak void HAL_MMCEx_Read_DMALnkLstBufCpltCallback(MMC_HandleTypeDef *hmmc) in HAL_MMCEx_Read_DMALnkLstBufCpltCallback() argument
4250 UNUSED(hmmc); in HAL_MMCEx_Read_DMALnkLstBufCpltCallback()
4261 __weak void HAL_MMCEx_Write_DMALnkLstBufCpltCallback(MMC_HandleTypeDef *hmmc) in HAL_MMCEx_Write_DMALnkLstBufCpltCallback() argument
4264 UNUSED(hmmc); in HAL_MMCEx_Write_DMALnkLstBufCpltCallback()