Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7678be4

Browse filesBrowse files
authored
Merge branch 'master' into esp32s2
2 parents c6f6522 + 4d98cea commit 7678be4
Copy full SHA for 7678be4

File tree

2 files changed

+15
-1
lines changed
Filter options

2 files changed

+15
-1
lines changed

‎libraries/Wire/src/Wire.cpp

Copy file name to clipboardExpand all lines: libraries/Wire/src/Wire.cpp
+11Lines 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

Copy file name to clipboardExpand all lines: libraries/Wire/src/Wire.h
+4-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.