-
Notifications
You must be signed in to change notification settings - Fork 3
/
ADC128D818.h
56 lines (39 loc) · 1023 Bytes
/
ADC128D818.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
#ifndef __ADC128D818_H__
#define __ADC128D818_H__
#include "Arduino.h"
enum reference_mode_t {
INTERNAL_REF = 0, EXTERNAL_REF = 1
};
enum conv_mode_t {
LOW_POWER, CONTINUOUS, ONE_SHOT
};
enum operation_mode_t {
SINGLE_ENDED_WITH_TEMP = 0,
SINGLE_ENDED = 1,
DIFFERENTIAL = 2,
MIXED = 3
};
class ADC128D818 {
public:
ADC128D818(uint8_t address);
void setReference(double ref_voltage);
void setReferenceMode(reference_mode_t mode);
void setOperationMode(operation_mode_t mode);
void setDisabledMask(uint8_t disabled_mask);
void setConversionMode(conv_mode_t mode);
void begin();
uint16_t read(uint8_t channel);
double readConverted(uint8_t channel);
double readTemperatureConverted();
private:
uint8_t addr;
uint8_t disabled_mask;
double ref_v;
reference_mode_t ref_mode;
operation_mode_t op_mode;
conv_mode_t conv_mode;
void setRegisterAddress(uint8_t reg_addr);
void setRegister(uint8_t reg_addr, uint8_t value);
uint8_t readCurrentRegister8();
};
#endif