Skip to content

Commit 694df6f

Browse files
committed
fix(wire): fixes C2 no slave
1 parent e151d4c commit 694df6f

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,14 +596,14 @@ void TwoWire::flush() {
596596
//i2cFlush(num); // cleanup
597597
}
598598

599-
void TwoWire::onReceive(user_onReceive_t function) {
599+
void TwoWire::onReceive(std::function<void(int) function) {
600600
#if SOC_I2C_SUPPORT_SLAVE
601601
user_onReceive = function;
602602
#endif
603603
}
604604

605605
// sets function called on slave read
606-
void TwoWire::onRequest(user_onRequest_t function) {
606+
void TwoWire::onRequest(std::function<void() function) {
607607
#if SOC_I2C_SUPPORT_SLAVE
608608
user_onRequest = function;
609609
#endif

libraries/Wire/src/Wire.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ class TwoWire : public HardwareI2C {
7474
#if SOC_I2C_SUPPORT_SLAVE
7575
bool is_slave;
7676
// functional pointers for user callbacks
77-
using user_onRequest_t = std::function<void()>;
78-
using user_onReceive_t = std::function<void(int)>;
79-
user_onRequest_t user_onRequest;
80-
user_onReceive_t user_onReceive;
77+
std::function<void()> user_onRequest;
78+
std::function<void(int) user_onReceive;
8179
static void onRequestService(uint8_t, void *);
8280
static void onReceiveService(uint8_t, uint8_t *, size_t, bool, void *);
8381
#endif /* SOC_I2C_SUPPORT_SLAVE */
@@ -115,8 +113,8 @@ class TwoWire : public HardwareI2C {
115113
size_t requestFrom(uint8_t address, size_t len, bool stopBit) override;
116114
size_t requestFrom(uint8_t address, size_t len) override;
117115

118-
void onReceive(user_onReceive_t) override;
119-
void onRequest(user_onRequest_t) override;
116+
void onReceive(std::function<void(int)) override;
117+
void onRequest(std::function<void()>) override;
120118

121119
//call setPins() first, so that begin() can be called without arguments from libraries
122120
bool setPins(int sda, int scl);

0 commit comments

Comments
 (0)