aboutsummaryrefslogtreecommitdiffstats
path: root/os/io/adc.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-05 09:53:48 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-05 09:53:48 +0000
commit345e69346056fde8e9a806b03a71c1ad78e5784b (patch)
treeea0f1d16c294d4bf1710e3182cbd11a72c47e1cf /os/io/adc.c
parent493c21948bdca96c6632a5afcd8c4e63f8151910 (diff)
downloadChibiOS-345e69346056fde8e9a806b03a71c1ad78e5784b.tar.gz
ChibiOS-345e69346056fde8e9a806b03a71c1ad78e5784b.tar.bz2
ChibiOS-345e69346056fde8e9a806b03a71c1ad78e5784b.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1267 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/io/adc.c')
-rw-r--r--os/io/adc.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/os/io/adc.c b/os/io/adc.c
new file mode 100644
index 000000000..8b4123bcd
--- /dev/null
+++ b/os/io/adc.c
@@ -0,0 +1,83 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file adc.c
+ * @brief ADC Driver code.
+ * @addtogroup ADC
+ * @{
+ */
+
+#include <ch.h>
+#include <adc.h>
+
+/**
+ * @brief ADC Driver initialization.
+ */
+void adcInit(void) {
+
+ adc_lld_init();
+}
+
+/**
+ * @brief Initializes the standard part of a @p ADCDriver structure.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ */
+void adcObjectInit(ADCDriver *adcp) {
+
+ adcp->adc_state = ADC_STOP;
+ adcp->adc_config = NULL;
+}
+
+/**
+ * @brief Configures and activates the ADC peripheral.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ * @param config pointer to the @p ADCConfig object
+ */
+void adcStart(ADCDriver *adcp, const ADCConfig *config) {
+
+ chDbgCheck((adcp != NULL) && (config != NULL), "adcStart");
+ chDbgAssert((adcp->adc_state == ADC_STOP) || (adcp->adc_state == ADC_READY),
+ "adcStart(), #1",
+ "invalid state");
+
+ adcp->adc_config = config;
+ adc_lld_start(adcp);
+ adcp->adc_state = ADC_READY;
+}
+
+/**
+ * @brief Deactivates the ADC peripheral.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ */
+void adcStop(ADCDriver *adcp) {
+
+ chDbgCheck(adcp != NULL, "adcStop");
+ chDbgAssert((adcp->spd_state == ADC_STOP) || (adcp->spd_state == ADC_READY),
+ "adcStop(), #1",
+ "invalid state");
+
+ adc_lld_stop(adcp);
+ adcp->spd_state = ADC_STOP;
+}
+
+/** @} */