i2c fallback: support all drivers

This commit is contained in:
Dimitris Mantzouranis 2023-05-29 21:07:02 +03:00
parent a2e6cb94c6
commit 5b7af85493
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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,