From 6cbaed75c8f938a1dd1ae657b11adaeff7077c3e Mon Sep 17 00:00:00 2001 From: Kenneth Bell Date: Thu, 25 Nov 2021 22:03:55 +0000 Subject: [PATCH] stm32: fix timeout for i2c comms ticks changed to 16ns causing timeouts to be very, very short. This change updates timeouts for 16ns ticks. --- src/machine/machine_stm32_i2c_revb.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/machine/machine_stm32_i2c_revb.go b/src/machine/machine_stm32_i2c_revb.go index aca96240..a265c602 100644 --- a/src/machine/machine_stm32_i2c_revb.go +++ b/src/machine/machine_stm32_i2c_revb.go @@ -1,3 +1,4 @@ +//go:build stm32l5 || stm32f7 || stm32l4 || stm32l0 // +build stm32l5 stm32f7 stm32l4 stm32l0 package machine @@ -27,7 +28,10 @@ const ( const ( MAX_NBYTE_SIZE = 255 - TIMEOUT_TICKS = 100 // 100ms + + // 100ms delay = 100e6ns / 16ns + // In runtime_stm32_timers.go, tick is fixed at 16ns per tick + TIMEOUT_TICKS = 100e6 / 16 I2C_NO_STARTSTOP = 0x0 I2C_GENERATE_START_WRITE = 0x80000000 | stm32.I2C_CR2_START