From 42d5a324eb673b2214a87c8911d850105c3bdaab Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 10 Jul 2017 11:18:47 -0400 Subject: Start mvoing hardware drivers to /drivers/ (#1433) * start driver isolation * update nyquist and orthodox boards * update atreus62 * move drivers to avr * update avr conditional --- drivers/avr/analog.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 drivers/avr/analog.c (limited to 'drivers/avr/analog.c') diff --git a/drivers/avr/analog.c b/drivers/avr/analog.c new file mode 100644 index 000000000..1ec38df75 --- /dev/null +++ b/drivers/avr/analog.c @@ -0,0 +1,69 @@ +/* Copyright 2015 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// 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<