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

STM32: I2C peripheral is not reset #945

Open
ser-plu opened this issue Jan 17, 2023 · 3 comments
Open

STM32: I2C peripheral is not reset #945

ser-plu opened this issue Jan 17, 2023 · 3 comments

Comments

@ser-plu
Copy link

ser-plu commented Jan 17, 2023

On I2cMaster::reset there is no actual reset of the I2C peripheral.
If there are some connectivity problems with I2C lines, this could lead, that no event is generated, transaction is not finished and peripheral stays in hanging state.

I think, resetting peripheral needs to be added to the reset routine.

  I2C2->CR1 &= ~I2C_CR1_PE;
  modm::delay(5us);
  I2C2->CR1 |= I2C_CR1_PE;
@salkinium
Copy link
Member

Yeah, fair point. I think the logic was to not have to initialize the hardware again, but it's weird semantic. I would rename the reset() method to disable(), since it makes clear that you need to initialize the peripheral again.

@ser-plu
Copy link
Author

ser-plu commented Jan 18, 2023

Then an additional API to actually reinit peripheral is required.

@salkinium
Copy link
Member

salkinium commented Jan 18, 2023

Well, you would need to call the initialize() function again. It circumvents the semantic ambiguity of what exactly is reset, by simply disabling the whole thing and then you need to initialize it fully again. It's a bit of a big hammer, but it's pretty clear what it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants