Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

ads7870.h

Go to the documentation of this file.
00001 /*! \file ads7870.h \brief TI ADS7870 12-bit 8ch A/D Converter Driver Library. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'ads7870.h'
00005 // Title        : TI ADS7870 12-bit 8ch A/D Converter Driver Library
00006 // Author       : Pascal Stang - Copyright (C) 2005
00007 // Created      : 2005.07.19
00008 // Revised      : 2005.07.21
00009 // Version      : 0.1
00010 // Target MCU   : Atmel AVR Series
00011 // Editor Tabs  : 4
00012 //
00013 // NOTE: This code is currently below version 1.0, and therefore is considered
00014 // to be lacking in some functionality or documentation, or may not be fully
00015 // tested.  Nonetheless, you can expect most functions to work.
00016 //
00017 // This code is distributed under the GNU Public License
00018 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00019 //
00020 /// \ingroup driver_hw
00021 /// \defgroup ads7870 TI ADS7870 SPI A/D Converter Driver (ads7870.c)
00022 /// \code #include "ads7870.h" \endcode
00023 /// \par Overview
00024 ///     This library provides high-level functions for accessing the Texas
00025 ///     Instruments ADS7870 I2C A/D Converter.
00026 ///
00027 ///     The basic specs of the ADS7870 are:
00028 ///     - Fast SPI interface (up to 20MHz)
00029 ///     - 12-bit results
00030 ///     - 8 single-ended or 4 differential input channels
00031 ///     - Programmable gain stage (1,2,4,5,8,10,16,20x gains)
00032 ///     - Software or hardware triggered conversion
00033 ///     - 4-bit auxiliary digital I/O lines (controlled via serial interface)
00034 ///     - Up to 50KHz conversion rate
00035 ///     - External reference or internal 2.5V, 2.048V, 1.15V reference
00036 ///     - NOTE: use pin-compatible ADS7871 for 14-bit results
00037 //
00038 //*****************************************************************************
00039 //@{
00040 
00041 #ifndef ADS7870_H
00042 #define ADS7870_H
00043 
00044 #include "global.h"
00045 
00046 // constants/macros/typdefs
00047 #define ADS7870_CS_PORT         PORTB
00048 #define ADS7870_CS_DDR          DDRB
00049 #define ADS7870_CS_PIN          PB0
00050 
00051 // instruction bit defines
00052 #define ADS7870_CONVERT         0x80
00053 
00054 #define ADS7870_REG_READ        0x40
00055 #define ADS7870_REG_WRITE       0x00
00056 #define ADS7870_REG_16BIT       0x20
00057 
00058 // register addresses
00059 #define ADS7870_RESULTLO        0x00
00060 #define ADS7870_RESULTHI        0x01
00061 #define ADS7870_PGAVALID        0x02
00062 #define ADS7870_ADCTRL          0x03
00063 #define ADS7870_GAINMUX         0x04
00064 #define ADS7870_DIGIOSTATE      0x05
00065 #define ADS7870_DIGIOCTRL       0x06
00066 #define ADS7870_REFOSC          0x07
00067 #define ADS7870_SERIFCTRL       0x18
00068 #define ADS7870_ID              0x1F
00069 
00070 // register bit defines
00071 #define ADS7870_RESULTLO_OVR    0x01
00072 
00073 #define ADS7870_ADCTRL_BIN      0x20
00074 #define ADS7870_ADCTRL_RMB1     0x08
00075 #define ADS7870_ADCTRL_RMB0     0x04
00076 #define ADS7870_ADCTRL_CFD1     0x02
00077 #define ADS7870_ADCTRL_CFD0     0x01
00078 
00079 #define ADS7870_GAINMUX_CNVBSY  0x80
00080 
00081 #define ADS7870_REFOSC_OSCR     0x20
00082 #define ADS7870_REFOSC_OSCE     0x10
00083 #define ADS7870_REFOSC_REFE     0x08
00084 #define ADS7870_REFOSC_BUFE     0x04
00085 #define ADS7870_REFOSC_R2V      0x02
00086 #define ADS7870_REFOSC_RBG      0x01
00087 
00088 #define ADS7870_SERIFCTRL_LSB   0x01
00089 #define ADS7870_SERIFCTRL_2W3W  0x02
00090 #define ADS7870_SERIFCTRL_8051  0x04
00091 
00092 #define ADS7870_ID_VALUE        0x01
00093 
00094 // gain defines
00095 #define ADS7870_GAIN_1X         0x00
00096 #define ADS7870_GAIN_2X         0x10
00097 #define ADS7870_GAIN_4X         0x20
00098 #define ADS7870_GAIN_5X         0x30
00099 #define ADS7870_GAIN_8X         0x40
00100 #define ADS7870_GAIN_10X        0x50
00101 #define ADS7870_GAIN_16X        0x60
00102 #define ADS7870_GAIN_20X        0x70
00103 // channel defines
00104 #define ADS7870_CH_0_1_DIFF     0x00
00105 #define ADS7870_CH_2_3_DIFF     0x01
00106 #define ADS7870_CH_4_5_DIFF     0x02
00107 #define ADS7870_CH_6_7_DIFF     0x03
00108 #define ADS7870_CH_1_0_DIFF     0x04
00109 #define ADS7870_CH_3_2_DIFF     0x05
00110 #define ADS7870_CH_5_4_DIFF     0x06
00111 #define ADS7870_CH_7_6_DIFF     0x07
00112 #define ADS7870_CH_SINGLE_ENDED 0x08
00113 #define ADS7870_CH_0            0x08
00114 #define ADS7870_CH_1            0x09
00115 #define ADS7870_CH_2            0x0A
00116 #define ADS7870_CH_3            0x0B
00117 #define ADS7870_CH_4            0x0C
00118 #define ADS7870_CH_5            0x0D
00119 #define ADS7870_CH_6            0x0E
00120 #define ADS7870_CH_7            0x0F
00121 
00122 // functions
00123 
00124 //! Initialize the ADS7870 chip.
00125 /// Returns:
00126 /// TRUE if successful, 
00127 /// FALSE if unsuccessful (chip not responding).
00128 u08 ads7870Init(void);
00129 
00130 //! Begin single-ended conversion on given logical channel#0-7, and return result.
00131 /// \note Result is returned left-justified.
00132 s16 ads7870Convert(u08 channel);
00133 
00134 //! Begin differential conversion on given channel pair, and return result.
00135 /// \note Result is returned left-justified.
00136 s16 ads7870ConvertDiff(u08 channel);
00137 
00138 //! Begin conversion on given raw channel#, and return result.
00139 /// \note Result is returned left-justified.
00140 s16 ads7870ConvertRaw(u08 channel);
00141 
00142 //! Read value from ADS7870 register.
00143 ///
00144 u08 ads7870ReadReg(u08 reg);
00145 
00146 //! Write value into ADS7870 register.
00147 ///
00148 void ads7870WriteReg(u08 reg, u08 value);
00149 
00150 
00151 
00152 #endif
00153 //@}

Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by  doxygen 1.4.2