Skip to content

Commit 63d3096

Browse files
committed
feat(wire): disable clock when deinit
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent b149a92 commit 63d3096

File tree

1 file changed

+43
-0
lines changed
  • libraries/Wire/src/utility

1 file changed

+43
-0
lines changed

libraries/Wire/src/utility/twi.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,49 @@ void i2c_deinit(i2c_t *obj)
804804
HAL_NVIC_DisableIRQ(obj->irqER);
805805
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
806806
HAL_I2C_DeInit(&(obj->handle));
807+
// Reset I2Cx and disable clock
808+
#if defined I2C1_BASE
809+
if (obj->i2c == I2C1) {
810+
__HAL_RCC_I2C1_FORCE_RESET();
811+
__HAL_RCC_I2C1_RELEASE_RESET();
812+
__HAL_RCC_I2C1_CLK_DISABLE();
813+
}
814+
#endif // I2C1_BASE
815+
#if defined I2C2_BASE
816+
if (obj->i2c == I2C2) {
817+
__HAL_RCC_I2C2_FORCE_RESET();
818+
__HAL_RCC_I2C2_RELEASE_RESET();
819+
__HAL_RCC_I2C2_CLK_DISABLE();
820+
}
821+
#endif // I2C2_BASE
822+
#if defined I2C3_BASE
823+
if (obj->i2c == I2C3) {
824+
__HAL_RCC_I2C3_FORCE_RESET();
825+
__HAL_RCC_I2C3_RELEASE_RESET();
826+
__HAL_RCC_I2C3_CLK_DISABLE();
827+
}
828+
#endif // I2C3_BASE
829+
#if defined I2C4_BASE
830+
if (obj->i2c == I2C4) {
831+
__HAL_RCC_I2C4_FORCE_RESET();
832+
__HAL_RCC_I2C4_RELEASE_RESET();
833+
__HAL_RCC_I2C4_CLK_DISABLE();
834+
}
835+
#endif // I2C4_BASE
836+
#if defined I2C5_BASE
837+
if (obj->i2c == I2C5) {
838+
__HAL_RCC_I2C5_FORCE_RESET();
839+
__HAL_RCC_I2C5_RELEASE_RESET();
840+
__HAL_RCC_I2C5_CLK_DISABLE();
841+
}
842+
#endif // I2C5_BASE
843+
#if defined I2C6_BASE
844+
if (obj->i2c == I2C6) {
845+
__HAL_RCC_I2C6_FORCE_RESET();
846+
__HAL_RCC_I2C6_RELEASE_RESET();
847+
__HAL_RCC_I2C6_CLK_DISABLE();
848+
}
849+
#endif // I2C6_BASE
807850
}
808851

809852
/**

0 commit comments

Comments
 (0)
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