/**************************************************************************** * * Copyright (c) 2005 Dave Hylands * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ****************************************************************************/ /** * * @file a2d_8.c * * @brief Contains code for retrieving 8 bit A/D samples. * *****************************************************************************/ /* ---- Include Files ----------------------------------------------------- */ #include #include "Config.h" #include "Hardware.h" /* ---- Public Variables -------------------------------------------------- */ /* ---- Private Constants and Types --------------------------------------- */ /* ---- Private Variables ------------------------------------------------- */ /* ---- Private Function Prototypes --------------------------------------- */ /* ---- Functions --------------------------------------------------------- */ /****************************************************************************/ /** * Reads an 8 bit A/D value. */ #if CFG_USE_ADC uint8_t a2d_8( uint8_t Channel ) { // Select the channel ADMUX = Channel | ( 1 << ADLAR ); // Start the conversion ADCSR = ADCSR | ( 1 << ADSC ); // Wait for it to complete while ( ADCSR & ( 1 << ADSC )); // We only need the top 8 bits (left-adjusted) return ADCH; } // a2d _8 #endif // CFG_USE_ADC