From 9f748c7950d5f4445f27ba700a6e3349c7a5b6c3 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 14 Jul 2021 23:38:50 +0200 Subject: [PATCH] Fix cambus getting stuck sometimes after failed scan. * This seems to only affect the H7. * After a failed scan the bus can get stuck. Re-initializing the bus fixes it, but it seems disabling and re-enabling the bus is all that's needed. --- src/omv/ports/stm32/cambus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/omv/ports/stm32/cambus.c b/src/omv/ports/stm32/cambus.c index 49a459868..f5c62bc63 100644 --- a/src/omv/ports/stm32/cambus.c +++ b/src/omv/ports/stm32/cambus.c @@ -264,7 +264,13 @@ int cambus_scan(cambus_t *bus) return (addr << 1); } } - + #if defined(STM32H7) + // After a failed scan the bus can get stuck. Re-initializing the bus fixes + // it, but it seems disabling and re-enabling the bus is all that's needed. + __HAL_I2C_DISABLE(bus->i2c); + mp_hal_delay_ms(10); + __HAL_I2C_ENABLE(bus->i2c); + #endif return 0; }