-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAD7606.h
95 lines (87 loc) · 4.43 KB
/
AD7606.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef AD7606_H
#define AD7606_H
#include "arduino.h"
// Serial
// Send CVA and CVB high pulse, wait busy go to low, put CS low, {read 16 times DB7 and DB8} (Most significant bit first)
//
// Byte mode / paralel mode
// Send CVA and CVB high pulse, wait busy go to low, put CS low, {put RD low, read the values, put RD high}
class AD7606
{
protected:
uint8_t _RESET;
uint8_t _CS;
uint8_t _CONVSTA;
uint8_t _CONVSTB;
uint8_t _RD;
uint8_t _DB7;
uint8_t _DB8;
uint8_t _BUSY;
uint8_t _D0_D7[8];
uint8_t _D0_D15[16];
uint8_t _OS0;
uint8_t _OS1;
uint8_t _OS2;
uint8_t _RANGE;
void pulse(uint8_t);
void pulse(uint8_t, uint8_t);
void ipulse(uint8_t);
void ipulse(uint8_t, uint8_t);
void reset();
public:
void setOversampling(uint8_t);
void setRange(bool);
void extendedRange(bool);
};
class AD7606_ESPI : public AD7606
{
public:
AD7606_ESPI(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET); // Constructor for Emulated SPI communication
AD7606_ESPI(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int RANGE); // Constructor for Emulated SPI communication
AD7606_ESPI(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2); // Constructor for Emulated SPI communication
AD7606_ESPI(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2,int RANGE); // Constructor for Emulated SPI communication
void read(int16_t *); // Read raw values from ADC
void read(int16_t *,uint8_t ); // Read raw values from ADC
int16_t * readAndReturn(); // Read raw values from ADC and return a array pointer
};
class AD7606_Serial : public AD7606
{
public:
AD7606_Serial(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET); // Constructor for serial communication
AD7606_Serial(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int RANGE); // Constructor for serial communication
AD7606_Serial(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2); // Constructor for serial communication
AD7606_Serial(int DB7, int DB8, int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2,int RANGE); // Constructor for serial communication
void read(int16_t *); // Read raw values from ADC
void read(int16_t *,uint8_t ); // Read raw values from ADC
};
class AD7606_8080 : public AD7606
{
public:
AD7606_8080(int D0_D7[8], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET); // Constructor for parallel byte communication
AD7606_8080(int D0_D7[8], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int RANGE); // Constructor for parallel byte communication
AD7606_8080(int D0_D7[8], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2); // Constructor for parallel byte communication
AD7606_8080(int D0_D7[8], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2,int RANGE); // Constructor for parallel byte communication
void read(int16_t *); // Read raw values from ADC
void read(int16_t *,uint8_t ); // Read raw values from ADC
int16_t * readAndReturn(); // Read raw values from ADC and return a array pointer
};
class AD7606_16 : public AD7606
{
public:
AD7606_16(int D0_D15[16], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET); // Constructor for parallel communication
AD7606_16(int D0_D15[16], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int RANGE); // Constructor for parallel communication
AD7606_16(int D0_D15[16], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2); // Constructor for parallel communication
AD7606_16(int D0_D15[16], int RD, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET,int OS0,int OS1,int OS2,int RANGE); // Constructor for parallel communication
void read(int16_t *); // Read raw values from ADC
void read(int16_t *,uint8_t ); // Read raw values from ADC
int16_t * readAndReturn(); // Read raw values from ADC and return a array pointer
};
class AD7606_SPI : public AD7606
{
public:
AD7606_SPI(int MISO, int SCK, int CS, int CONVSTA, int CONVSTB, int BUSY, int RESET); // Constructor for SPI communication
void read(int16_t *); // Read raw values from ADC
void read(int16_t *,uint8_t ); // Read raw values from ADC
int16_t * readAndReturn(); // Read raw values from ADC and return a array pointer
};
#endif