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.2  2007/12/09 22:12:05  olereinhardt
00038  * Added cvs log tag
00039  *
00040  */
00041 
00042 
00049 
00050 #ifndef _AT91_ADC_H_
00051 #define _AT91_ADC_H_
00052 
00069 typedef enum adc_mode_type
00070 {
00071     ADC_OFF,
00072     FREE_RUNNING_T0,
00073     FREE_RUNNING_T1,
00074     FREE_RUNNING_T2,
00075     FREE_RUNNING_EXT,
00076     SINGLE_CONVERSION
00077 } TADCMode;
00078 
00079 
00085 typedef enum adc_channel_type
00086 {
00087     ADC0=0,
00088     ADC1=1,
00089     ADC2=2,
00090     ADC3=3,
00091     ADC4=4,
00092     ADC5=5,
00093     ADC6=6,
00094     ADC7=7,
00095     ADC_MAX_CHANNEL = 8
00096 } TADCChannel;
00097 
00098 /* Function prototypes */
00099 
00100 void ADCInit(void);
00101 
00102 
00103 // ADCStartConversion
00104 //                                                    
00105 // Begins ADC conversion. The conversion will process all 
00106 // enabled channels one after the other.
00107 //
00108 // NOTE: Converted values from the ADC are stored
00109 //       in a local buffer. The user must call
00110 //       ADC_read to obtain these values.
00111 //
00112 // pre:  none
00113 // post: The ADC has started conversion. Completion of
00114 //       any conversions is not guaranteed.
00115 
00116 void ADCStartConversion(void);
00117 
00118 
00119 // ADCSetPrescale
00120 //                                                    
00121 // Allows setting of ADC clock prescalar (ADC rate).
00122 // The  ADC rate is given by the system clock rate
00123 // divided by the prescalar value. Possible prescalar
00124 // values range from 2-128
00125 //
00126 // pre: "prescalar" is a valid ADC reference from the
00127 //       choices given above
00128 // post: ADC prescalar set to desired choice
00129 
00130 void ADCSetPrescale(u_int prescale);
00131 
00132 
00133 // ADCEnableChannel
00134 // ADCDisableChannel
00135 //
00136 // Enables/disables a channel to be sampled on the next conversion
00137 //
00138 // pre: none
00139 // post: Channel is selected / deselected. Next conversion will respect these settings
00140 
00141 void ADCDisableChannel(TADCChannel channel);
00142 void ADCEnableChannel(TADCChannel channel);
00143 
00144 
00145 // ADCSetMode
00146 //
00147 // Possible values: 
00148 //    - ADC_OFF
00149 //    - SINGLE_CONVERSION
00150 //    - FREE_RUNNING_T0
00151 //    - FREE_RUNNING_T1
00152 //    - FREE_RUNNING_T2
00153 //      These depend on a timer t0 / t1 / t2 
00154 //    - FREE_RUNNING_EXT
00155 //      External trigger
00156 //
00157 // pre: none
00158 // post: Set adc conversion to the selected value. 
00159 
00160 void ADCSetMode(TADCMode mode); 
00161 
00162 // AFCBufRead
00163 //
00164 // Reads the next sampled value of the given channel from the buffer.
00165 // 
00166 // pre: Sample completed
00167 // post: Value will be removed from buffer
00168 
00169 int ADCBufRead(u_short channel, u_short * read);
00170 
00171 #endif
00172 

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