File tree 1 file changed +4
-1
lines changed
1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ int i2c_write(int busno, int b)
139
139
for (i = 7 ;i >=0 ;i -- ) {
140
140
/* Set SCL low and set our bit on SDA */
141
141
i2c_scl_o (busno , 0 );
142
+ i2c_halfperiod (); /* make sure SCL has settled low */
142
143
i2c_sda_oe (busno , b & (1 << i ) ? 0 : 1 );
143
144
i2c_halfperiod ();
144
145
/* Set SCL high ; data is shifted on the rising edge of SCL */
@@ -148,8 +149,9 @@ int i2c_write(int busno, int b)
148
149
/* Check ack */
149
150
/* Set SCL low, then release SDA so that the I2C target can respond */
150
151
i2c_scl_o (busno , 0 );
151
- i2c_halfperiod ();
152
+ i2c_halfperiod (); /* make sure SCL has settled low */
152
153
i2c_sda_oe (busno , 0 );
154
+ i2c_halfperiod ();
153
155
/* Set SCL high and check for ack */
154
156
i2c_scl_o (busno , 1 );
155
157
i2c_halfperiod ();
@@ -182,6 +184,7 @@ int i2c_read(int busno, int ack)
182
184
/* Send ack */
183
185
/* Set SCL low and pull SDA low when acking */
184
186
i2c_scl_o (busno , 0 );
187
+ i2c_halfperiod (); /* make sure SCL has settled low */
185
188
if (ack )
186
189
i2c_sda_oe (busno , 1 );
187
190
i2c_halfperiod ();
You can’t perform that action at this time.
0 commit comments