code: func (m *MCP23017Driver) WriteGPIO(pin uint8, val uint8, portStr string) (err error) {
  	selectedPort := m.getPort(portStr)
  	// read current value of IODIR register
  	iodir, err := m.read(selectedPort.IODIR)
  	if err != nil {
  		return err
  	}
  	// set pin as output by clearing bit
  	iodirVal := clearBit(iodir, uint8(pin))
  	// write IODIR register bit
  	err = m.write(selectedPort.IODIR, uint8(pin), uint8(iodirVal))
  	if err != nil {
  		return err
  	}
  	// read current value of OLAT register
  	olat, err := m.read(selectedPort.OLAT)
  	if err != nil {
  		return err
  	}
  	// set or clear olat value, 0 is no output, 1 is an output
  	var olatVal uint8
  	if val == 0 {
  		olatVal = clearBit(olat, uint8(pin))
  	} else {
  		olatVal = setBit(olat, uint8(pin))
  	}
  	// write OLAT register bit
  	err = m.write(selectedPort.OLAT, uint8(pin), uint8(olatVal))
  	if err != nil {
  		return err
  	}
  	return nil
  }
docs: // WriteGPIO writes a value to a gpio pin (0-7) and a port (A or B).