Skip to content

Commit

Permalink
Merge pull request #13173 from jeromecoutant/PR_I2C_L4R
Browse files Browse the repository at this point in the history
STM32L4: I2C init parameters for L4+ MCU
  • Loading branch information
0xc0170 committed Jul 1, 2020
2 parents 9ad4aa5 + 0d277ee commit 0e225f9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions targets/TARGET_STM/TARGET_STM32L4/i2c_device.h
Expand Up @@ -31,6 +31,7 @@
#define MBED_I2C_DEVICE_H

#include "cmsis.h"
#include "mbed_error.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 0e225f9

Please sign in to comment.