The MCP23017 Class provides a programming interface to the MCP23017 I2C port expander chip.

Constructors
The MCP23017 Class has a single constructor. The constructor takes an optional argument of an I2C address. I2C addresses for the chip are in the range 0x20 to 0x27.
If no argument is provided the constructor configures the class to use the default I2C address of 0x20 for the MCP23017.
The MCP23017 class references the I2CBase class as superclass. The I2C address in the constructor is passed to the superclass
public MCP23017(int addr) public MCP23017(int addr = MCP23017_ADDRESS) :base(addr)
Methods
InitMCP23017Async
This is an asynchronous method whih initializes the I2C interface by calling the I2CBase Class InitI2CAsync method, and sets all MCP23017 GPIO pins to outputs.
public async Task InitMCP23017Async()
pinMode
The PinMode method sets the input/output direction of a single GPIO pin. It takes two arguments, the pin number, andthe direction.
Pin number is an integer in the range 0..15, where pins numbered from 0 to 7 are on Port A, and pins numbered from 8 to 15 are on Port B.
The direction argument is of type Direction, which is an enumeration defined within the class. Defined values are "INPUT" and "OUTPUT"
public enum Direction { INPUT = 0, OUTPUT = 1 }; public void pinMode(int p, Direction d)
pullup
This method sets the pullup state of a single GPIO pin to logical HIGH or LOW. It takes two arguments, a pin number and a logic value.
Pin number is an integer in the range 0..15, where pins numbered from 0 to 7 are on Port A, and pins numbered from 8 to 15 are on Port B.
The logic value argument is of type Level, which is an enumeration defined within the class. Defined values are "LOW" and "HIGH"
public enum Level { LOW = 0, HIGH = 1 }; public void pullUp(int pin, Level d)
digitalWrite
This method sets the state of a single GPIO pin to logical HIGH or LOW. It takes two arguments, a pin number and a logic value.
Pin number is an integer in the range 0..15, where pins numbered from 0 to 7 are on Port A, and pins numbered from 8 to 15 are on Port B.
The logic value argument is of type Level, which is an enumeration defined within the class. Defined values are "LOW" and "HIGH"
public enum Level { LOW = 0, HIGH = 1 }; public void digitalWrite(int pin, Level d)
digitalRead
This method gets the state of a single GPIO pin, and returns it as a logical HIGH or LOW. It takes a single arguments, a pin number.
Pin number is an integer in the range 0..15, where pins numbered from 0 to 7 are on Port A, and pins numbered from 8 to 15 are on Port B.
The return value is of type Level, which is an enumeration defined within the class. Defined values are "LOW" and "HIGH"
public enum Level { LOW = 0, HIGH = 1 }; public Level digitalRead(int pin)
writeGPIOAB
This writeGPIOAB method writes to all pins simultaneously. It takes a single argument, an unsigned 16-bit integer representing a bitmask of the desired logic state for each pin. The LSB corresponds to Port A, pin 0, and the MSB corresponds to Port B, pin 7.
public void writeGPIOAB(UInt16 ba)
readGPIOAB
This readGPIOAB method reads all pins simultaneously. It returns a single value, an unsigned 16-bit integer representing a bitmask of the current logic state for each pin. The LSB corresponds to Port A, pin 0, and the MSB corresponds to Port B, pin 7.
public UInt16 readGPIOAB()
Page last edited September 15, 2016
Text editor powered by tinymce.