Skip to content

improve Glitch prevention, Hardware RESET! #25

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

Merged
merged 12 commits into from
Mar 14, 2018

Conversation

stickbreaker
Copy link
Owner

My prior glitch prevention relied on previous pin configuration. This update sets all values.

Also, I think I have found a way to reset the I2C hardware to the same state as a Power Cycle or Hardware reset.

My prior glitch prevention relied on previous pin configuration.  This update sets all values.

Also, I think I have found a way to reset the I2C hardware to the same state as a Power Cycle or Hardware reset.
These changes should remove the possibility of a signal glitch when starting or restarting the Wire() object.

Also, I think I have found a way to reset the i2c hardware to a Power On or Hardware Reset state.
After hardware reset, all i2c hardware register are back to zero, so the clockrate needs to be recovered.
I had manually applied these changes and misspelled two function names!
@stickbreaker stickbreaker changed the title improve Glitch prevention improve Glitch prevention, Hardware RESET! Mar 11, 2018
Continue with I2C transaction if bus_busy is cleared by i2cInit()
`SCL` and `SDA` need to be detached from the i2c hardware before the i2c hardware is init'd else a glitch is generated.  esp32-hal-i2c.c does not know which pins are assigned to the hardware.  Return the error and let `TwoWire()` do the reinit.

Also, '~' is not the same as '!'  

My Bad.
The i2c data bus must be disconnected from the i2c peripheral before it is init'd. Else it will generate a glitch on both pins.  Since the Hal layer does not remember which pins are assigned, just return the error and let `TwoWire()` handle re-initing.
had to move the hardware init code out of begin, so that I could call it without destroying queued transactions
Reinit i2c hardware when bus fault (busy) is detected
@stickbreaker
Copy link
Owner Author

stickbreaker commented Mar 12, 2018

The branch can handle a bus fault, Grounding SDA and or SCL is now recoverable. The signal glitch that was created when attaching pins to the i2c peripheral has now been solved!

A bus_busy status is now auto-magically cleared. When this status is detected upon entry into the hal layer i2cProcQueue(), i2cProcQueue() immediately returns I2C_ERROR_BUSY which cause TwoWire() to attempt to clear the bus, first is re-inits the i2c peripheral(hardware reset!), then it attempts to cycle the i2c bus manually. TwoWire() then retries the transaction once.

This branch should handle both I2C peripherals at the same time, UnTESTED, but, it should work.

@stickbreaker stickbreaker merged commit bb24e52 into master Mar 14, 2018
@stickbreaker stickbreaker deleted the stickbreaker-Busy-Glitch branch March 14, 2018 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant