Skip to content

Commit 7678be4

Browse files
authored
Merge branch 'master' into esp32s2
2 parents c6f6522 + 4d98cea commit 7678be4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ TwoWire::~TwoWire()
5858
}
5959
}
6060

61+
bool TwoWire::setPins(int sdaPin, int sclPin)
62+
{
63+
if(i2c) {
64+
log_e("can not set pins if begin was already called");
65+
return false;
66+
}
67+
sda = sdaPin;
68+
scl = sclPin;
69+
return true;
70+
}
71+
6172
bool TwoWire::begin(int sdaPin, int sclPin, uint32_t frequency)
6273
{
6374
if(sdaPin < 0) { // default param passed

libraries/Wire/src/Wire.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ class TwoWire: public Stream
6767
public:
6868
TwoWire(uint8_t bus_num);
6969
~TwoWire();
70+
71+
//call setPins() first, so that begin() can be called without arguments from libraries
72+
bool setPins(int sda, int scl);
73+
7074
bool begin(int sda=-1, int scl=-1, uint32_t frequency=100000); // returns true, if successful init of i2c bus
71-
// calling will attemp to recover hung bus
7275

7376
void setClock(uint32_t frequency); // change bus clock without initing hardware
7477
size_t getClock(); // current bus clock rate in hz

0 commit comments

Comments
 (0)