mirror of
https://github.com/esphome/esphome.git
synced 2024-11-14 11:08:10 +01:00
mcp23017: read output latch registers during setup (#3744)
This commit is contained in:
parent
84bac8356a
commit
b2199d5464
5 changed files with 18 additions and 0 deletions
|
@ -14,6 +14,9 @@ void MCP23008::setup() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read current output register state
|
||||||
|
this->read_reg(mcp23x08_base::MCP23X08_OLAT, &this->olat_);
|
||||||
|
|
||||||
if (this->open_drain_ints_) {
|
if (this->open_drain_ints_) {
|
||||||
// enable open-drain interrupt pins, 3.3V-safe
|
// enable open-drain interrupt pins, 3.3V-safe
|
||||||
this->write_reg(mcp23x08_base::MCP23X08_IOCON, 0x04);
|
this->write_reg(mcp23x08_base::MCP23X08_IOCON, 0x04);
|
||||||
|
|
|
@ -15,6 +15,10 @@ void MCP23016::setup() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read current output register state
|
||||||
|
this->read_reg_(MCP23016_OLAT0, &this->olat_0_);
|
||||||
|
this->read_reg_(MCP23016_OLAT1, &this->olat_1_);
|
||||||
|
|
||||||
// all pins input
|
// all pins input
|
||||||
this->write_reg_(MCP23016_IODIR0, 0xFF);
|
this->write_reg_(MCP23016_IODIR0, 0xFF);
|
||||||
this->write_reg_(MCP23016_IODIR1, 0xFF);
|
this->write_reg_(MCP23016_IODIR1, 0xFF);
|
||||||
|
|
|
@ -14,6 +14,10 @@ void MCP23017::setup() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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_);
|
||||||
|
|
||||||
if (this->open_drain_ints_) {
|
if (this->open_drain_ints_) {
|
||||||
// enable open-drain interrupt pins, 3.3V-safe
|
// enable open-drain interrupt pins, 3.3V-safe
|
||||||
this->write_reg(mcp23x17_base::MCP23X17_IOCONA, 0x04);
|
this->write_reg(mcp23x17_base::MCP23X17_IOCONA, 0x04);
|
||||||
|
|
|
@ -23,6 +23,9 @@ void MCP23S08::setup() {
|
||||||
this->transfer_byte(0b00011000); // Enable HAEN pins for addressing
|
this->transfer_byte(0b00011000); // Enable HAEN pins for addressing
|
||||||
this->disable();
|
this->disable();
|
||||||
|
|
||||||
|
// Read current output register state
|
||||||
|
this->read_reg(mcp23x08_base::MCP23X08_OLAT, &this->olat_);
|
||||||
|
|
||||||
if (this->open_drain_ints_) {
|
if (this->open_drain_ints_) {
|
||||||
// enable open-drain interrupt pins, 3.3V-safe
|
// enable open-drain interrupt pins, 3.3V-safe
|
||||||
this->write_reg(mcp23x08_base::MCP23X08_IOCON, 0x04);
|
this->write_reg(mcp23x08_base::MCP23X08_IOCON, 0x04);
|
||||||
|
|
|
@ -23,6 +23,10 @@ void MCP23S17::setup() {
|
||||||
this->transfer_byte(0b00011000); // Enable HAEN pins for addressing
|
this->transfer_byte(0b00011000); // Enable HAEN pins for addressing
|
||||||
this->disable();
|
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_);
|
||||||
|
|
||||||
if (this->open_drain_ints_) {
|
if (this->open_drain_ints_) {
|
||||||
// enable open-drain interrupt pins, 3.3V-safe
|
// enable open-drain interrupt pins, 3.3V-safe
|
||||||
this->write_reg(mcp23x17_base::MCP23X17_IOCONA, 0x04);
|
this->write_reg(mcp23x17_base::MCP23X17_IOCONA, 0x04);
|
||||||
|
|
Loading…
Reference in a new issue