@@ -110,7 +110,7 @@ bool TwoWire::initHardware(int sdaPin, int sclPin, uint32_t frequency){
110
110
pinMode (scl,PULLUP|OPEN_DRAIN|OUTPUT|INPUT);
111
111
112
112
if (!digitalRead (sda)||!digitalRead (scl)){ // bus in busy state
113
- log_d (" invalid state sda=%d, scl=%d" ,digitalRead (sda),digitalRead (scl));
113
+ // Serial.printf ("invalid state sda=%d, scl=%d\n ",digitalRead(sda),digitalRead(scl));
114
114
digitalWrite (sda,HIGH);
115
115
digitalWrite (scl,HIGH);
116
116
delayMicroseconds (5 );
@@ -124,17 +124,23 @@ bool TwoWire::initHardware(int sdaPin, int sclPin, uint32_t frequency){
124
124
delayMicroseconds (5 );
125
125
digitalWrite (sda,HIGH);
126
126
}
127
-
128
127
i2cAttachSDA (i2c, sda);
129
128
i2cAttachSCL (i2c, scl);
129
+
130
+ if (!digitalRead (sda)||!digitalRead (scl)){ // bus in busy state
131
+ // Serial.println("Bus Invalid State, TwoWire() Can't init");
132
+ return false ; // bus is busy
133
+ }
134
+
130
135
return true ;
131
136
}
132
137
133
138
i2c_err_t TwoWire::processQueue (uint32_t * readCount){
134
139
last_error=i2cProcQueue (i2c,readCount,_timeOutMillis);
135
140
if (last_error==I2C_ERROR_BUSY){ // try to clear the bus
136
- if (initHardware (sda,scl,getClock ()))
141
+ if (initHardware (sda,scl,getClock ())){
137
142
last_error=i2cProcQueue (i2c,readCount,_timeOutMillis);
143
+ }
138
144
}
139
145
140
146
rxIndex = 0 ;
@@ -143,7 +149,7 @@ i2c_err_t TwoWire::processQueue(uint32_t * readCount){
143
149
txQueued = 0 ; // the SendStop=true will restart all Queueing
144
150
if (_dump){
145
151
i2cDumpI2c (i2c);
146
- i2cDumpInts ();
152
+ i2cDumpInts (num );
147
153
}
148
154
i2cFreeQueue (i2c);
149
155
return last_error;
@@ -230,7 +236,7 @@ return last_error;
230
236
/* stickbreaker Dump i2c Interrupt buffer, i2c isr Debugging
231
237
*/
232
238
void TwoWire::dumpInts (){
233
- i2cDumpInts ();
239
+ i2cDumpInts (num );
234
240
}
235
241
236
242
/* stickbreaker i2c isr Debugging
0 commit comments