at91_adc.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 by Ole Reinhardt <ole.reinhardt@embedded-it.de>,
00003  *                       Kernelconcepts http://www.embedded-it.de
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. Neither the name of the copyright holders nor the names of
00015  *    contributors may be used to endorse or promote products derived
00016  *    from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00019  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00022  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00025  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00026  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00027  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00028  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00029  * SUCH DAMAGE.
00030  *
00031  * For additional information see http://www.ethernut.de/
00032  *
00033  */
00034  
00035 /*
00036  * $Log: at91_adc.h,v $
00037  * Revision 1.3  2008/08/11 06:59:59  haraldkipp
00038  * BSD types replaced by stdint types (feature request #1282721).
00039  *
00040  * Revision 1.2  2007/12/09 22:12:05  olereinhardt
00041  * Added cvs log tag
00042  *
00043  */
00044 
00045 
00052 
00053 #ifndef _AT91_ADC_H_
00054 #define _AT91_ADC_H_
00055 
00072 typedef enum adc_mode_type
00073 {
00074     ADC_OFF,
00075     FREE_RUNNING_T0,
00076     FREE_RUNNING_T1,
00077     FREE_RUNNING_T2,
00078     FREE_RUNNING_EXT,
00079     SINGLE_CONVERSION
00080 } TADCMode;
00081 
00082 
00088 typedef enum adc_channel_type
00089 {
00090     ADC0=0,
00091     ADC1=1,
00092     ADC2=2,
00093     ADC3=3,
00094     ADC4=4,
00095     ADC5=5,
00096     ADC6=6,
00097     ADC7=7,
00098     ADC_MAX_CHANNEL = 8
00099 } TADCChannel;
00100 
00101 /* Function prototypes */
00102 
00103 void ADCInit(void);
00104 
00105 
00106 // ADCStartConversion
00107 //                                                    
00108 // Begins ADC conversion. The conversion will process all 
00109 // enabled channels one after the other.
00110 //
00111 // NOTE: Converted values from the ADC are stored
00112 //       in a local buffer. The user must call
00113 //       ADC_read to obtain these values.
00114 //
00115 // pre:  none
00116 // post: The ADC has started conversion. Completion of
00117 //       any conversions is not guaranteed.
00118 
00119 void ADCStartConversion(void);
00120 
00121 
00122 // ADCSetPrescale
00123 //                                                    
00124 // Allows setting of ADC clock prescalar (ADC rate).
00125 // The  ADC rate is given by the system clock rate
00126 // divided by the prescalar value. Possible prescalar
00127 // values range from 2-128
00128 //
00129 // pre: "prescalar" is a valid ADC reference from the
00130 //       choices given above
00131 // post: ADC prescalar set to desired choice
00132 
00133 void ADCSetPrescale(u_int prescale);
00134 
00135 
00136 // ADCEnableChannel
00137 // ADCDisableChannel
00138 //
00139 // Enables/disables a channel to be sampled on the next conversion
00140 //
00141 // pre: none
00142 // post: Channel is selected / deselected. Next conversion will respect these settings
00143 
00144 void ADCDisableChannel(TADCChannel channel);
00145 void ADCEnableChannel(TADCChannel channel);
00146 
00147 
00148 // ADCSetMode
00149 //
00150 // Possible values: 
00151 //    - ADC_OFF
00152 //    - SINGLE_CONVERSION
00153 //    - FREE_RUNNING_T0
00154 //    - FREE_RUNNING_T1
00155 //    - FREE_RUNNING_T2
00156 //      These depend on a timer t0 / t1 / t2 
00157 //    - FREE_RUNNING_EXT
00158 //      External trigger
00159 //
00160 // pre: none
00161 // post: Set adc conversion to the selected value. 
00162 
00163 void ADCSetMode(TADCMode mode); 
00164 
00165 // AFCBufRead
00166 //
00167 // Reads the next sampled value of the given channel from the buffer.
00168 // 
00169 // pre: Sample completed
00170 // post: Value will be removed from buffer
00171 
00172 int ADCBufRead(uint16_t channel, uint16_t * read);
00173 
00174 #endif
00175 

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/