Fix mcp23s17 addressing beyond 3 (#3797)

This commit is contained in:
pawel3410 2022-09-16 03:19:41 +02:00 committed by GitHub
parent 7a91ca9809
commit f6e5a8cb2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -23,6 +23,13 @@ void MCP23S17::setup() {
this->transfer_byte(0b00011000); // Enable HAEN pins for addressing
this->disable();
this->enable();
cmd = 0b01001000;
this->transfer_byte(cmd);
this->transfer_byte(mcp23x17_base::MCP23X17_IOCONA);
this->transfer_byte(0b00011000); // Enable HAEN pins for addressing
this->disable();
// Read current output register state
this->read_reg(mcp23x17_base::MCP23X17_OLATA, &this->olat_a_);
this->read_reg(mcp23x17_base::MCP23X17_OLATB, &this->olat_b_);