Skip to content

Commit

Permalink
fix(core): slowdown i2c on u5 to 200kHz
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
TychoVrahe committed Apr 3, 2024
1 parent a1165d9 commit d2aa227
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/embed/trezorhal/stm32u5/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit d2aa227

Please sign in to comment.