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

# ads7828.h

Go to the documentation of this file.

    00001 /*! \file ads7828.h \brief TI ADS7828 12-bit 8ch A/D Converter Driver Library. */
    00002 //*****************************************************************************
    00003 //
    00004 // File Name    : 'ads7828.h'
    00005 // Title        : TI ADS7828 12-bit 8ch A/D Converter Driver Library
    00006 // Author       : Pascal Stang - Copyright (C) 2004
    00007 // Created      : 2004.02.10
    00008 // Revised      : 2004.02.19
    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 ads7828 TI ADS7828 I2C A/D Converter Driver (ads7828.c)
    00022 /// \code #include "ads7828.h" \endcode
    00023 /// \par Overview
    00024 ///     This library provides high-level functions for accessing the Texas
    00025 ///     Instruments ADS7828 I2C A/D Converter.
    00026 ///
    00027 ///     The basic specs of the ADS7828 are:
    00028 ///     - 12-bit results
    00029 ///     - 8 input channels
    00030 ///     - up to 50KHz conversion rate
    00031 ///     - External reference or internal 2.5V reference
    00032 //
    00033 //*****************************************************************************
    00034 //@{
    00035
    00036 #ifndef ADS7828_H
    00037 #define ADS7828_H
    00038
    00039 #include "global.h"
    00040
    00041 // constants/macros/typdefs
    00042 #define ADS7828_I2C_ADDR    0x90    ///< Base I2C address of ADS7828 devices
    00043
    00044 // command register bit defines
    00045 #define ADS7828_CMD_PD0     0x04    ///< ADS7828 Power-down bit 0
    00046 #define ADS7828_CMD_PD1     0x08    ///< ADS7828 Power-down bit 1
    00047 #define ADS7828_CMD_C0      0x10    ///< ADS7828 Channel Select bit 0
    00048 #define ADS7828_CMD_C1      0x20    ///< ADS7828 Channel Select bit 1
    00049 #define ADS7828_CMD_C2      0x40    ///< ADS7828 Channel Select bit 2
    00050 #define ADS7828_CMD_SD      0x80    ///< ADS7828 Single-ended/Differential Select bit
    00051
    00052 // single-ended channel order defines
    00053 #define ADS7828_CMD_CH0     0x00    ///< ADS7828 Convert Channel 0
    00054 #define ADS7828_CMD_CH1     0x04    ///< ADS7828 Convert Channel 1
    00055 #define ADS7828_CMD_CH2     0x01    ///< ADS7828 Convert Channel 2
    00056 #define ADS7828_CMD_CH3     0x05    ///< ADS7828 Convert Channel 3
    00057 #define ADS7828_CMD_CH4     0x02    ///< ADS7828 Convert Channel 4
    00058 #define ADS7828_CMD_CH5     0x06    ///< ADS7828 Convert Channel 5
    00059 #define ADS7828_CMD_CH6     0x03    ///< ADS7828 Convert Channel 6
    00060 #define ADS7828_CMD_CH7     0x07    ///< ADS7828 Convert Channel 7
    00061
    00062 // power-down mode defines
    00063 #define ADS7828_CMD_PDMODE0 0x00    ///< ADS7828 Power-down Mode 0
    00064 #define ADS7828_CMD_PDMODE1 0x04    ///< ADS7828 Power-down Mode 1
    00065 #define ADS7828_CMD_PDMODE2 0x08    ///< ADS7828 Power-down Mode 2
    00066 #define ADS7828_CMD_PDMODE3 0x0C    ///< ADS7828 Power-down Mode 3
    00067
    00068 // functions
    00069
    00070 //! Initialize the ADS7828 chip.
    00071 /// Returns:
    00072 /// TRUE if successful,
    00073 /// FALSE if unsuccessful (chip not present).
    00074 u08 ads7828Init(u08 i2cAddr);
    00075
    00076 //! Set the voltage reference to use for A/D conversion.
    00077 /// - ref = 0  =>  External reference voltage on Ref pin.
    00078 /// - ref = 1  =>  Internal 2.5V reference voltage (Ref pin left open).
    00079 void ads7828SetReference(u08 ref);
    00080
    00081 //! Begin single-ended conversion on given logical channel#, and return result.
    00082 u16 ads7828Convert(u08 i2cAddr, u08 channel);
    00083
    00084 //! Begin differential conversion on given channel pair, and return result.
    00085 u16 ads7828ConvertDiff(u08 i2cAddr, u08 channel);
    00086
    00087 //! Begin conversion on given raw channel#, and return result.
    00088 u16 ads7828ConvertRaw(u08 i2cAddr, u08 channel);
    00089
    00090 #endif
    00091 //@}