Skip to content

Commit 990fac2

Browse files
authored
Update Wire.h
1 parent e40a29f commit 990fac2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libraries/Wire/src/Wire.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
#ifndef I2C_BUFFER_LENGTH
4646
#define I2C_BUFFER_LENGTH 128 // Default size, if none is set using Wire::setBuffersize(size_t)
4747
#endif
48+
#if SOC_I2C_SUPPORT_SLAVE
4849
typedef void(*user_onRequest)(void);
4950
typedef void(*user_onReceive)(uint8_t*, int);
51+
#endif /* SOC_I2C_SUPPORT_SLAVE */
5052

5153
class TwoWire: public Stream
5254
{
@@ -71,8 +73,8 @@ class TwoWire: public Stream
7173
SemaphoreHandle_t lock;
7274
#endif
7375
private:
74-
bool is_slave;
7576
#if SOC_I2C_SUPPORT_SLAVE
77+
bool is_slave;
7678
void (*user_onRequest)(void);
7779
void (*user_onReceive)(int);
7880
static void onRequestService(uint8_t, void *);
@@ -90,12 +92,15 @@ class TwoWire: public Stream
9092
bool setPins(int sda, int scl);
9193

9294
bool begin(int sda, int scl, uint32_t frequency=0); // returns true, if successful init of i2c bus
95+
#if SOC_I2C_SUPPORT_SLAVE
9396
bool begin(uint8_t slaveAddr, int sda, int scl, uint32_t frequency);
97+
#endif /* SOC_I2C_SUPPORT_SLAVE */
9498
// Explicit Overload for Arduino MainStream API compatibility
9599
inline bool begin()
96100
{
97101
return begin(-1, -1, static_cast<uint32_t>(0));
98102
}
103+
#if SOC_I2C_SUPPORT_SLAVE
99104
inline bool begin(uint8_t addr)
100105
{
101106
return begin(addr, -1, -1, 0);
@@ -104,6 +109,7 @@ class TwoWire: public Stream
104109
{
105110
return begin(static_cast<uint8_t>(addr), -1, -1, 0);
106111
}
112+
#endif /* SOC_I2C_SUPPORT_SLAVE */
107113
bool end();
108114

109115
size_t setBufferSize(size_t bSize);

0 commit comments

Comments
 (0)