File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -931,21 +931,17 @@ static void prep_for_restart_if_needed(struct i2c_s *obj_s) {
931
931
* STOP at the end of the current transaction.
932
932
*/
933
933
static uint32_t get_hal_xfer_options (struct i2c_s * obj_s , bool stop ) {
934
- if ( obj_s -> state == STM_I2C_SB_READ_IN_PROGRESS || obj_s -> state == STM_I2C_SB_WRITE_IN_PROGRESS ) {
935
- if ( stop ) {
936
- // Generate restart condition and stop at end
937
- return I2C_OTHER_AND_LAST_FRAME ;
938
- } else {
939
- // Generate restart condition but don't send STOP
940
- return I2C_OTHER_FRAME ;
941
- }
934
+ ( void ) obj_s ;
935
+
936
+ // Note: The naming used by STM32 HAL is quite counterintuitive. "OTHER_FRAME" means "always send a
937
+ // start/restart condition at the start of the frame". In contrast, "FIRST_FRAME" means "don't send
938
+ // a start/restart if the previous transfer was going the same direction".
939
+ if ( stop ) {
940
+ // Generate start condition and stop at end
941
+ return I2C_OTHER_AND_LAST_FRAME ;
942
942
} else {
943
- if (stop ) {
944
- // Generate start condition and stop at end
945
- return I2C_FIRST_AND_LAST_FRAME ;
946
- } else {
947
- return I2C_LAST_FRAME ;
948
- }
943
+ // Generate only the start condition
944
+ return I2C_OTHER_FRAME ;
949
945
}
950
946
}
951
947
You can’t perform that action at this time.
0 commit comments