From b2d4969f8f49654f79b8747f08ec30aa84cf8ba7 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sun, 16 Aug 2015 17:56:56 -0400 Subject: atomic --- keyboard/atomic/analog.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 keyboard/atomic/analog.c (limited to 'keyboard/atomic/analog.c') diff --git a/keyboard/atomic/analog.c b/keyboard/atomic/analog.c new file mode 100644 index 0000000000..49b84ee0e8 --- /dev/null +++ b/keyboard/atomic/analog.c @@ -0,0 +1,53 @@ +// Simple analog to digitial conversion + +#include +#include +#include +#include "analog.h" + + +static uint8_t aref = (1<= 12) return 0; + return adc_read(pgm_read_byte(pin_to_mux + pin)); +#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) + if (pin >= 8) return 0; + return adc_read(pin); +#else + return 0; +#endif +} + +// Mux input +int16_t adc_read(uint8_t mux) +{ +#if defined(__AVR_AT90USB162__) + return 0; +#else + uint8_t low; + + ADCSRA = (1<