From 0d277eefe4360e86400152c8c3ff0b9411f0dea9 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Tue, 23 Jun 2020 10:05:24 +0200 Subject: [PATCH] STM32L4: I2C init parameters for L4+ MCU --- targets/TARGET_STM/TARGET_STM32L4/i2c_device.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/targets/TARGET_STM/TARGET_STM32L4/i2c_device.h b/targets/TARGET_STM/TARGET_STM32L4/i2c_device.h index a575269ad5d..7ad782baa76 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/i2c_device.h +++ b/targets/TARGET_STM/TARGET_STM32L4/i2c_device.h @@ -31,6 +31,7 @@ #define MBED_I2C_DEVICE_H #include "cmsis.h" +#include "mbed_error.h" #ifdef __cplusplus extern "C" { @@ -82,6 +83,23 @@ static inline uint32_t get_i2c_timing(int hz) default: break; } + } else if (SystemCoreClock == 120000000) { + // Common settings: I2C clock = 120 MHz, Analog filter = ON, Digital filter coefficient = 0 + switch (hz) { + case 100000: + tim = 0x107075B0; // Standard mode with Rise Time = 400ns and Fall Time = 100ns + break; + case 400000: + tim = 0x00501E6C; // Fast mode with Rise Time = 250ns and Fall Time = 100ns + break; + case 1000000: + tim = 0x00200A26; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns + break; + default: + break; + } + } else { + error("get_i2c_timing error\n"); } return tim; }