/* * c't-Bot * * 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, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307, USA. * */ /*! @file adc.c * @brief Routinen zum Einlesen der AnalogeingÄnge * @author Benjamin Benz (bbe@heise.de) * @date 26.12.05 */ #ifdef MCU #include #include //#include #include "adc.h" /*! * Initialisert den AD-Umsetzer. * @param channel Für jeden Kanal, den man nutzen möchte, * muss das entsprechende Bit in channel gesetzt sein * Bit0 = Kanal 0 usw. */ void adc_init(uint8 channel){ DDRA &= ~ channel; // Pin als input PORTA &= ~ channel; // Alle Pullups aus. } /*! * Liest einen analogen Kanal aus * @param channel Kanal - hex-Wertigkeit des Pins (0x01 fuer PA0; 0x02 fuer PA1, ..) */ uint16 adc_read(uint8 channel){ uint16 result = 0x00; // interne Refernzspannung AVCC, rechts Ausrichtung ADMUX= _BV(REFS0) ;//| _BV(REFS1); //|(0<