Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wire): disable clock when deinit #2223

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(wire): disable clock when deinit
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
  • Loading branch information
fpistm committed Dec 6, 2023
commit 5c052819483da906437ea03b13c50cef0acd0378
43 changes: 43 additions & 0 deletions libraries/Wire/src/utility/twi.c
Original file line number Diff line number Diff line change
@@ -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
}

/**