From f6e5a8cb2a9840840239006fd7649f56cab02d02 Mon Sep 17 00:00:00 2001 From: pawel3410 Date: Fri, 16 Sep 2022 03:19:41 +0200 Subject: [PATCH] Fix mcp23s17 addressing beyond 3 (#3797) --- esphome/components/mcp23s17/mcp23s17.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/esphome/components/mcp23s17/mcp23s17.cpp b/esphome/components/mcp23s17/mcp23s17.cpp index 2fc9c74634..ca4c28e0b4 100644 --- a/esphome/components/mcp23s17/mcp23s17.cpp +++ b/esphome/components/mcp23s17/mcp23s17.cpp @@ -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_);