aboutsummaryrefslogtreecommitdiffstats
path: root/os/io
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-10 22:30:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-10 22:30:11 +0000
commit9bc4122e0e4b5e91d97ea19083dc944c1d2dc0d0 (patch)
tree66e8ec6d30fc2ae72b011ed34fb314179ffae169 /os/io
parent176444320c3c32bd35180ffcdbbda7be0cfd23bc (diff)
downloadChibiOS-9bc4122e0e4b5e91d97ea19083dc944c1d2dc0d0.tar.gz
ChibiOS-9bc4122e0e4b5e91d97ea19083dc944c1d2dc0d0.tar.bz2
ChibiOS-9bc4122e0e4b5e91d97ea19083dc944c1d2dc0d0.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1282 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/io')
-rw-r--r--os/io/mmc_spi.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/os/io/mmc_spi.c b/os/io/mmc_spi.c
index 42100bb61..4e9d6e3f5 100644
--- a/os/io/mmc_spi.c
+++ b/os/io/mmc_spi.c
@@ -395,4 +395,96 @@ bool_t mmcStopSequentialRead(MMCDriver *mmcp) {
return result;
}
+/**
+ * @brief Starts a sequential write.
+ *
+ * @param[in] mmcp pointer to the @p MMCDriver object
+ * @param[in] startblk first block to write
+ *
+ * @return The operation status.
+ * @retval FALSE the operation was successful.
+ * @retval TRUE the operation failed.
+ */
+bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk) {
+
+ chDbgCheck(mmcp != NULL, "mmcStartSequentialWrite");
+
+ chSysLock();
+ if (mmcp->mmc_state != MMC_READY) {
+ chSysUnlock();
+ return TRUE;
+ }
+ mmcp->mmc_state = MMC_WRITING;
+ chSysUnlock();
+
+ spiSelect(mmcp->mmc_spip);
+ send_hdr(mmcp, MMC_CMDWRITEMULTIPLE, startblk << 9);
+ if (recvr1(mmcp) != 0x00) {
+ spiUnselect(mmcp->mmc_spip);
+ chSysLock();
+ if (mmcp->mmc_state == MMC_READING)
+ mmcp->mmc_state = MMC_READY;
+ chSysUnlock();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * @brief Writes a block within a sequential write operation.
+ *
+ * @param[in] mmcp pointer to the @p MMCDriver object
+ * @param[out] buffer pointer to the write buffer
+ *
+ * @return The operation status.
+ * @retval FALSE the operation was successful.
+ * @retval TRUE the operation failed.
+ */
+bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {
+
+ chDbgCheck((mmcp != NULL) && (buffer != NULL), "mmcSequentialRead");
+
+ chSysLock();
+ if (mmcp->mmc_state != MMC_WRITING) {
+ chSysUnlock();
+ return TRUE;
+ }
+ chSysUnlock();
+
+ /**/
+
+ return TRUE;
+}
+
+/**
+ * @brief Stops a sequential write gracefully.
+ *
+ * @param[in] mmcp pointer to the @p MMCDriver object
+ *
+ * @return The operation status.
+ * @retval FALSE the operation was successful.
+ * @retval TRUE the operation failed.
+ */
+bool_t mmcStopSequentialWrite(MMCDriver *mmcp) {
+ static const uint8_t stop[] = {0xFD, 0xFF};
+
+ chDbgCheck(mmcp != NULL, "mmcStopSequentialWrite");
+
+ chSysLock();
+ if (mmcp->mmc_state != MMC_WRITING) {
+ chSysUnlock();
+ return TRUE;
+ }
+ chSysUnlock();
+
+ spiSend(mmcp->mmc_spip, sizeof(stop), stop);
+ spiUnselect(mmcp->mmc_spip);
+
+ chSysLock();
+ if (mmcp->mmc_state == MMC_WRITING)
+ mmcp->mmc_state = MMC_READY;
+ chSysUnlock();
+ return TRUE;
+}
+
/** @} */