hdo
beta
|
00001 /* ---------------------------------------------------------------------------- 00002 * ATMEL Microcontroller Software Support 00003 * ---------------------------------------------------------------------------- 00004 * Copyright (c) 2008, Atmel Corporation 00005 * 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the disclaimer below. 00013 * 00014 * Atmel's name may not be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00020 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * ---------------------------------------------------------------------------- 00028 */ 00029 00030 //------------------------------------------------------------------------------ 00043 // -# Wait the end of the conversion by polling status with ADC_GetStatus() 00044 // -# Finally, get the converted data using ADC_GetConvertedData() 00046 //------------------------------------------------------------------------------ 00047 #ifndef ADC_H 00048 #define ADC_H 00049 00050 //------------------------------------------------------------------------------ 00051 // Headers 00052 //------------------------------------------------------------------------------ 00053 00054 //------------------------------------------------------------------------------ 00055 // Definitions 00056 //------------------------------------------------------------------------------ 00057 #define ADC_CHANNEL_0 0 00058 #define ADC_CHANNEL_1 1 00059 #define ADC_CHANNEL_2 2 00060 #define ADC_CHANNEL_3 3 00061 #define ADC_CHANNEL_4 4 00062 #define ADC_CHANNEL_5 5 00063 #define ADC_CHANNEL_6 6 00064 #define ADC_CHANNEL_7 7 00065 00066 //------------------------------------------------------------------------------ 00067 // Exported functions 00068 //------------------------------------------------------------------------------ 00069 extern void ADC_Initialize (AT91S_ADC *pAdc, 00070 unsigned char idAdc, 00071 unsigned char trgEn, 00072 unsigned char trgSel, 00073 unsigned char sleepMode, 00074 unsigned char resolution, 00075 unsigned int mckClock, 00076 unsigned int adcClock, 00077 unsigned int startupTime, 00078 unsigned int sampleAndHoldTime); 00079 extern unsigned int ADC_GetModeReg(AT91S_ADC *pAdc); 00080 extern void ADC_EnableChannel(AT91S_ADC *pAdc, unsigned int channel); 00081 extern void ADC_DisableChannel (AT91S_ADC *pAdc, unsigned int channel); 00082 extern unsigned int ADC_GetChannelStatus(AT91S_ADC *pAdc); 00083 extern void ADC_StartConversion(AT91S_ADC *pAdc); 00084 extern void ADC_SoftReset(AT91S_ADC *pAdc); 00085 extern unsigned int ADC_GetLastConvertedData(AT91S_ADC *pAdc); 00086 extern unsigned int ADC_GetConvertedData(AT91S_ADC *pAdc, unsigned int channel); 00087 extern void ADC_EnableIt(AT91S_ADC *pAdc, unsigned int flag); 00088 extern void ADC_EnableDataReadyIt(AT91S_ADC *pAdc); 00089 extern void ADC_DisableIt(AT91S_ADC *pAdc, unsigned int flag); 00090 extern unsigned int ADC_GetStatus(AT91S_ADC *pAdc); 00091 extern unsigned int ADC_GetInterruptMaskStatus(AT91S_ADC *pAdc); 00092 extern unsigned int ADC_IsInterruptMasked(AT91S_ADC *pAdc, unsigned int flag); 00093 extern unsigned int ADC_IsStatusSet(AT91S_ADC *pAdc, unsigned int flag); 00094 extern unsigned char ADC_IsChannelInterruptStatusSet(unsigned int adc_sr, 00095 unsigned int channel); 00096 00097 #endif //#ifndef ADC_H