diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-04-16 18:19:34 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-04-16 18:19:34 +0000 |
commit | 973d8da5eabeead58445937e5be4c740ffaf2c56 (patch) | |
tree | e9c863024f826aa2f0da691dcde604f472678e94 /os/hal | |
parent | 04da61495794ed3e22381cdead5a8f1919b512a2 (diff) | |
download | ChibiOS-973d8da5eabeead58445937e5be4c740ffaf2c56.tar.gz ChibiOS-973d8da5eabeead58445937e5be4c740ffaf2c56.tar.bz2 ChibiOS-973d8da5eabeead58445937e5be4c740ffaf2c56.zip |
SDC. Added function sdcGetAndClearErrors.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/sdc_dev2@4099 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/include/sdc.h | 1 | ||||
-rw-r--r-- | os/hal/platforms/STM32/sdc_lld.c | 13 | ||||
-rw-r--r-- | os/hal/platforms/STM32/sdc_lld.h | 9 | ||||
-rw-r--r-- | os/hal/src/sdc.c | 15 |
4 files changed, 36 insertions, 2 deletions
diff --git a/os/hal/include/sdc.h b/os/hal/include/sdc.h index 9be833dd3..83f16d111 100644 --- a/os/hal/include/sdc.h +++ b/os/hal/include/sdc.h @@ -337,6 +337,7 @@ extern "C" { uint8_t *buffer, uint32_t n);
bool_t sdcWrite(SDCDriver *sdcp, uint32_t startblk,
const uint8_t *buffer, uint32_t n);
+ sdcflags_t sdcGetAndClearErrors(SDCDriver *sdcp);
bool_t _sdc_wait_for_transfer_state(SDCDriver *sdcp);
#ifdef __cplusplus
}
diff --git a/os/hal/platforms/STM32/sdc_lld.c b/os/hal/platforms/STM32/sdc_lld.c index c42867ffe..0c535e2dc 100644 --- a/os/hal/platforms/STM32/sdc_lld.c +++ b/os/hal/platforms/STM32/sdc_lld.c @@ -755,6 +755,19 @@ bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk, return sdc_lld_write_aligned(sdcp, startblk, buf, n);
}
+/**
+ * @brief Get errors from SDC driver and clear error field.
+ *
+ * @param[in] sdcp pointer to the @p SDCDriver object
+ *
+ * @notapi
+ */
+sdcflags_t sdc_lld_get_and_clear_errors(SDCDriver *sdcp) {
+ sdcflags_t flags = sdcp->errors;
+ sdcp->errors = SDC_NO_ERROR;
+ return flags;
+}
+
#endif /* HAL_USE_SDC */
/** @} */
diff --git a/os/hal/platforms/STM32/sdc_lld.h b/os/hal/platforms/STM32/sdc_lld.h index 51db5b2aa..000100396 100644 --- a/os/hal/platforms/STM32/sdc_lld.h +++ b/os/hal/platforms/STM32/sdc_lld.h @@ -119,7 +119,6 @@ #endif
-
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -139,6 +138,11 @@ typedef enum { typedef uint32_t sdcmode_t;
/**
+ * @brief SDC Driver condition flags type.
+ */
+typedef uint32_t sdcflags_t;
+
+/**
* @brief Type of a structure representing an SDC driver.
*/
typedef struct SDCDriver SDCDriver;
@@ -170,7 +174,7 @@ struct SDCDriver { /**
* @brief Errors flags.
*/
- uint32_t errors;
+ sdcflags_t errors;
/**
* @brief Card CID.
*/
@@ -242,6 +246,7 @@ extern "C" { uint8_t *buf, uint32_t n);
bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
const uint8_t *buf, uint32_t n);
+ sdcflags_t sdc_lld_get_and_clear_errors(SDCDriver *sdcp);
bool_t sdc_lld_is_card_inserted(SDCDriver *sdcp);
bool_t sdc_lld_is_write_protected(SDCDriver *sdcp);
#ifdef __cplusplus
diff --git a/os/hal/src/sdc.c b/os/hal/src/sdc.c index 6cb6dbe06..10baa38e8 100644 --- a/os/hal/src/sdc.c +++ b/os/hal/src/sdc.c @@ -465,6 +465,21 @@ bool_t sdcWrite(SDCDriver *sdcp, uint32_t startblk, return status;
}
+/**
+ * @brief Returns the errors mask associated to the previous operation.
+ *
+ * @param[in] sdcp pointer to the @p SDCDriver object
+ * @return The errors mask.
+ *
+ * @api
+ */
+sdcflags_t sdcGetAndClearErrors(SDCDriver *sdcp) {
+
+ chDbgCheck(sdcp != NULL, "sdcGetAndClearErrors");
+
+ return sdc_lld_get_and_clear_errors(sdcp);
+}
+
#endif /* HAL_USE_SDC */
/** @} */
|