| 45 | |
| 46 | #if defined(ESP8266) || defined(ESP32) |
| 47 | bool MCP23017::begin(const uint8_t dataPin, const uint8_t clockPin) |
| 48 | { |
| 49 | _wire = &Wire; |
| 50 | _wire->begin(dataPin, clockPin); |
| 51 | // check connected |
| 52 | if (! isConnected()) return false; |
| 53 | // disable address increment (datasheet) |
| 54 | if (! writeReg(MCP23017_IOCR, 0b00100000)) return false; |
| 55 | // Force INPUT_PULLUP |
| 56 | if (! writeReg(MCP23017_PUR_A, 0xFF)) return false; |
| 57 | if (! writeReg(MCP23017_PUR_B, 0xFF)) return false; |
| 58 | return true; |
| 59 | } |
| 60 | #endif |
| 61 | |
| 62 |