drivers: esp32: I2C driver implementation

Supports both master and slave mode, standard and fast modes,
configurable timeouts, and a few other tunable settings.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
Leandro Pereira
2017-08-23 17:24:40 -07:00
committed by Anas Nashif
parent 5f22dab17a
commit e1effa0e73
5 changed files with 813 additions and 0 deletions

View File

@@ -28,3 +28,18 @@ CONFIG_RANDOM_ESP32_RNG=y
CONFIG_SW_ISR_TABLE=y
CONFIG_GEN_ISR_TABLES=y
CONFIG_GEN_IRQ_VECTOR_TABLE=n
CONFIG_I2C=y
CONFIG_I2C_ESP32=y
CONFIG_I2C_0=y
CONFIG_I2C_1=y
CONFIG_I2C_2=n
CONFIG_I2C_3=n
# FIXME: ESP32 port should support DTS.
CONFIG_HAS_DTS_I2C=n
# IRQ priorities are fixed on Xtensa, but Kconfig will ask for these
# if not set.
CONFIG_I2C_0_IRQ_PRI=1
CONFIG_I2C_1_IRQ_PRI=1

View File

@@ -369,4 +369,6 @@ config I2C_SDA_RX_HOLD
The hold time on the data signal after a negative edge of i2c clock
while i2c acts as receiver. The unit is i2c module base clock.
source "drivers/i2c/Kconfig.esp32"
endif # I2C

79
drivers/i2c/Kconfig.esp32 Normal file
View File

@@ -0,0 +1,79 @@
# Kconfig.esp32 - ESP32 I2C configuration options
#
#
# Copyright (c) 2017 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
menuconfig I2C_ESP32
bool "ESP32 I2C"
depends on I2C && SOC_ESP32
select GPIO_ESP32
default n
help
Enables the ESP32 I2C driver
if I2C_ESP32
config I2C_ESP32_TIMEOUT
int "I2C timeout to receive a data bit in APB clock cycles"
default 200000
if I2C_0
config I2C_0_DEFAULT_CFG
# Standard speed, master
default 0x12
config I2C_ESP32_0_TX_LSB_FIRST
bool "Port 0 Transmit LSB first"
default n
config I2C_ESP32_0_RX_LSB_FIRST
bool "Port 0 Receive LSB first"
default n
config I2C_ESP32_0_IRQ
int "Port 0 IRQ line"
default 8
config I2C_ESP32_0_SCL_PIN
int "Port 0 SCL pin"
default 2
config I2C_ESP32_0_SDA_PIN
int "Port 0 SDA pin"
default 4
endif # I2C_0
if I2C_1
config I2C_1_DEFAULT_CFG
# Standard speed, master
default 0x12
config I2C_ESP32_1_TX_LSB_FIRST
bool "Port 1 Transmit LSB first"
default n
config I2C_ESP32_1_RX_LSB_FIRST
bool "Port 1 Receive LSB first"
default n
config I2C_ESP32_1_IRQ
int "Port 1 IRQ line"
default 9
config I2C_ESP32_1_SCL_PIN
int "Port 1 SCL pin"
default 5
config I2C_ESP32_1_SDA_PIN
int "Port 1 SDA pin"
default 18
endif # I2C_1
endif # I2C_ESP32

View File

@@ -10,3 +10,4 @@ obj-$(CONFIG_I2C_SBCON) += i2c_sbcon.o
obj-$(CONFIG_I2C_STM32_V1) += i2c_ll_stm32_v1.o i2c_ll_stm32.o
obj-$(CONFIG_I2C_STM32_V2) += i2c_ll_stm32_v2.o i2c_ll_stm32.o
obj-$(CONFIG_TWIHS_SAM) += twihs_sam.o
obj-$(CONFIG_I2C_ESP32) += i2c_esp32.o

716
drivers/i2c/i2c_esp32.c Normal file

File diff suppressed because it is too large Load Diff