zephyr/drivers/i2c/Kconfig.dw
Dev Joshi a9e6fa4b29 drivers: I2C_DW: Fix I2C scan example
Solves two identical issues listed below:

Issue 1: I2C scanner example for DesignWare hardware gets stuck
indefenitely resulting in system hang up.This is because DW I2C driver
does not handle 0 byte transfer correctly which is the case for I2C
scan example.

Fixed it by overwriting the msg length to 1 if it is 0 and the
buffer is not NULL.

Issue 2: Similarly, if the I2C pins are not pulled up (nothing connected
 to I2C pins), the DW hardware does not actually send the data
(assuming contention on the bus) hence not releasing the semaphore
resulting in calling thread waiting forever.

Fixed it by adding a timeout to k_sem_take call and return error if
cannot successfully acquire it.

Tested scenarios where nothing was connected on the bus and saw the
I2C scan example complete the whole scan command. Then connected
two different sensors on the I2C bus and saw both the address on the
console. Tested both the uses cases on Raspberry Pi Pico.

Fixes #70332.

Found that micropython tackles the same issue by implementing I2C scan
commands with Soft I2C because the same reason mentioned in Issue 1.

Signed-off-by: Dev Joshi <quic_devbhave@quicinc.com>
2024-07-04 08:23:43 +02:00

30 lines
762 B
Plaintext

# Copyright (c) 2018 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
menuconfig I2C_DW
bool "Design Ware I2C support"
default y
depends on DT_HAS_SNPS_DESIGNWARE_I2C_ENABLED
help
Enable the Design Ware I2C driver
config I2C_DW_CLOCK_SPEED
int "Set the clock speed for I2C"
depends on I2C_DW
default 32
config I2C_DW_LPSS_DMA
bool "Use I2C integrated DMA for asynchronous transfer"
depends on I2C_DW
select DMA
select DMA_INTEL_LPSS
help
This option enables I2C DMA feature to be used for asynchronous
data transfers. All Tx operations are done using dma channel 0 and
all Rx operations are done using dma channel 1.
config I2C_DW_RW_TIMEOUT_MS
int "Set the Read/Write timeout in milliseconds"
depends on I2C_DW
default 100