45
45
#ifndef I2C_BUFFER_LENGTH
46
46
#define I2C_BUFFER_LENGTH 128 // Default size, if none is set using Wire::setBuffersize(size_t)
47
47
#endif
48
+ #if SOC_I2C_SUPPORT_SLAVE
48
49
typedef void (*user_onRequest)(void );
49
50
typedef void (*user_onReceive)(uint8_t *, int );
51
+ #endif /* SOC_I2C_SUPPORT_SLAVE */
50
52
51
53
class TwoWire : public Stream
52
54
{
@@ -71,8 +73,8 @@ class TwoWire: public Stream
71
73
SemaphoreHandle_t lock;
72
74
#endif
73
75
private:
74
- bool is_slave;
75
76
#if SOC_I2C_SUPPORT_SLAVE
77
+ bool is_slave;
76
78
void (*user_onRequest)(void );
77
79
void (*user_onReceive)(int );
78
80
static void onRequestService (uint8_t , void *);
@@ -90,12 +92,15 @@ class TwoWire: public Stream
90
92
bool setPins (int sda, int scl);
91
93
92
94
bool begin (int sda, int scl, uint32_t frequency=0 ); // returns true, if successful init of i2c bus
95
+ #if SOC_I2C_SUPPORT_SLAVE
93
96
bool begin (uint8_t slaveAddr, int sda, int scl, uint32_t frequency);
97
+ #endif /* SOC_I2C_SUPPORT_SLAVE */
94
98
// Explicit Overload for Arduino MainStream API compatibility
95
99
inline bool begin ()
96
100
{
97
101
return begin (-1 , -1 , static_cast <uint32_t >(0 ));
98
102
}
103
+ #if SOC_I2C_SUPPORT_SLAVE
99
104
inline bool begin (uint8_t addr)
100
105
{
101
106
return begin (addr, -1 , -1 , 0 );
@@ -104,6 +109,7 @@ class TwoWire: public Stream
104
109
{
105
110
return begin (static_cast <uint8_t >(addr), -1 , -1 , 0 );
106
111
}
112
+ #endif /* SOC_I2C_SUPPORT_SLAVE */
107
113
bool end ();
108
114
109
115
size_t setBufferSize (size_t bSize);
0 commit comments