-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAD5625.h
62 lines (57 loc) · 1.79 KB
/
AD5625.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
/*
AD5625.h Library for writing configuration data to AD5625 DAC
Last update 9/3/2015
John Freudenthal and Sean Kirkpatrick
*/
#ifndef AD5625_h //check for multiple inclusions
#define AD5625_h
#include "Arduino.h"
#include "i2c_t3.h"
#define NumberOfChannels 4
#define InternalReference 2.5f
#define I2CTimeout 1000
#define MaxVoltageInt 0x1000
enum class powerMode{Unknown, Normal, GND1kOhm, GND100kOhm, HighImpedance};
enum class outputMode{Unknown, Immediate, Synchronized};
enum class AD5625ReferenceMode{Unknown, Internal, External};
enum class commandMode{Write2Register, UpdateRegister, WriteWUpdateAll, WriteWUpdate, PowerUpDown, Reset, LDACRegister, IntReference};
class AD5625
{
public:
AD5625();
AD5625(uint8_t _Address);
~AD5625();
bool isConnected();
uint8_t getAddress();
void setAddress(uint8_t address);
bool setVoltage(uint8_t Channel, float Value);
int getVoltage(uint8_t Channel);
bool setPower(uint8_t Channel, bool Active);
bool getPower(uint8_t Channel);
bool setPowerMode(powerMode ModeSetting);
powerMode getPowerMode();
bool setOutputMode(outputMode ModeSetting);
outputMode getOutputMode();
bool setReference(AD5625ReferenceMode ModeSetting);
AD5625ReferenceMode getReference();
void setVRefExt(float VRef);
float getVRefExt();
float getVRef();
private:
uint8_t Address;
bool Power[NumberOfChannels];
float Voltage[NumberOfChannels];
powerMode PowerMode;
outputMode OutputMode;
AD5625ReferenceMode ReferenceMode;
uint8_t CommandByte;
uint8_t MSBByte;
uint8_t LSBByte;
const float VRefInt = InternalReference;
float VRefExt;
void ResetCommandByte();
void SetCommandByteAddress(uint8_t DACAddress);
void SetCommandByteCommand(commandMode Command);
void SendI2C();
};
#endif