summaryrefslogtreecommitdiffstats
path: root/adc.cpp
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-04-04 14:08:03 +0200
committerneoraider <devnull@localhost>2007-04-04 14:08:03 +0200
commite26a1dc73313098cef235918d237f9b1a6e4cb5f (patch)
tree0dfc7f873db2f228b39509daed9b1e01cb5739dd /adc.cpp
parentdc1306244e3a7853c31cd94c5ac3d97aa6e6c0d5 (diff)
downloadrc2007-rescue-e26a1dc73313098cef235918d237f9b1a6e4cb5f.tar
rc2007-rescue-e26a1dc73313098cef235918d237f9b1a6e4cb5f.zip
Rescue: Weitere Grundfunktionen implementiert
Diffstat (limited to 'adc.cpp')
-rw-r--r--adc.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/adc.cpp b/adc.cpp
new file mode 100644
index 0000000..192d36c
--- /dev/null
+++ b/adc.cpp
@@ -0,0 +1,18 @@
+#include "adc.h"
+
+#include <avr/io.h>
+
+
+void initADC() {
+ ADMUX = (1<<REFS0);
+ ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
+}
+
+uint16_t getADCValue(int port) {
+ ADMUX = (1<<REFS0)|(1<<ADLAR)|(port&0x07);
+ ADCSRA |= (1<<ADSC);
+
+ while(!(ADCSRA & (1<<ADIF)));
+
+ return ADC;
+}