source: firmware/FSC/usb_src/ad7719_adc.h@ 19602

Last change on this file since 19602 was 10109, checked in by lutz, 14 years ago
niculin & dom debugged quite some stuff
File size: 2.6 KB
Line 
1#ifndef __AD7719_ADC_H
2#define __AD7719_ADC_H
3//-----------------------------------------------------------------------------
4
5#include "typedefs.h"
6#include "application.h"
7#include "num_conversion.h"
8//-----------------------------------------------------------------------------
9// Bit Definitions
10#define ADC_RDY PD6
11#define ADC_RST PD7
12#define AD7719_IS_READY() (!(PIND & (1<<PD6))) // TRUE if PD6=0 AD_RDY is inverted logic.
13
14// Port Definitions
15#define ADC_PRT PORTD
16#define ADC_DDR DDRD
17#define ADC_PIN PIND
18
19
20// ON CHIP REGISTER ADDRESSES
21#define STATUS_RD 0x40
22
23#define MODE_WR 0x01
24#define MODE_RD 0x41
25
26#define AD0CON_WR 0x02
27#define AD0CON_RD 0x42
28
29#define AD1CON_WR 0x03
30#define AD1CON_RD 0x43
31
32#define FILTER_WR 0x04
33#define FILTER_RD 0x44
34
35#define AD0DAT_RD 0x45
36#define AD1DAT_RD 0x46
37
38#define IOCON_WR 0x07
39#define IOCON_RD 0x47
40
41#define AD0OFS_WR 0x08
42#define AD0OFS_RD 0x48
43
44#define AD1OFS_WR 0x09
45#define AD1OFS_RD 0x49
46
47#define AD0GAIN_WR 0x0A
48#define AD0GAIN_RD 0x4A
49
50#define AD1GAIN_WR 0x0B
51#define AD1GAIN_RD 0x4B
52
53#define ID_RD 0x4F
54
55// REGISTER INIT VALUES
56
57 //Init Configure and Initialize AD7719
58 //http://designtools.analog.com/dt/adc/codegen/ad7719.html
59
60#define IOCON_INIT_HIGH 0x03 //0000.0011 // I-sources I1 and I2 are switched on, thats all
61#define IOCON_INIT_LOWBYTE 0x00
62
63#define FILTER_INIT 0x52 //0x52 euro use 50Hz = -171dB and 60Hz = -58dB Rejectjon Updaterate = 4Hz
64 // 0x52=82 decimal. f_ADC=16.6Hz; t_ADC=60ms; t_settle = 120ms
65
66#define AD1CON_INIT 0x31 //0011.0001
67 // AD1EN is set --> AUX ADc is used for Temp measurement.
68 // ACH = 011 --> Tempsensor
69 // U/#B = 0 --> bipolar, but i'm not entirely sure if this is correct.
70 // ARN = 1 --> input range is REFIN2 , but when tempsensor is chosen, internal ref is used ...
71
72#define AD0CON_INIT 0x8E // 1000.1110
73 // AD0EN is set
74 // WL is cleared --> 24bit
75 // CH = 00 --> AIN1 , AIN2 used
76 // U/#B = 1 --> unipolar
77 // RN=110 --> input range = +-1.28V --> whatever this means in ratiometric measurements.
78
79
80#define MODE_IDLE 0x01
81#define MODE_SINGLE 0x02
82#define MODE_CONT 0x03
83#define MODE_INTERNAL_ZERO_CAL 0x04 // not tested
84#define MODE_INTERNAL_FULL_CAL 0x05 // not tested
85
86// since the ADC is chopped, one should wait 3 conversions
87// after the muxer was switched, until the reading is okay.
88#define READINGS_UNTIL_AD7719_SETTLED 3
89
90void ad7719_init(void);
91void startconv(U08 continuous);
92void stopconv(void);
93U32 read_adc(void);
94//-----------------------------------------------------------------------------
95#endif
Note: See TracBrowser for help on using the repository browser.