aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/dac.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-06-30 10:23:41 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-06-30 10:23:41 +0000
commit0dc43f5c2431d4221d819f58134c1da896a29a99 (patch)
tree65967fe4c312f1990b74b019f450606660314106 /os/hal/src/dac.c
parente01bc962c70d4bd88af3a8605736601ef7af68f9 (diff)
downloadChibiOS-0dc43f5c2431d4221d819f58134c1da896a29a99.tar.gz
ChibiOS-0dc43f5c2431d4221d819f58134c1da896a29a99.tar.bz2
ChibiOS-0dc43f5c2431d4221d819f58134c1da896a29a99.zip
DAC merge and rework, part 2.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5912 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/dac.c')
-rw-r--r--os/hal/src/dac.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/os/hal/src/dac.c b/os/hal/src/dac.c
index b4a659791..a4cb5aa10 100644
--- a/os/hal/src/dac.c
+++ b/os/hal/src/dac.c
@@ -196,6 +196,60 @@ void dacStartConversionI(DACDriver *dacp,
dac_lld_start_conversion(dacp);
}
+/**
+ * @brief Stops an ongoing conversion.
+ * @details This function stops the currently ongoing conversion and returns
+ * the driver in the @p DAC_READY state. If there was no conversion
+ * being processed then the function does nothing.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object
+ *
+ * @api
+ */
+void dacStopConversion(DACDriver *dacp) {
+
+ chDbgCheck(dacp != NULL, "dacStopConversion");
+
+ chSysLock();
+ chDbgAssert((dacp->state == DAC_READY) ||
+ (dacp->state == DAC_ACTIVE),
+ "dacStopConversion(), #1", "invalid state");
+ if (dacp->state != DAC_READY) {
+ adc_lld_stop_conversion(dacp);
+ dacp->grpp = NULL;
+ dacp->state = DAC_READY;
+ _dac_reset_s(dacp);
+ }
+ chSysUnlock();
+}
+
+/**
+ * @brief Stops an ongoing conversion.
+ * @details This function stops the currently ongoing conversion and returns
+ * the driver in the @p DAC_READY state. If there was no conversion
+ * being processed then the function does nothing.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object
+ *
+ * @iclass
+ */
+void dacStopConversionI(DACDriver *dacp) {
+
+ chDbgCheckClassI();
+ chDbgCheck(dacp != NULL, "dacStopConversionI");
+ chDbgAssert((dacp->state == DAC_READY) ||
+ (dacp->state == DAC_ACTIVE) ||
+ (dacp->state == DAC_COMPLETE),
+ "dacStopConversionI(), #1", "invalid state");
+
+ if (dacp->state != DAC_READY) {
+ adc_lld_stop_conversion(dacp);
+ dacp->grpp = NULL;
+ dacp->state = DAC_READY;
+ _dac_reset_i(dacp);
+ }
+}
+
#if DAC_USE_WAIT || defined(__DOXYGEN__)
/**
* @brief Performs a DAC conversion.