| EVShield v1.3 EVShield Library Reference by mindsensors.com

Public Member Functions | Public Attributes | List of all members
EVShieldI2C Class Reference

This class implements I2C interfaces used by EVShield. More...

`#include <EVShieldI2C.h>`

Inheritance diagram for EVShieldI2C:

## Public Member Functions
| EVShieldI2C (uint8_t i2c_address)
void | init (void *shield, SH_BankPort bp)
uint8_t | readByte (uint8_t location)
uint16_t | readInteger (uint8_t location)
uint32_t | readLong (uint8_t location)
uint8_t * | readRegisters (uint8_t start_register, uint8_t bytes, uint8_t *buf)
char * | readString (uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
bool | writeRegisters (uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
bool | writeByte (uint8_t location, uint8_t data)
bool | writeInteger (uint8_t location, uint16_t data)
bool | writeLong (uint8_t location, uint32_t data)
char * | getFirmwareVersion ()
char * | getVendorID ()
char * | getDeviceID ()
char * | getFeatureSet ()
uint8_t | getErrorCode ()
bool | checkAddress ()
bool | setAddress (uint8_t address)
Public Member Functions inherited from BaseI2CDevice
| BaseI2CDevice (uint8_t i2c_address)
void | initProtocol ()
uint8_t * | readRegisters (uint8_t start_register, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0, bool clear_buffer=false)
uint8_t | readByte (uint8_t location)
int16_t | readInteger (uint8_t location)
uint32_t | readLong (uint8_t location)
char * | readString (uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
bool | writeRegisters (uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
bool | writeByte (uint8_t location, uint8_t data)
bool | writeInteger (uint8_t location, uint16_t data)
bool | writeLong (uint8_t location, uint32_t data)
bool | checkAddress ()
bool | setAddress (uint8_t i2c_address)
uint8_t | getAddress ()
uint8_t | getWriteErrorCode ()
char * | getFirmwareVersion ()
char * | getVendorID ()
char * | getDeviceID ()
char * | getFeatureSet ()
Public Member Functions inherited from SoftI2cMaster
uint8_t | start (uint8_t addressRW)
void | stop (void)
uint8_t | restart (uint8_t addressRW)
uint8_t | write (uint8_t b)
uint8_t | read (uint8_t last)
| SoftI2cMaster (uint8_t devAddr)
void | initProtocol (uint8_t sclPin=(uint8_t) NULL, uint8_t sdaPin=(uint8_t) NULL)
uint8_t * | readRegisters (uint8_t startRegister, uint8_t bytes, uint8_t *buf=NULL)
bool | writeRegistersWithLocation (int bytes, uint8_t *buf)
bool | writeRegisters (uint8_t location, uint8_t bytes_to_write, uint8_t *buffer=0)
bool | writeByte (uint8_t location, uint8_t data)
bool | writeInteger (uint8_t location, uint16_t data)
bool | writeLong (uint8_t location, uint32_t data)
char * | readString (uint8_t startRegister, uint8_t bytes, uint8_t *buf=NULL, uint8_t len=0)
uint8_t | readByte (uint8_t location)
int16_t | readInteger (uint8_t location)
uint32_t | readLong (uint8_t location)
char * | getFirmwareVersion ()
char * | getVendorID ()
char * | getDeviceID ()
uint8_t | getWriteErrorCode ()
bool | checkAddress ()
bool | setAddress (uint8_t address)

## Public Attributes
void * | mp_shield
uint8_t * | _i2c_buffer
uint8_t | m_protocol
Public Attributes inherited from SoftI2cMaster
uint8_t * | _so_buffer

## Additional Inherited Members
Static Public Attributes inherited from BaseI2CDevice
static uint8_t * | _buffer = 0
static bool | b_initialized = false
Protected Member Functions inherited from BaseI2CDevice
void | setWriteErrorCode (uint8_t code)

## Detailed Description

This class implements I2C interfaces used by EVShield.

## Constructor & Destructor Documentation

## § EVShieldI2C()

EVShieldI2C::EVShieldI2C | ( | uint8_t | i2c_address | ) |

Class constructor for the EVShieldI2C; derived from both BaseI2CDevice and SoftI2cMaster; i2c address must be passed as a parameter

## Member Function Documentation

## § getDeviceID()

char * EVShieldI2C::getDeviceID | ( |  | ) |

get the name of the device

## § getErrorCode()

uint8_t EVShieldI2C::getErrorCode | ( |  | ) |

get the error code of last i2c operation

## § getFeatureSet()

char * EVShieldI2C::getFeatureSet | ( |  | ) |

get the features the device is capable of; only supported by some devices

## § getFirmwareVersion()

char * EVShieldI2C::getFirmwareVersion | ( |  | ) |

get the firmware version of the device

## § getVendorID()

char * EVShieldI2C::getVendorID | ( |  | ) |

get the name of the vendor of the device

## § init()

void EVShieldI2C::init | ( | void * | shield,
|  | SH_BankPort | bp
| ) |  |

initialized this i2c address with a pointer to the EVShield and the bankport it is connected to

## § readByte()

uint8_t EVShieldI2C::readByte | ( | uint8_t | location | ) |

Read a byte from specified location

Parameters

  location | address to read at

Returns
  a byte value read from the location

## § readInteger()

uint16_t EVShieldI2C::readInteger | ( | uint8_t | location | ) |

Read an integer from specified location. Integer comprises of 2 bytes.

Parameters

  location | address to read at

Returns
  an integer value read from the location

## § readLong()

uint32_t EVShieldI2C::readLong | ( | uint8_t | location | ) |

Read a long from specified location. Long comprises of 4 bytes.

Parameters

  location | address to read at

Returns
  a long value read from the location

## § readRegisters()

uint8_t * EVShieldI2C::readRegisters | ( | uint8_t | start_register,
|  | uint8_t | bytes,
|  | uint8_t * | buf
| ) |  |

read the specified number of bytes from the buffer starting from the specified start register

Parameters

  start_register | location to start reading from
  bytes | Number of bytes to read
  buf | buffer to read the data into

Returns
  the character array that was read.

## § readString()

char * EVShieldI2C::readString | ( | uint8_t | location,
|  | uint8_t | bytes_to_read,
|  | uint8_t * | buffer = `0`,
|  | uint8_t | buffer_length = `0`
| ) |  |

Read a string from specified location

Parameters

  location | address to read at
  bytes_to_read | number of bytes to read
  buffer | optional, a buffer to read the data into.
  buffer_length | optional, length of the buffer supplied.

Returns
  a char array read from the location

## § setAddress()

bool EVShieldI2C::setAddress | ( | uint8_t | address | ) |

set the i2c address for this device

Parameters

  address | new device address.

## § writeByte()

bool EVShieldI2C::writeByte | ( | uint8_t | location,
|  | uint8_t | data
| ) |  |

write one byte to the specified register location

Parameters

  location | location to write to.
  data | the data to write.

## § writeInteger()

bool EVShieldI2C::writeInteger | ( | uint8_t | location,
|  | uint16_t | data
| ) |  |

write two bytes (int) to the specified register location

Parameters

  location | location to write to.
  data | the data to write.

## § writeLong()

bool EVShieldI2C::writeLong | ( | uint8_t | location,
|  | uint32_t | data
| ) |  |

write four bytes (long) to the specified register location

Parameters

  location | location to write to.
  data | the data to write.

## § writeRegisters()

bool EVShieldI2C::writeRegisters | ( | uint8_t | start_register,
|  | uint8_t | bytes_to_write,
|  | uint8_t * | buffer = `0`
| ) |  |

write data bytes to the i2c device starting from the start register

Parameters

  start_register | location to write at.
  bytes_to_write | Number of bytes to write
  buffer | (optional) data buffer, if not supplied, data from internal buffer is used.

## Member Data Documentation

## § _i2c_buffer

uint8_t* EVShieldI2C::_i2c_buffer

Pointer to internal i2c buffer

## § m_protocol

uint8_t EVShieldI2C::m_protocol

global variable of the i2c protocol used

## § mp_shield

void* EVShieldI2C::mp_shield

Pointer to the EVShield

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

- C:/Program Files (x86)/Arduino-1.6.12/libraries/EVShield/EVShieldI2C.h
- C:/Program Files (x86)/Arduino-1.6.12/libraries/EVShield/EVShieldI2C.cpp