File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -7,26 +7,32 @@ void arduino::MbedI2C::begin() {
7
7
}
8
8
9
9
void arduino::MbedI2C::begin (uint8_t slaveAddr) {
10
+ #ifdef DEVICE_I2CSLAVE
10
11
slave = new mbed::I2CSlave ((PinName)_sda, (PinName)_scl);
11
12
slave->address (slaveAddr);
13
+ #endif
12
14
}
13
15
14
16
void arduino::MbedI2C::end () {
15
17
if (master != NULL ) {
16
18
delete master;
17
19
}
20
+ #ifdef DEVICE_I2CSLAVE
18
21
if (slave != NULL ) {
19
22
delete slave;
20
23
}
24
+ #endif
21
25
}
22
26
23
27
void arduino::MbedI2C::setClock (uint32_t freq) {
24
28
if (master != NULL ) {
25
29
master->frequency (freq);
26
30
}
31
+ #ifdef DEVICE_I2CSLAVE
27
32
if (slave != NULL ) {
28
33
slave->frequency (freq);
29
34
}
35
+ #endif
30
36
}
31
37
32
38
void arduino::MbedI2C::beginTransmission (uint8_t address) {
Original file line number Diff line number Diff line change @@ -52,7 +52,10 @@ class MbedI2C : public HardwareI2C
52
52
virtual int available ();
53
53
54
54
private:
55
+
56
+ #ifdef DEVICE_I2CSLAVE
55
57
mbed::I2CSlave* slave;
58
+ #endif
56
59
mbed::I2C* master;
57
60
int _sda;
58
61
int _scl;
@@ -68,3 +71,5 @@ extern arduino::MbedI2C Wire;
68
71
#elif DEVICE_I2C > 1
69
72
extern arduino::MbedI2C Wire1;
70
73
#endif
74
+
75
+ typedef arduino::MbedI2C TwoWire;
You can’t perform that action at this time.
0 commit comments