sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AS7265X.h
Go to the documentation of this file.
1 #ifndef AS7265X_h
2 #define AS7265X_h
3 
4 #include "Arduino.h"
5 #include <Wire.h>
6 
7 #define AS72651_DEVICE_TYPE 0x00
8 #define AS72651_HW_VERSION 0x01
9 #define AS72651_FW_VERSION_H 0x02
10 #define AS72651_FW_VERSION_L 0x03
11 #define AS72651_CONTROL_SETUP 0x04
12 #define AS72651_INT_TIME 0x05
13 #define AS72651_DEV_TEMP 0x06
14 #define AS72651_LED_CONFIG 0x07
15 
16 #define AS72651_RAW_VALUE_0_H 0x08 // selection depends on register value of DEV_SEL
17 #define AS72651_RAW_VALUE_0_L 0x09
18 #define AS72651_RAW_VALUE_1_H 0x0A
19 #define AS72651_RAW_VALUE_1_L 0x0B
20 #define AS72651_RAW_VALUE_2_H 0x0C
21 #define AS72651_RAW_VALUE_2_L 0x0D
22 #define AS72651_RAW_VALUE_3_H 0x0E
23 #define AS72651_RAW_VALUE_3_L 0x0F
24 #define AS72651_RAW_VALUE_4_H 0x10
25 #define AS72651_RAW_VALUE_4_L 0x11
26 #define AS72651_RAW_VALUE_5_H 0x12
27 #define AS72651_RAW_VALUE_5_L 0x13
28 
29 #define AS72651_I2C_CAL_SELECT 0x3F
30 
31 //I2C_CAL_SELECT == 0x00
32 #define AS72651_CAL_CHAN0_0 0x14
33 #define AS72651_CAL_CHAN0_1 0x15
34 #define AS72651_CAL_CHAN0_2 0x16
35 #define AS72651_CAL_CHAN0_3 0x17
36 
37 #define AS72651_CAL_CHAN1_0 0x18
38 #define AS72651_CAL_CHAN1_1 0x19
39 #define AS72651_CAL_CHAN1_2 0x1A
40 #define AS72651_CAL_CHAN1_3 0x1B
41 
42 #define AS72651_CAL_CHAN2_0 0x1C
43 #define AS72651_CAL_CHAN2_1 0x1D
44 #define AS72651_CAL_CHAN2_2 0x1E
45 #define AS72651_CAL_CHAN2_3 0x1F
46 
47 #define AS72651_CAL_CHAN3_0 0x20
48 #define AS72651_CAL_CHAN3_1 0x21
49 #define AS72651_CAL_CHAN3_2 0x22
50 #define AS72651_CAL_CHAN3_3 0x23
51 
52 #define AS72651_CAL_CHAN4_0 0x24
53 #define AS72651_CAL_CHAN4_1 0x25
54 #define AS72651_CAL_CHAN4_2 0x26
55 #define AS72651_CAL_CHAN4_3 0x27
56 
57 #define AS72651_CAL_CHAN5_0 0x28
58 #define AS72651_CAL_CHAN5_1 0x29
59 #define AS72651_CAL_CHAN5_2 0x2A
60 #define AS72651_CAL_CHAN5_3 0x2B
61 
62 #define AS72651_FW_CNTRL 0x48
63 #define AS72651_FW_BYTE_COUNT_H 0x49
64 #define AS72651_FW_BYTE_COUNT_L 0x4A
65 #define AS72651_DEV_SEL 0x4F
66 
67 #define AS72651_COEF_DATA_0 0x50
68 #define AS72651_COEF_DATA_1 0x51
69 #define AS72651_COEF_DATA_2 0x52
70 #define AS72651_COEF_DATA_3 0x53
71 #define AS72651_COEF_READ 0x54
72 #define AS72651_COEF_WRITE 0x55
73 
74 #define AS72651_FW_UPDATE_CONTROL 0x60
75 #define AS72651_FWBC_HIGH 0x61
76 #define AS72651_FWBC_LOW 0x62
77 #define AS72651_FW_LOAD 0x63
78 
79 #define I2C_AS72XX_SLAVE_STATUS_REG 0x00
80 #define I2C_AS72XX_SLAVE_WRITE_REG 0x01
81 #define I2C_AS72XX_SLAVE_READ_REG 0x02
82 #define I2C_AS72XX_SLAVE_TX_VALID 0x02
83 #define I2C_AS72XX_SLAVE_RX_VALID 0x01
84 
85 #define AS72651_ADDRESS 0x49
86 
87 #define led_drv_12_5_mA 0x00
88 #define led_drv_25_mA 0x01
89 #define led_drv_50_mA 0x02
90 #define led_drv_100_mA 0x03
91 
92 #define led_ind_1_mA 0x00
93 #define led_ind_2_mA 0x01
94 #define led_ind_4_mA 0x02
95 #define led_ind_8_mA 0x03
96 
97 #define gain_1x 0x00
98 #define gain_4x 0x01
99 #define gain_16x 0x02
100 #define gain_64x 0x03
101 
102 #define mode0 0x00 // Mode 0: S, U, V, T, I, H, K, G, C, B, E, A
103 #define mode1 0x01 // Mode 1: W, U, R, T, L, H, J, G, F, B, D, A
104 #define mode2 0x02 // default, all 18 channels
105 #define mode3 0x03 // one shotoperation of mode 2
106 
107 
108 class AS7265X
109 {
110  public:
111  AS7265X(uint8_t intPin);
112  void init(uint8_t gain, uint8_t mode, uint8_t intTime);
113  uint8_t getDevType();
114  uint8_t getHWVersion();
115  uint16_t getFWMajorVersion();
116  uint16_t getFWPatchVersion();
117  uint16_t getFWBuildVersion();
118  uint8_t getStatus();
119  float getTemperature(uint8_t devNum);
120  void configureLed(uint8_t ledIndCurrent, uint8_t ledDrvCurrent, uint8_t devNum);
121  void enableIndLed(uint8_t devNum);
122  void enableDrvLed(uint8_t devNum);
123  void disableIndLed(uint8_t devNum);
124  void disableDrvLed(uint8_t devNum);
125  void readCalData(float * destination);
126  void readRawData(int16_t * destination);
127  void I2Cscan();
128  void i2cm_AS72xx_write(uint8_t virtualReg, uint8_t d);
129  uint8_t i2cm_AS72xx_read(uint8_t virtualReg);
130  void writeByte(uint8_t address, uint8_t subAddress, uint8_t data);
131  uint8_t readByte(uint8_t address, uint8_t subAddress);
132 
133  private:
134  uint8_t _intPin;
135 };
136 
137 #endif
unsigned long d
Definition: OWGeneric_DangerShield.ino:116
void readCalData(float *destination)
Definition: AS7265X.cpp:76
Definition: AS7265X.h:108
void configureLed(uint8_t ledIndCurrent, uint8_t ledDrvCurrent, uint8_t devNum)
Definition: AS7265X.cpp:182
float getTemperature(uint8_t devNum)
Definition: AS7265X.cpp:174
uint8_t getStatus()
Definition: AS7265X.cpp:22
void disableDrvLed(uint8_t devNum)
Definition: AS7265X.cpp:213
uint16_t getFWPatchVersion()
Definition: AS7265X.cpp:150
uint16_t getFWBuildVersion()
Definition: AS7265X.cpp:162
void disableIndLed(uint8_t devNum)
Definition: AS7265X.cpp:197
void enableIndLed(uint8_t devNum)
Definition: AS7265X.cpp:189
uint8_t readByte(uint8_t address, uint8_t subAddress)
Definition: AS7265X.cpp:333
void init(uint8_t gain, uint8_t mode, uint8_t intTime)
Definition: AS7265X.cpp:9
AS7265X(uint8_t intPin)
Definition: AS7265X.cpp:4
void i2cm_AS72xx_write(uint8_t virtualReg, uint8_t d)
Definition: AS7265X.cpp:221
uint8_t i2cm_AS72xx_read(uint8_t virtualReg)
Definition: AS7265X.cpp:250
void readRawData(int16_t *destination)
Definition: AS7265X.cpp:30
void I2Cscan()
Definition: AS7265X.cpp:280
uint16_t getFWMajorVersion()
Definition: AS7265X.cpp:138
uint8_t getDevType()
Definition: AS7265X.cpp:125
uint8_t intTime
Definition: Due_AS7265X_Spectrometer.ino:51
void enableDrvLed(uint8_t devNum)
Definition: AS7265X.cpp:205
tuple data
Definition: ser-mon-AS7265X.py:40
void writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
Definition: AS7265X.cpp:325
uint8_t gain
Definition: Due_AS7265X_Spectrometer.ino:51
#define intPin
Definition: Due_AS7265X_Spectrometer.ino:26
uint8_t getHWVersion()
Definition: AS7265X.cpp:131
mode
Definition: onewire.c:520