forked from MyRobotLab/mrlcomm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MrlI2cBus.h
37 lines (33 loc) · 1.24 KB
/
MrlI2cBus.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
#ifndef MrlI2cBus_h
#define MrlI2cBus_h
#define WIRE Wire
#include <Wire.h>
/**
* I2C bus
* TODO:KW? don't allow this class to write directly to the global serial port
* device classes shouldn't have a direct handle to the serial port, rather have
* a mrlmessage class that it returns.
* TODO: Mats
* The I2CBus device represents one I2C bus.
* It's the SDA (data line) and SCL pins (clock line) that is used to
* communicate with any device that uses the i2c protocol on that bus.
* It is NOT a representation of the addressable i2c devices, just the bus
* On Arduino Uno that's pins A4 and A5, Mega 20 and 21, Leonardo 2 and 3,
* The pin assignment is defined in Wire.h so it will change to the correct
* pins at compile time. We don't have to worry here.
* However some other i2c implementations exist's so that more pins can be used
* for i2c communication. That is not supported here yet.
*
*/
class MrlI2CBus : public Device {
private:
int bus;
public:
MrlI2CBus(int deviceId);
bool attach(byte bus);
void i2cRead(byte deviceAddress, byte size);
void i2cWrite(byte deviceAddress, byte dataSize, const byte*data);
void i2cWriteRead(byte deviceAddress, byte readSize, byte writeValue);
void update();
};
#endif