summaryrefslogtreecommitdiffstats
path: root/adc.c
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-04-03 14:48:00 +0200
committerneoraider <devnull@localhost>2007-04-03 14:48:00 +0200
commitdc1306244e3a7853c31cd94c5ac3d97aa6e6c0d5 (patch)
tree758cc525af6b6fca0af22482ec51c70017dbb7fc /adc.c
downloadrc2007-rescue-dc1306244e3a7853c31cd94c5ac3d97aa6e6c0d5.tar
rc2007-rescue-dc1306244e3a7853c31cd94c5ac3d97aa6e6c0d5.zip
Neues Rescue-Programm angefangen (2)
Diffstat (limited to 'adc.c')
-rw-r--r--adc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/adc.c b/adc.c
new file mode 100644
index 0000000..192d36c
--- /dev/null
+++ b/adc.c
@@ -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;
+}