Added option to force legacy i2c driver

This commit is contained in:
nopnop2002 2024-09-07 11:43:16 +09:00
parent 8e2fc78391
commit 3994b245b9
3 changed files with 21 additions and 2 deletions

View File

@ -120,12 +120,20 @@ Therefore, the maximum i2c clock frequency is 400KHz.
The i2c clock frequency used by this project is 400KHz.
# I2C Port selection
![config-i2c-port](https://github.com/nopnop2002/esp-idf-ssd1306/assets/6020549/7a7de5ec-ef20-42ac-ba70-73ba74a762a7)
![config-i2c-port](https://github.com/user-attachments/assets/477bdf29-7492-4256-bc9e-e3ff363cddcc)
The ESP32 XTENSA series has two I2C Ports.
You can use these two ports freely.
If you use this module at the same time as another I2C device using I2C port 0, you must change it to I2C port 1.
# Force legacy i2c driver
xtensa's ESP32 has two i2c buses: I2C_NUM_0/1.
I2C_NUM_0/1 are initialized independently, but legacy i2c drivers and new i2c drivers cannot be mixed.
If I2C_NUM_0 is initialized with the legacy i2c driver, I2C_NUM_1 must also be initialized with the legacy i2c driver.
If you use the SSD1306 at the same time as an I2C device that uses a legacy I2C driver, you must initialize the SSD1306 with the legacy I2C driver.
Enabling this will use the legacy i2c driver even after ESP-IDF V5.2.
![config-i2c-driver](https://github.com/user-attachments/assets/d07076d0-1c94-43d1-aa5a-aec810d2f7bc)
---
# SPI Clock speed

View File

@ -4,7 +4,11 @@ set(component_srcs "ssd1306.c" "ssd1306_spi.c")
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}")
if(idf_version VERSION_GREATER_EQUAL "5.2")
list(APPEND component_srcs "ssd1306_i2c_new.c")
if(CONFIG_LEGACY_DRIVER)
list(APPEND component_srcs "ssd1306_i2c_legacy.c")
else()
list(APPEND component_srcs "ssd1306_i2c_new.c")
endif()
else()
list(APPEND component_srcs "ssd1306_i2c_legacy.c")
endif()

View File

@ -158,6 +158,13 @@ menu "SSD1306 Configuration"
Use I2C_PORT_1.
endchoice
config LEGACY_DRIVER
depends on I2C_INTERFACE
bool "Force legacy i2c driver"
default false
help
Force legacy i2c driver.
choice SPI_HOST
depends on SPI_INTERFACE
prompt "SPI peripheral that controls this bus"