]> git.tdb.fi Git - model-railway-devices.git/blobdiff - common/adc.h
Somre more common facilities
[model-railway-devices.git] / common / adc.h
diff --git a/common/adc.h b/common/adc.h
new file mode 100644 (file)
index 0000000..d9cff6b
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef ADC_H_
+#define ADC_H_
+
+#include <avr/interrupt.h>
+
+#define ADC_SET_CALLBACK(f) \
+       ISR(ADC_vect) \
+       { \
+               uint16_t v = ADCL; \
+               v |= ADCH<<8; \
+               f(v); \
+       }
+
+void adc_init();
+void adc_read_async(uint8_t);
+
+#endif