-
Notifications
You must be signed in to change notification settings - Fork 1
/
IO.ino
executable file
·40 lines (24 loc) · 898 Bytes
/
IO.ino
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
#include <Wire.h>
static TwoWire orbitBoosterWire(0);
void InitIO() {
orbitBoosterWire.begin();
}
void writeByte(int deviceaddress, int eeaddress, char data) {
orbitBoosterWire.beginTransmission(deviceaddress);
orbitBoosterWire.write((int) (eeaddress >> 8)); // MSB
orbitBoosterWire.write((int) (eeaddress & 0xFF)); // LSB
orbitBoosterWire.write(data);
orbitBoosterWire.endTransmission();
delay (DELAY_TIME);
}
char readByte(int deviceaddress, int eeaddress) {
char rdata = 0xFF;
orbitBoosterWire.beginTransmission(deviceaddress);
orbitBoosterWire.write((int) (eeaddress >> 8)); // MSB
orbitBoosterWire.write((int) (eeaddress & 0xFF)); // LSB
orbitBoosterWire.endTransmission();
orbitBoosterWire.requestFrom(deviceaddress, 1);
if (orbitBoosterWire.available())
rdata = orbitBoosterWire.read();
return rdata;
}