Nut/OS  4.10.3
API Reference
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$
00037  * Revision 1.4  2009/01/17 11:26:47  haraldkipp
00038  * Getting rid of two remaining BSD types in favor of stdint.
00039  * Replaced 'u_int' by 'unsinged int' and 'uptr_t' by 'uintptr_t'.
00040  *
00041  * Revision 1.3  2008/08/11 06:59:59  haraldkipp
00042  * BSD types replaced by stdint types (feature request #1282721).
00043  *
00044  * Revision 1.2  2007/12/09 22:12:05  olereinhardt
00045  * Added cvs log tag
00046  *
00047  */
00048 
00049 
00056 
00057 #ifndef _AT91_ADC_H_
00058 #define _AT91_ADC_H_
00059 
00076 typedef enum adc_mode_type
00077 {
00078     ADC_OFF,
00079     FREE_RUNNING_T0,
00080     FREE_RUNNING_T1,
00081     FREE_RUNNING_T2,
00082     FREE_RUNNING_EXT,
00083     SINGLE_CONVERSION
00084 } TADCMode;
00085 
00086 
00092 typedef enum adc_channel_type
00093 {
00094     ADC0=0,
00095     ADC1=1,
00096     ADC2=2,
00097     ADC3=3,
00098     ADC4=4,
00099     ADC5=5,
00100     ADC6=6,
00101     ADC7=7,
00102     ADC_MAX_CHANNEL = 8
00103 } TADCChannel;
00104 
00105 /* Function prototypes */
00106 
00107 void ADCInit(void);
00108 
00109 
00110 // ADCStartConversion
00111 //                                                    
00112 // Begins ADC conversion. The conversion will process all 
00113 // enabled channels one after the other.
00114 //
00115 // NOTE: Converted values from the ADC are stored
00116 //       in a local buffer. The user must call
00117 //       ADC_read to obtain these values.
00118 //
00119 // pre:  none
00120 // post: The ADC has started conversion. Completion of
00121 //       any conversions is not guaranteed.
00122 
00123 void ADCStartConversion(void);
00124 
00125 
00126 // ADCSetPrescale
00127 //                                                    
00128 // Allows setting of ADC clock prescalar (ADC rate).
00129 // The  ADC rate is given by the system clock rate
00130 // divided by the prescalar value. Possible prescalar
00131 // values range from 2-128
00132 //
00133 // pre: "prescalar" is a valid ADC reference from the
00134 //       choices given above
00135 // post: ADC prescalar set to desired choice
00136 
00137 void ADCSetPrescale(uint32_t prescale);
00138 
00139 
00140 // ADCEnableChannel
00141 // ADCDisableChannel
00142 //
00143 // Enables/disables a channel to be sampled on the next conversion
00144 //
00145 // pre: none
00146 // post: Channel is selected / deselected. Next conversion will respect these settings
00147 
00148 void ADCDisableChannel(TADCChannel channel);
00149 void ADCEnableChannel(TADCChannel channel);
00150 
00151 
00152 // ADCSetMode
00153 //
00154 // Possible values: 
00155 //    - ADC_OFF
00156 //    - SINGLE_CONVERSION
00157 //    - FREE_RUNNING_T0
00158 //    - FREE_RUNNING_T1
00159 //    - FREE_RUNNING_T2
00160 //      These depend on a timer t0 / t1 / t2 
00161 //    - FREE_RUNNING_EXT
00162 //      External trigger
00163 //
00164 // pre: none
00165 // post: Set adc conversion to the selected value. 
00166 
00167 void ADCSetMode(TADCMode mode); 
00168 
00169 // AFCBufRead
00170 //
00171 // Reads the next sampled value of the given channel from the buffer.
00172 // 
00173 // pre: Sample completed
00174 // post: Value will be removed from buffer
00175 
00176 int ADCBufRead(uint16_t channel, uint16_t * read);
00177 
00178 #endif
00179