From 5c052819483da906437ea03b13c50cef0acd0378 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 6 Dec 2023 15:39:12 +0100 Subject: [PATCH] feat(wire): disable clock when deinit Signed-off-by: Frederic Pillon --- libraries/Wire/src/utility/twi.c | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/libraries/Wire/src/utility/twi.c b/libraries/Wire/src/utility/twi.c index a4a2539f7c..fbaf092550 100644 --- a/libraries/Wire/src/utility/twi.c +++ b/libraries/Wire/src/utility/twi.c @@ -804,6 +804,49 @@ void i2c_deinit(i2c_t *obj) HAL_NVIC_DisableIRQ(obj->irqER); #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */ HAL_I2C_DeInit(&(obj->handle)); + // Reset I2Cx and disable clock +#if defined I2C1_BASE + if (obj->i2c == I2C1) { + __HAL_RCC_I2C1_FORCE_RESET(); + __HAL_RCC_I2C1_RELEASE_RESET(); + __HAL_RCC_I2C1_CLK_DISABLE(); + } +#endif // I2C1_BASE +#if defined I2C2_BASE + if (obj->i2c == I2C2) { + __HAL_RCC_I2C2_FORCE_RESET(); + __HAL_RCC_I2C2_RELEASE_RESET(); + __HAL_RCC_I2C2_CLK_DISABLE(); + } +#endif // I2C2_BASE +#if defined I2C3_BASE + if (obj->i2c == I2C3) { + __HAL_RCC_I2C3_FORCE_RESET(); + __HAL_RCC_I2C3_RELEASE_RESET(); + __HAL_RCC_I2C3_CLK_DISABLE(); + } +#endif // I2C3_BASE +#if defined I2C4_BASE + if (obj->i2c == I2C4) { + __HAL_RCC_I2C4_FORCE_RESET(); + __HAL_RCC_I2C4_RELEASE_RESET(); + __HAL_RCC_I2C4_CLK_DISABLE(); + } +#endif // I2C4_BASE +#if defined I2C5_BASE + if (obj->i2c == I2C5) { + __HAL_RCC_I2C5_FORCE_RESET(); + __HAL_RCC_I2C5_RELEASE_RESET(); + __HAL_RCC_I2C5_CLK_DISABLE(); + } +#endif // I2C5_BASE +#if defined I2C6_BASE + if (obj->i2c == I2C6) { + __HAL_RCC_I2C6_FORCE_RESET(); + __HAL_RCC_I2C6_RELEASE_RESET(); + __HAL_RCC_I2C6_CLK_DISABLE(); + } +#endif // I2C6_BASE } /** pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy