From 5b7af854937d243b614f94d708e848dbc9025ea6 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Mon, 29 May 2023 21:07:02 +0300 Subject: [PATCH] i2c fallback: support all drivers --- docs/i2c_driver.md | 4 ++-- platforms/chibios/drivers/i2c_master.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/i2c_driver.md b/docs/i2c_driver.md index 2efce83efe8..80fa52cd1a1 100644 --- a/docs/i2c_driver.md +++ b/docs/i2c_driver.md @@ -120,9 +120,9 @@ See [this page](https://www.playembedded.org/blog/stm32-i2c-chibios/#8_I2Cv2_I2C ### I2C Fallback :id=arm-configuration-i2cfallback ChibiOS provides a software solution through the I2C Fallback driver for cases where hardware I2C is not available. -To enable it, modify your board's `halconf.h` to enable the first I2C Fallback driver( assuming selected I2C peripheral is `I2CD1`). +To enable it, modify your board's `halconf.h` to enable the I2C Fallback driver( assuming selected I2C peripheral is `I2CD1`). ```c -#define SW_I2C_USE_I2C1 +#define SW_I2C_USE_I2C1 TRUE ``` By default, the delay required for I2C communication is calculated automatically with a target frequency of 100kHz, through the ChibiOS OSAL layer. If you wish to override this behavior, further modify your board's `halconf.h` ```c diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c index ad149d45407..ba59155ec13 100644 --- a/platforms/chibios/drivers/i2c_master.c +++ b/platforms/chibios/drivers/i2c_master.c @@ -90,7 +90,7 @@ # endif #endif -#ifdef SW_I2C_USE_I2C1 +#if (SW_I2C_USE_I2C1 || SW_I2C_USE_I2C2 || SW_I2C_USE_I2C3 || SW_I2C_USE_I2C4) # ifndef I2C1_SCL_PAL_MODE # define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN # endif @@ -113,7 +113,7 @@ __attribute__((weak)) void i2c_sw_delay(void) {} static uint8_t i2c_address; static const I2CConfig i2cconfig = { -#if defined(SW_I2C_USE_I2C1) +#if (SW_I2C_USE_I2C1 || SW_I2C_USE_I2C2 || SW_I2C_USE_I2C3 || SW_I2C_USE_I2C4) 0, I2C1_SCL_PIN, I2C1_SDA_PIN,