提交 4d98cea0 编写于 作者: M me-no-dev

Add Wire:setPins(sda, scl)

Fixes: https://github.com/espressif/arduino-esp32/issues/3779
上级 b92c58d7
......@@ -58,6 +58,17 @@ TwoWire::~TwoWire()
}
}
bool TwoWire::setPins(int sdaPin, int sclPin)
{
if(i2c) {
log_e("can not set pins if begin was already called");
return false;
}
sda = sdaPin;
scl = sclPin;
return true;
}
bool TwoWire::begin(int sdaPin, int sclPin, uint32_t frequency)
{
if(sdaPin < 0) { // default param passed
......
......@@ -67,6 +67,10 @@ protected:
public:
TwoWire(uint8_t bus_num);
~TwoWire();
//call setPins() first, so that begin() can be called without arguments from libraries
bool setPins(int sda, int scl);
bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus
// calling will attemp to recover hung bus
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册