aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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