I2CIO Class Reference

## Public Member Functions

| I2CIO ()
int | begin (uint8_t i2cAddr)
void | pinMode (uint8_t pin, uint8_t dir)
void | portMode (uint8_t dir)
uint8_t | read (void)
uint8_t | digitalRead (uint8_t pin)
int | write (uint8_t value)
int | digitalWrite (uint8_t pin, uint8_t level)

## Constructor & Destructor Documentation

I2CIO::I2CIO | ( |  | ) |

Constructor method Class constructor constructor.

## Member Function Documentation

int I2CIO::begin | ( | uint8_t | i2cAddr | ) |

Initializes the device. This method initializes the device allocating an I2C address. This method is the first method that should be call prior to calling any other method form this class. On initialization all pins are configured as INPUT on the device.

Parameters

  i2cAddr | I2C Address where the device is located.

Returns
  1 if the device was initialized correctly, 0 otherwise

uint8_t I2CIO::digitalRead | ( | uint8_t | pin | ) |

Read a pin from the device. Reads a particular pin from the device. To read a particular pin it has to be configured as INPUT. During initialization all pins are configured as INPUTs by default. Please refer to pinMode or portMode.

Parameters

  pin[in] | Pin from the port to read its status. Range (0..7)

Returns
  Returns the pin status (HIGH, LOW) if the pin is configured as an output, reading its value will always return LOW regardless of its real state.

int I2CIO::digitalWrite | ( | uint8_t | pin,
|  | uint8_t | level
| ) |  |

Writes a digital level to a particular pin. Write a level to the indicated pin of the device. For this method to have effect, the pin has to be configured as OUTPUT using the pinMode or portMode methods.

Parameters

  pin[in] | device pin to change level. Range (0..7). level[in] logic level to set the pin at (HIGH, LOW).

Returns
  1 on success, 0 otherwise.

void I2CIO::pinMode | ( | uint8_t | pin,
|  | uint8_t | dir
| ) |  |

Sets the mode of a particular pin. Sets the mode of a particular pin to INPUT, OUTPUT. digitalWrite has no effect on pins which are not declared as output.

Parameters

  pin[in] | Pin from the I2C IO expander to be configured. Range 0..7
  dir[in] | Pin direction (INPUT, OUTPUT).

void I2CIO::portMode | ( | uint8_t | dir | ) |

Sets all the pins of the device in a particular direction. This method sets all the pins of the device in a particular direction. This method is useful to set all the pins of the device to be either inputs or outputs.

Parameters

  dir[in] | Direction of all the pins of the device (INPUT, OUTPUT).

uint8_t I2CIO::read | ( | void |  | ) |

Reads all the pins of the device that are configured as INPUT. Reads from the device the status of the pins that are configured as INPUT. During initialization all pins are configured as INPUTs by default. Please refer to pinMode or portMode.

Parameters

  none |

int I2CIO::write | ( | uint8_t | value | ) |

Write a value to the device. Writes to a set of pins in the device. The value is the binary representation of all the pins in device. The value written is masked with the configuration of the direction of the pins; to change the state of a particular pin with this method, such pin has to be configured as OUTPUT using the portMode or pinMode methods. If no pins have been configured as OUTPUTs this method will have no effect.

Parameters

  value[in] | value to be written to the device.

Returns
  1 on success, 0 otherwise

The documentation for this class was generated from the following files:

- /Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/I2CIO.h
- /Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/I2CIO.cpp