Repository navigation
Fix PI4IOE5V6408 initialization and checked input reads - #402
Merged
Merged
Conversation
begin() never set the initialized flag, so isEnabled() always returned false. It now records whether the device ID register could be read (and is non-zero) on every call, so a changed port or address is checked again. getInputLevel() was not overridden and always reported failure. It now reads the input status register (0x0F) with error checking and leaves the output untouched on failure, matching M5IOE1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
begin()never set the initialized flag, soisEnabled()always returnedfalsefor a PI4IOE5V6408. It now records whether the device ID register (0x01) could be read and is non-zero. The check runs on every call, so a changed port or address is probed again.getInputLevel()was not overridden, so it always reported a failure. It now reads the input status register (0x0F) with error checking, the same way asM5IOE1_Class. On an invalid pin, a null pointer or an I2C failure it returnsfalseand leaves*leveluntouched.Other methods are unchanged.
Checked
isEnabled(),begin(), andgetInputLevel()compared withdigitalRead()on all 8 pins, plus an invalid pin and a null pointer.isEnabled()afterM5.begin()falsetruegetInputLevel(), pins 0-7false(failure) on every pintrue, level equalsdigitalRead()false, output untouchedfalse, output untouched