diff options
author | Stephan Bösebeck <sb@caluga.de> | 2016-04-01 23:54:16 +0200 |
---|---|---|
committer | Stephan Bösebeck <sb@caluga.de> | 2016-04-01 23:54:16 +0200 |
commit | aee8715815544b076c123d4ed55c76e23a7e54d0 (patch) | |
tree | ea5beb11e41bf0cc0257f1a098b2218b48a83b84 /keyboard/preonic/analog.c | |
parent | c274699085b2f922a5e8b14b21aa377249e62d29 (diff) | |
parent | de904af36072f53d2354bff0ed36b63014ad0d61 (diff) |
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'keyboard/preonic/analog.c')
-rw-r--r-- | keyboard/preonic/analog.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/keyboard/preonic/analog.c b/keyboard/preonic/analog.c deleted file mode 100644 index 49b84ee0e8..0000000000 --- a/keyboard/preonic/analog.c +++ /dev/null @@ -1,53 +0,0 @@ -// Simple analog to digitial conversion - -#include <avr/io.h> -#include <avr/pgmspace.h> -#include <stdint.h> -#include "analog.h" - - -static uint8_t aref = (1<<REFS0); // default to AREF = Vcc - - -void analogReference(uint8_t mode) -{ - aref = mode & 0xC0; -} - - -// Arduino compatible pin input -int16_t analogRead(uint8_t pin) -{ -#if defined(__AVR_ATmega32U4__) - static const uint8_t PROGMEM pin_to_mux[] = { - 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, - 0x25, 0x24, 0x23, 0x22, 0x21, 0x20}; - if (pin >= 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<<ADEN) | ADC_PRESCALER; // enable ADC - ADCSRB = (1<<ADHSM) | (mux & 0x20); // high speed mode - ADMUX = aref | (mux & 0x1F); // configure mux input - ADCSRA = (1<<ADEN) | ADC_PRESCALER | (1<<ADSC); // start the conversion - while (ADCSRA & (1<<ADSC)) ; // wait for result - low = ADCL; // must read LSB first - return (ADCH << 8) | low; // must read MSB only once! -#endif -} - - |