?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik /*! \file ads7870.h \brief TI ADS7870 12-bit 8ch A/D Converter Driver Library. */
2 //*****************************************************************************
3 //
4 // File Name : 'ads7870.h'
5 // Title : TI ADS7870 12-bit 8ch A/D Converter Driver Library
6 // Author : Pascal Stang - Copyright (C) 2005
7 // Created : 2005.07.19
8 // Revised : 2005.07.21
9 // Version : 0.1
10 // Target MCU : Atmel AVR Series
11 // Editor Tabs : 4
12 //
13 // NOTE: This code is currently below version 1.0, and therefore is considered
14 // to be lacking in some functionality or documentation, or may not be fully
15 // tested. Nonetheless, you can expect most functions to work.
16 //
17 // This code is distributed under the GNU Public License
18 // which can be found at http://www.gnu.org/licenses/gpl.txt
19 //
20 /// \ingroup driver_hw
21 /// \defgroup ads7870 TI ADS7870 SPI A/D Converter Driver (ads7870.c)
22 /// \code #include "ads7870.h" \endcode
23 /// \par Overview
24 /// This library provides high-level functions for accessing the Texas
25 /// Instruments ADS7870 I2C A/D Converter.
26 ///
27 /// The basic specs of the ADS7870 are:
28 /// - Fast SPI interface (up to 20MHz)
29 /// - 12-bit results
30 /// - 8 single-ended or 4 differential input channels
31 /// - Programmable gain stage (1,2,4,5,8,10,16,20x gains)
32 /// - Software or hardware triggered conversion
33 /// - 4-bit auxiliary digital I/O lines (controlled via serial interface)
34 /// - Up to 50KHz conversion rate
35 /// - External reference or internal 2.5V, 2.048V, 1.15V reference
36 /// - NOTE: use pin-compatible ADS7871 for 14-bit results
37 //
38 //*****************************************************************************
39 //@{
40  
41 #ifndef ADS7870_H
42 #define ADS7870_H
43  
44 #include "global.h"
45  
46 // constants/macros/typdefs
47 #define ADS7870_CS_PORT PORTB
48 #define ADS7870_CS_DDR DDRB
49 #define ADS7870_CS_PIN PB0
50  
51 // instruction bit defines
52 #define ADS7870_CONVERT 0x80
53  
54 #define ADS7870_REG_READ 0x40
55 #define ADS7870_REG_WRITE 0x00
56 #define ADS7870_REG_16BIT 0x20
57  
58 // register addresses
59 #define ADS7870_RESULTLO 0x00
60 #define ADS7870_RESULTHI 0x01
61 #define ADS7870_PGAVALID 0x02
62 #define ADS7870_ADCTRL 0x03
63 #define ADS7870_GAINMUX 0x04
64 #define ADS7870_DIGIOSTATE 0x05
65 #define ADS7870_DIGIOCTRL 0x06
66 #define ADS7870_REFOSC 0x07
67 #define ADS7870_SERIFCTRL 0x18
68 #define ADS7870_ID 0x1F
69  
70 // register bit defines
71 #define ADS7870_RESULTLO_OVR 0x01
72  
73 #define ADS7870_ADCTRL_BIN 0x20
74 #define ADS7870_ADCTRL_RMB1 0x08
75 #define ADS7870_ADCTRL_RMB0 0x04
76 #define ADS7870_ADCTRL_CFD1 0x02
77 #define ADS7870_ADCTRL_CFD0 0x01
78  
79 #define ADS7870_GAINMUX_CNVBSY 0x80
80  
81 #define ADS7870_REFOSC_OSCR 0x20
82 #define ADS7870_REFOSC_OSCE 0x10
83 #define ADS7870_REFOSC_REFE 0x08
84 #define ADS7870_REFOSC_BUFE 0x04
85 #define ADS7870_REFOSC_R2V 0x02
86 #define ADS7870_REFOSC_RBG 0x01
87  
88 #define ADS7870_SERIFCTRL_LSB 0x01
89 #define ADS7870_SERIFCTRL_2W3W 0x02
90 #define ADS7870_SERIFCTRL_8051 0x04
91  
92 #define ADS7870_ID_VALUE 0x01
93  
94 // gain defines
95 #define ADS7870_GAIN_1X 0x00
96 #define ADS7870_GAIN_2X 0x10
97 #define ADS7870_GAIN_4X 0x20
98 #define ADS7870_GAIN_5X 0x30
99 #define ADS7870_GAIN_8X 0x40
100 #define ADS7870_GAIN_10X 0x50
101 #define ADS7870_GAIN_16X 0x60
102 #define ADS7870_GAIN_20X 0x70
103 // channel defines
104 #define ADS7870_CH_0_1_DIFF 0x00
105 #define ADS7870_CH_2_3_DIFF 0x01
106 #define ADS7870_CH_4_5_DIFF 0x02
107 #define ADS7870_CH_6_7_DIFF 0x03
108 #define ADS7870_CH_1_0_DIFF 0x04
109 #define ADS7870_CH_3_2_DIFF 0x05
110 #define ADS7870_CH_5_4_DIFF 0x06
111 #define ADS7870_CH_7_6_DIFF 0x07
112 #define ADS7870_CH_SINGLE_ENDED 0x08
113 #define ADS7870_CH_0 0x08
114 #define ADS7870_CH_1 0x09
115 #define ADS7870_CH_2 0x0A
116 #define ADS7870_CH_3 0x0B
117 #define ADS7870_CH_4 0x0C
118 #define ADS7870_CH_5 0x0D
119 #define ADS7870_CH_6 0x0E
120 #define ADS7870_CH_7 0x0F
121  
122 // functions
123  
124 //! Initialize the ADS7870 chip.
125 /// Returns:
126 /// TRUE if successful,
127 /// FALSE if unsuccessful (chip not responding).
128 u08 ads7870Init(void);
129  
130 //! Begin single-ended conversion on given logical channel#0-7, and return result.
131 /// \note Result is returned left-justified.
132 s16 ads7870Convert(u08 channel);
133  
134 //! Begin differential conversion on given channel pair, and return result.
135 /// \note Result is returned left-justified.
136 s16 ads7870ConvertDiff(u08 channel);
137  
138 //! Begin conversion on given raw channel#, and return result.
139 /// \note Result is returned left-justified.
140 s16 ads7870ConvertRaw(u08 channel);
141  
142 //! Read value from ADS7870 register.
143 ///
144 u08 ads7870ReadReg(u08 reg);
145  
146 //! Write value into ADS7870 register.
147 ///
148 void ads7870WriteReg(u08 reg, u08 value);
149  
150  
151  
152 #endif
153 //@}
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3