public MCP23017(byte address = 0x20) { i2cDevice = new NetduinoI2CDevice(address); // set the defaults i2cDevice.WriteRegister((byte)Command.MCP23017_IODIRA, 0xff); i2cDevice.WriteRegister((byte)Command.MCP23017_IODIRB, 0xff); }
public MCP23017(byte address = 0x20) { i2cDevice = new NetduinoI2CDevice(address); // set the defaults i2cDevice.WriteRegister((byte)Command.MCP23017_IODIRA, 0xff); i2cDevice.WriteRegister((byte)Command.MCP23017_IODIRB, 0xff); //The below were added in order to read the interrupt from the chip. //i2cDevice configuration register // mirror interrupts, disable sequential mode i2cDevice.WriteRegister((byte)Command.MCP23017_IOCONA, 0x60); // 0b01100000 (binary) = ox60 (hexadecimal) // enable pull-up on switches i2cDevice.WriteRegister((byte)Command.MCP23017_GPPUA, 0xff); // pull-up resistor for switch - both ports // invert polarity i2cDevice.WriteRegister((byte)Command.MCP23017_IPOLA, 0xff); // invert polarity of signal - both ports // enable all interrupts. This one is what needs to be enabled for the data to flow to the pin... i2cDevice.WriteRegister((byte)Command.MCP23017_GPINTENA, 0xff); //i2cDevice.WriteRegister((byte)0x12, 0xff); }