/** * @brief Returns information about specific card. * @param cardinfo: pointer to a SD_CardInfo structure that contains all SD * card information. * @retval The SD Response: * - SD_RESPONSE_FAILURE: Sequence failed * - SD_RESPONSE_NO_ERROR: Sequence succeed */ SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo) { static uint32_t i = 0; SD_Error status = SD_RESPONSE_FAILURE; status = SD_GetCSDRegister(&(cardinfo->SD_csd)); if(SD_RESPONSE_FAILURE == status) { status = SD_GetCSDRegister(&(cardinfo->SD_csd)); } status = SD_GetCIDRegister(&(cardinfo->SD_cid)); cardinfo->CardCapacity = (cardinfo->SD_csd.DeviceSize + 1) ; cardinfo->CardCapacity *= (1 << (cardinfo->SD_csd.DeviceSizeMul + 2)); cardinfo->CardBlockSize = 1 << (cardinfo->SD_csd.RdBlockLen); cardinfo->CardCapacity *= cardinfo->CardBlockSize; // if(i == 1) // { // printf("\n\r SD CardBlockSize %d CardCapacity %d M", cardinfo->CardBlockSize, // cardinfo->CardCapacity / 1024 / 1024); // } i++; /*!< Returns the reponse */ return status; }
/** * @brief Returns information about specific card. * @param cardinfo: pointer to a SD_CardInfo structure that contains all SD * card information. * @retval The SD Response: * - SD_RESPONSE_FAILURE: Sequence failed * - SD_RESPONSE_NO_ERROR: Sequence succeed */ SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo) { SD_Error status = SD_RESPONSE_FAILURE; status = SD_GetCSDRegister(&(cardinfo->SD_csd)); status = SD_GetCIDRegister(&(cardinfo->SD_cid)); cardinfo->CardCapacity = (cardinfo->SD_csd.DeviceSize + 1) ; cardinfo->CardCapacity *= (1 << (cardinfo->SD_csd.DeviceSizeMul + 2)); cardinfo->CardBlockSize = 1 << (cardinfo->SD_csd.RdBlockLen); cardinfo->CardCapacity *= cardinfo->CardBlockSize; /*!< Returns the reponse */ return status; }
/** * @brief Returns information about specific card. * @param cardinfo: pointer to a SD_CardInfo structure that contains all SD * card information. * @retval The SD Response: * - MSD_ERROR : Sequence failed * - MSD_OK : Sequence succeed */ uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo) { uint8_t status = MSD_ERROR; SD_GetCSDRegister(&(pCardInfo->Csd)); status = SD_GetCIDRegister(&(pCardInfo->Cid)); pCardInfo->CardCapacity = (pCardInfo->Csd.DeviceSize + 1) ; pCardInfo->CardCapacity *= (1 << (pCardInfo->Csd.DeviceSizeMul + 2)); pCardInfo->CardBlockSize = 1 << (pCardInfo->Csd.RdBlockLen); pCardInfo->CardCapacity *= pCardInfo->CardBlockSize; /* Returns the reponse */ return status; }
/** * @brief Returns information about specific card. * @param pCardInfo: Pointer to a SD_CardInfo structure that contains all SD * card information. * @retval The SD Response: * - MSD_ERROR: Sequence failed * - MSD_OK: Sequence succeed */ uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo) { uint8_t status = MSD_ERROR; SD_GetCSDRegister(&(pCardInfo->Csd)); status = SD_GetCIDRegister(&(pCardInfo->Cid)); pCardInfo->CardCapacity = (pCardInfo->Csd.DeviceSize + 1) ; pCardInfo->CardCapacity *= (1 << (pCardInfo->Csd.DeviceSizeMul + 2)); pCardInfo->CardBlockSize = 1 << (pCardInfo->Csd.RdBlockLen); pCardInfo->CardCapacity *= pCardInfo->CardBlockSize; /* Returns the response */ if (status == SD_RESPONSE_NO_ERROR) { return MSD_OK; } else { return MSD_ERROR; } }