aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_sd.c')
-rw-r--r--os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_sd.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_sd.c b/os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_sd.c
index a27d0b819..ed2286bbc 100644
--- a/os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_sd.c
+++ b/os/hal/ports/SAMA/LLD/SDMMCv1/ch_sdmmc_sd.c
@@ -479,6 +479,29 @@ void SdParamReset(sSdCard * pSd)
memset(pSd->SCR, 0, SCR_SIZE);
}
+/**
+ * Query whether the card is writeprotected or not by mechanical
+ write protect switch.
+ * \param pSd Pointer to \ref sSdCard instance.
+ * \return an \ref sdmmc_rc "error code", as follows:
+ * - SDMMC_LOCKED if the device has been mechanical write protected.
+ * - SDMMC_OK if the card is not write-protected.
+ */
+uint8_t SD_GetWpStatus(SdmmcDriver *driver)
+{
+ uint32_t rc;
+
+ driver->control_param = 0;
+
+ rc = sdmmc_device_control(driver,SDMMC_IOCTL_GET_WP);
+
+ if (rc != SDMMC_OK)
+ return SDMMC_NOT_SUPPORTED;
+ if (!driver->control_param)
+ return SDMMC_LOCKED;
+ else
+ return SDMMC_OK;
+}
/**