You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/12/18 21:56:58 UTC
[30/50] incubator-mynewt-core git commit: Add extra doc + errors
messages
Add extra doc + errors messages
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fe4416f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fe4416f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fe4416f9
Branch: refs/heads/sensors_branch
Commit: fe4416f962f97ee1c3ff8bf40cf2207a08c2e096
Parents: 646945e
Author: Fabio Utzig <ut...@utzig.org>
Authored: Fri Dec 9 09:10:24 2016 -0200
Committer: Sterling Hughes <st...@apache.org>
Committed: Sun Dec 18 13:56:16 2016 -0800
----------------------------------------------------------------------
hw/drivers/mmc/include/mmc/mmc.h | 39 +++++++++++++++++++----------------
hw/drivers/mmc/src/mmc.c | 22 +++++++++++---------
2 files changed, 33 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fe4416f9/hw/drivers/mmc/include/mmc/mmc.h
----------------------------------------------------------------------
diff --git a/hw/drivers/mmc/include/mmc/mmc.h b/hw/drivers/mmc/include/mmc/mmc.h
index 9dbf35e..d65363d 100644
--- a/hw/drivers/mmc/include/mmc/mmc.h
+++ b/hw/drivers/mmc/include/mmc/mmc.h
@@ -29,16 +29,19 @@ extern "C" {
/**
* MMC driver errors.
*/
-#define MMC_OK (0)
-#define MMC_CARD_ERROR (-1) /* Is there a card installed? */
-#define MMC_READ_ERROR (-2)
-#define MMC_WRITE_ERROR (-3)
-#define MMC_TIMEOUT (-4)
-#define MMC_PARAM_ERROR (-5)
-#define MMC_CRC_ERROR (-6)
-#define MMC_DEVICE_ERROR (-7)
-#define MMC_RESPONSE_ERROR (-8)
-#define MMC_VOLTAGE_ERROR (-9)
+#define MMC_OK (0)
+#define MMC_CARD_ERROR (-1) /* Is there a card installed? */
+#define MMC_READ_ERROR (-2)
+#define MMC_WRITE_ERROR (-3)
+#define MMC_TIMEOUT (-4)
+#define MMC_PARAM_ERROR (-5)
+#define MMC_CRC_ERROR (-6)
+#define MMC_DEVICE_ERROR (-7)
+#define MMC_RESPONSE_ERROR (-8)
+#define MMC_VOLTAGE_ERROR (-9)
+#define MMC_INVALID_COMMAND (-10)
+#define MMC_ERASE_ERROR (-11)
+#define MMC_ADDR_ERROR (-12)
/**
* Initialize the MMC driver
@@ -55,10 +58,10 @@ mmc_init(int spi_num, void *spi_cfg, int ss_pin);
/**
* Read data from MMC
*
- * @param mmc_id
- * @param addr
- * @param buf
- * @param len
+ * @param mmc_id Id of the MMC device (currently must be 0)
+ * @param addr Disk address (in bytes) to be read from
+ * @param buf Buffer where data should be copied to
+ * @param len Amount of data to read/copy
*
* @return 0 on success, non-zero on failure
*/
@@ -68,10 +71,10 @@ mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, size_t len);
/**
* Write data to the MMC
*
- * @param mmc_id
- * @param addr
- * @param buf
- * @param len
+ * @param mmc_id Id of the MMC device (currently must be 0)
+ * @param addr Disk address (in bytes) to be written to
+ * @param buf Buffer where data should be copied from
+ * @param len Amount of data to copy/write
*
* @return 0 on success, non-zero on failure
*/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fe4416f9/hw/drivers/mmc/src/mmc.c
----------------------------------------------------------------------
diff --git a/hw/drivers/mmc/src/mmc.c b/hw/drivers/mmc/src/mmc.c
index 653e08f..6c5dcbe 100644
--- a/hw/drivers/mmc/src/mmc.c
+++ b/hw/drivers/mmc/src/mmc.c
@@ -86,27 +86,29 @@ static struct mmc_cfg {
static int
error_by_response(uint8_t status)
{
+ int rc = MMC_CARD_ERROR;
+
if (status == 0) {
- return MMC_OK;
+ rc = MMC_OK;
} else if (status == 0xff) {
- return MMC_CARD_ERROR;
+ rc = MMC_CARD_ERROR;
} else if (status & R_IDLE) {
- return MMC_TIMEOUT;
+ rc = MMC_TIMEOUT;
} else if (status & R_ERASE_RESET) {
- /* TODO */
+ rc = MMC_ERASE_ERROR;
} else if (status & R_ILLEGAL_COMMAND) {
- /* TODO */
+ rc = MMC_INVALID_COMMAND;
} else if (status & R_CRC_ERROR) {
- return MMC_CRC_ERROR;
+ rc = MMC_CRC_ERROR;
} else if (status & R_ERASE_ERROR) {
- /* TODO */
+ rc = MMC_ERASE_ERROR;
} else if (status & R_ADDR_ERROR) {
- /* TODO */
+ rc = MMC_ADDR_ERROR;
} else if (status & R_PARAM_ERROR) {
- return MMC_PARAM_ERROR;
+ rc = MMC_PARAM_ERROR;
}
- return MMC_CARD_ERROR;
+ return (rc);
}
static struct mmc_cfg *