| 34 | |
| 35 | #if defined(ESP8266) || defined(ESP32) |
| 36 | bool MCP23008::begin(const uint8_t dataPin, const uint8_t clockPin) |
| 37 | { |
| 38 | _wire = &Wire; |
| 39 | _wire->begin(dataPin, clockPin); |
| 40 | // check connected |
| 41 | if (! isConnected()) return false; |
| 42 | // disable address increment (datasheet) |
| 43 | if (! writeReg(MCP23008_IOCR, 0b00100000)) return false; |
| 44 | // Force INPUT_PULLUP |
| 45 | if (! writeReg(MCP23008_PUR_A, 0xFF)) return false; |
| 46 | return true; |
| 47 | } |
| 48 | #endif |
| 49 | |
| 50 |