diff options
Diffstat (limited to 'drivers/arm/i2c_master.h')
| -rw-r--r-- | drivers/arm/i2c_master.h | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/arm/i2c_master.h b/drivers/arm/i2c_master.h index efe3909a6..31cbfb977 100644 --- a/drivers/arm/i2c_master.h +++ b/drivers/arm/i2c_master.h | |||
| @@ -27,7 +27,7 @@ | |||
| 27 | #include "ch.h" | 27 | #include "ch.h" |
| 28 | #include <hal.h> | 28 | #include <hal.h> |
| 29 | 29 | ||
| 30 | #if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32L0xx) || defined(STM32L1xx) | 30 | #if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F4XX) || defined(STM32L0xx) || defined(STM32L1xx) |
| 31 | # define USE_I2CV1 | 31 | # define USE_I2CV1 |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| @@ -51,6 +51,20 @@ | |||
| 51 | # define I2C1_SDA 7 | 51 | # define I2C1_SDA 7 |
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | #if defined(STM32F1XX) || defined(STM32F1xx) | ||
| 55 | # define USE_GPIOV1 | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #ifndef USE_GPIOV1 | ||
| 59 | // The default PAL alternate modes are used to signal that the pins are used for I2C | ||
| 60 | # ifndef I2C1_SCL_PAL_MODE | ||
| 61 | # define I2C1_SCL_PAL_MODE 4 | ||
| 62 | # endif | ||
| 63 | # ifndef I2C1_SDA_PAL_MODE | ||
| 64 | # define I2C1_SDA_PAL_MODE 4 | ||
| 65 | # endif | ||
| 66 | #endif | ||
| 67 | |||
| 54 | #ifdef USE_I2CV1 | 68 | #ifdef USE_I2CV1 |
| 55 | # ifndef I2C1_OPMODE | 69 | # ifndef I2C1_OPMODE |
| 56 | # define I2C1_OPMODE OPMODE_I2C | 70 | # define I2C1_OPMODE OPMODE_I2C |
| @@ -62,14 +76,6 @@ | |||
| 62 | # define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */ | 76 | # define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */ |
| 63 | # endif | 77 | # endif |
| 64 | #else | 78 | #else |
| 65 | // The default PAL alternate modes are used to signal that the pins are used for I2C | ||
| 66 | # ifndef I2C1_SCL_PAL_MODE | ||
| 67 | # define I2C1_SCL_PAL_MODE 4 | ||
| 68 | # endif | ||
| 69 | # ifndef I2C1_SDA_PAL_MODE | ||
| 70 | # define I2C1_SDA_PAL_MODE 4 | ||
| 71 | # endif | ||
| 72 | |||
| 73 | // The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock | 79 | // The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock |
| 74 | // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html | 80 | // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html |
| 75 | # ifndef I2C1_TIMINGR_PRESC | 81 | # ifndef I2C1_TIMINGR_PRESC |
