From 69ed626ca0302437ba70a655d0ac05fa5a70c77e Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Wed, 20 Mar 2024 16:06:54 +0100 Subject: [PATCH] fix(core): slowdown i2c on u5 to 200kHz [no changelog] --- core/embed/trezorhal/stm32u5/i2c.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/embed/trezorhal/stm32u5/i2c.c b/core/embed/trezorhal/stm32u5/i2c.c index 796433b1a6..764b71e873 100644 --- a/core/embed/trezorhal/stm32u5/i2c.c +++ b/core/embed/trezorhal/stm32u5/i2c.c @@ -60,8 +60,12 @@ i2c_instance_t i2c_defs[I2C_COUNT] = { * Using calculation from STM32CubeMX * PCLKx as source, assumed 160MHz * Fast mode, freq = 400kHz, Rise time = 250ns, Fall time = 100ns + * Fast mode, freq = 200kHz, Rise time = 250ns, Fall time = 100ns + * SCLH and SCLL are manually modified to achieve more symmetric clock */ -#define I2C_TIMING_400000_Hz 0x30D2153A +#define I2C_TIMING_400000_Hz 0x30D22728 +#define I2C_TIMING_200000_Hz 0x30D2595A +#define I2C_TIMING I2C_TIMING_200000_Hz void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) { if (i2c_handle[idx].Instance) { @@ -86,7 +90,7 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) { HAL_GPIO_Init(instance->SdaPort, &GPIO_InitStructure); i2c_handle[idx].Instance = instance->Instance; - i2c_handle[idx].Init.Timing = I2C_TIMING_400000_Hz; + i2c_handle[idx].Init.Timing = I2C_TIMING; i2c_handle[idx].Init.OwnAddress1 = 0xFE; // master i2c_handle[idx].Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; i2c_handle[idx].Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;