ch_sdmmc_reledge.c 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "hal.h"
  2. #if (HAL_USE_SDMMC == TRUE)
  3. #include "sama_sdmmc_lld.h"
  4. #include "ch_sdmmc_device.h"
  5. #include "ch_sdmmc_cmds.h"
  6. #include "ch_sdmmc_sdio.h"
  7. #include "ch_sdmmc_sd.h"
  8. #include "ch_sdmmc_mmc.h"
  9. #include "ch_sdmmc_reledge.h"
  10. eSDMMC_RC sd_mmc_test_unit_ready( SdmmcDriver *sdmmcp)
  11. {
  12. uint32_t rc;
  13. if (sdmmc_is_busy(sdmmcp))
  14. return SDMMC_BUSY;
  15. rc = SD_GetStatus(sdmmcp);
  16. if (rc != SDMMC_OK)
  17. {
  18. return rc;
  19. }
  20. if ( !(sdmmcp->card.bCardType == CARD_UNKNOWN) ) {
  21. return SDMMC_OK;
  22. }
  23. // It is not a memory card
  24. return SDMMC_ERR;
  25. }
  26. bool sd_mmc_is_write_protected(SdmmcDriver *sdmmcp)
  27. {
  28. uint32_t rc;
  29. rc = SD_GetWpStatus(sdmmcp);
  30. return (rc == SDMMC_LOCKED);
  31. }
  32. eSDMMC_RC sd_mmc_read_capacity(SdmmcDriver *sdmmcp, uint32_t *nb_sector)
  33. {
  34. // Return last sector address (-1)
  35. *nb_sector = sdmmcp->card.dwNbBlocks - 1;
  36. return sd_mmc_test_unit_ready(sdmmcp);
  37. }
  38. #endif