aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2018-03-19 15:09:00 +0200
committerDamien George <damien.p.george@gmail.com>2018-03-20 23:25:01 +1100
commit24a9facd897bd8727dc7fc05bdb7a36d5232316e (patch)
tree52ff4082d532b77050ab758699dc4e0a74f46ddc
parent2ebc538d63fedcddf89d8c9f0e86b2bb00ff164d (diff)
stm32/i2c: Add H7 I2C timing configurations.
Found the timing for full (400 KHz) and FM+ (1MHz) in the HAL examples, and used CubeMX to calculate the standard value (100KHz).
-rw-r--r--ports/stm32/i2c.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/ports/stm32/i2c.c b/ports/stm32/i2c.c
index f072a75b8..e17472cb4 100644
--- a/ports/stm32/i2c.c
+++ b/ports/stm32/i2c.c
@@ -131,9 +131,9 @@ const pyb_i2c_obj_t pyb_i2c_obj[] = {
#endif
};
-#if defined(STM32F7) || defined(STM32L4)
+#if defined(STM32F7) || defined(STM32L4) || defined(STM32H7)
-// The STM32F0, F3, F7 and L4 use a TIMINGR register rather than ClockSpeed and
+// The STM32F0, F3, F7, H7 and L4 use a TIMINGR register rather than ClockSpeed and
// DutyCycle.
#if defined(STM32F746xx)
@@ -161,6 +161,17 @@ const pyb_i2c_obj_t pyb_i2c_obj[] = {
#define MICROPY_HW_I2C_BAUDRATE_DEFAULT (PYB_I2C_SPEED_FULL)
#define MICROPY_HW_I2C_BAUDRATE_MAX (PYB_I2C_SPEED_FAST)
+#elif defined(STM32H7)
+
+// I2C TIMINGs obtained from the STHAL examples.
+#define MICROPY_HW_I2C_BAUDRATE_TIMING { \
+ {PYB_I2C_SPEED_STANDARD, 0x40604E73}, \
+ {PYB_I2C_SPEED_FULL, 0x00901954}, \
+ {PYB_I2C_SPEED_FAST, 0x10810915}, \
+ }
+#define MICROPY_HW_I2C_BAUDRATE_DEFAULT (PYB_I2C_SPEED_FULL)
+#define MICROPY_HW_I2C_BAUDRATE_MAX (PYB_I2C_SPEED_FAST)
+
#elif defined(STM32L4)
// The value 0x90112626 was obtained from the DISCOVERY_I2C1_TIMING constant