Skip to content

Commit

Permalink
drivers: add generic i2c bitbang driver
Browse files Browse the repository at this point in the history
  • Loading branch information
protobits authored and btashton committed Jan 25, 2021
1 parent 56ef940 commit 0fa34a0
Show file tree
Hide file tree
Showing 4 changed files with 516 additions and 0 deletions.
41 changes: 41 additions & 0 deletions drivers/i2c/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,47 @@ config I2C_NTRACE
default 32
depends on I2C_TRACE

config I2C_BITBANG
bool "I2C bitbang implementation"
default n
---help---
Enable support for a bitbang implementation of I2C

if I2C_BITBANG

config I2C_BITBANG_NO_DELAY
bool "Do not add delay"
default n
---help---
If you want to go full speed (depending on how fast pins can be toggled)
you can enable this option. This will not respect the desired frequency
set during the I2C transfer operation.

config I2C_BITBANG_GPIO_OVERHEAD
int "GPIO overhead"
depends on !I2C_BITBANG_NO_DELAY
default 0
---help---
Overhead of GPIO toggling operation to consider when computing
delays. This overhead will be subtracted from sleep times to achieve
desired frquency.

config I2C_BITBANG_TIMEOUT
int "I2C timeout"
default 1000
---help---
Timeout (microseconds) to abort wait on slave

config I2C_BITBANG_CLOCK_STRETCHING
bool "Support clock stretching"
default n
---help---
This enables I2C clock stretching. This requires the hardware to set
the pin into open-collector mode (master sets SCL high and waits until
slave stops holding it low).

endif # I2C_BITBANG

config I2C_DRIVER
bool "I2C character driver"
default n
Expand Down
4 changes: 4 additions & 0 deletions drivers/i2c/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ ifeq ($(CONFIG_I2C_DRIVER),y)
CSRCS += i2c_driver.c
endif

ifeq ($(CONFIG_I2C_BITBANG),y)
CSRCS += i2c_bitbang.c
endif

# Include the selected I2C multiplexer drivers

ifeq ($(CONFIG_I2CMULTIPLEXER_PCA9540BDP),y)
Expand Down
Loading

0 comments on commit 0fa34a0

Please sign in to comment.