File tree 2 files changed +15
-1
lines changed
Filter options
2 files changed +15
-1
lines changed
Original file line number Diff line number Diff line change @@ -58,6 +58,17 @@ TwoWire::~TwoWire()
58
58
}
59
59
}
60
60
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
+
61
72
bool TwoWire::begin (int sdaPin, int sclPin, uint32_t frequency)
62
73
{
63
74
if (sdaPin < 0 ) { // default param passed
Original file line number Diff line number Diff line change @@ -67,8 +67,11 @@ class TwoWire: public Stream
67
67
public:
68
68
TwoWire (uint8_t bus_num);
69
69
~TwoWire ();
70
+
71
+ // call setPins() first, so that begin() can be called without arguments from libraries
72
+ bool setPins (int sda, int scl);
73
+
70
74
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
72
75
73
76
void setClock (uint32_t frequency); // change bus clock without initing hardware
74
77
size_t getClock (); // current bus clock rate in hz
You can’t perform that action at this time.
0 commit comments