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).
@@ -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
