File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -932,6 +932,9 @@ where
932
932
// Send a STOP condition
933
933
self . i2c . cr1 . modify ( |_, w| w. stop ( ) . set_bit ( ) ) ;
934
934
935
+ // Wait for STOP condition to transmit.
936
+ while self . i2c . cr1 . read ( ) . stop ( ) . bit_is_set ( ) { }
937
+
935
938
// Fallthrough is success
936
939
Ok ( ( ) )
937
940
}
@@ -965,7 +968,10 @@ where
965
968
. write ( |w| unsafe { w. bits ( ( u32:: from ( addr) << 1 ) + 1 ) } ) ;
966
969
967
970
// Wait until address was sent
968
- while self . i2c . sr1 . read ( ) . addr ( ) . bit_is_clear ( ) { }
971
+ while {
972
+ self . check_and_clear_error_flags ( ) ?;
973
+ self . i2c . sr1 . read ( ) . addr ( ) . bit_is_clear ( )
974
+ } { }
969
975
970
976
// Clear condition by reading SR2
971
977
self . i2c . sr2 . read ( ) ;
@@ -983,6 +989,9 @@ where
983
989
// Receive last byte
984
990
* last = self . recv_byte ( ) ?;
985
991
992
+ // Wait for the STOP to be sent.
993
+ while self . i2c . cr1 . read ( ) . stop ( ) . bit_is_set ( ) { }
994
+
986
995
// Fallthrough is success
987
996
Ok ( ( ) )
988
997
} else {
You can’t perform that action at this time.
0 commit comments