Commit cb86a2b3 authored by Andrzej Głąbek's avatar Andrzej Głąbek Committed by Carles Cufi
Browse files

drivers: i2c_nrfx_twim: Fix handling of zero-length transfers



For a zero-length transfer, the STOP task is not triggered
automatically by the shortcut with the event that signals
the transfer end because such event is not generated.
Trigger this task "manually" to prevent the driver getting
stuck after the address byte is acknowledged.

Signed-off-by: default avatarAndrzej Głąbek <andrzej.glabek@nordicsemi.no>
parent 8ff12f3a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -127,6 +127,17 @@ static int i2c_nrfx_twim_transfer(const struct device *dev,
			}
		}

		if (cur_xfer.primary_length == 0) {
			/* For a zero-length transfer, the STOP task will not
			 * be triggered automatically by the shortcut with the
			 * event that signals the transfer end. It needs to be
			 * done "manually" to prevent the driver getting stuck
			 * after the address byte is acknowledged.
			 */
			nrf_twim_task_trigger(get_dev_config(dev)->twim.p_twim,
					      NRF_TWIM_TASK_STOP);
		}

		ret = k_sem_take(&(get_dev_data(dev)->completion_sync),
				 I2C_TRANSFER_TIMEOUT_MSEC);
		if (ret != 0) {