00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00017 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00018 * 00019 * Redistribution and use in source and binary forms, with or without 00020 * modification, are permitted provided that the following conditions are met: 00021 * 00022 * 1. Redistributions of source code must retain the above copyright notice, this 00023 * list of conditions and the following disclaimer. 00024 * 00025 * 2. Redistributions in binary form must reproduce the above copyright notice, 00026 * this list of conditions and the following disclaimer in the documentation 00027 * and/or other materials provided with the distribution. 00028 * 00029 * 3. The name of Atmel may not be used to endorse or promote products derived 00030 * from this software without specific prior written permission. 00031 * 00032 * 4. This software may only be redistributed and used in connection with an Atmel 00033 * AVR product. 00034 * 00035 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00037 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00038 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00039 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00040 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00041 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00042 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00043 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00044 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00045 * 00046 */ 00047 00048 #ifndef _ADC_H_ 00049 #define _ADC_H_ 00050 00051 #include <avr32/io.h> 00052 #include "compiler.h" 00053 00054 00055 // if using 8 bits for ADC, define this flag in your compiler options 00057 #ifdef USE_ADC_8_BITS 00058 # define ADC_MAX_VALUE 0xFF 00059 #else 00060 # define ADC_MAX_VALUE 0x3FF 00061 #endif 00062 00063 00069 extern void adc_configure(volatile avr32_adc_t * adc); 00070 00074 extern void adc_start(volatile avr32_adc_t * adc); 00075 00081 extern void adc_enable(volatile avr32_adc_t * adc, unsigned short channel); 00082 00088 extern void adc_disable(volatile avr32_adc_t * adc, unsigned short channel); 00089 00097 extern Bool adc_get_status(volatile avr32_adc_t * adc, unsigned short channel); 00098 00106 extern Bool adc_check_eoc(volatile avr32_adc_t * adc, unsigned short channel); 00107 00115 extern Bool adc_check_ovr(volatile avr32_adc_t * adc, unsigned short channel); 00116 00123 extern unsigned long adc_get_value(volatile avr32_adc_t * adc, unsigned short channel); 00124 00130 extern unsigned long adc_get_latest_value(volatile avr32_adc_t * adc); 00131 00132 #endif // _ADC_H_