NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
SoftI2cMaster Class Reference

This class implements software i2c interface used by NXShield on Arduino. More...

#include <SoftI2cMaster.h>

Inheritance diagram for SoftI2cMaster:
NXShieldI2C NXTUS AbsoluteIMU ACCLNx AngleSensor CurrentMeter DISTNx EV3SensorAdapter LineLeader MagicWand NumericPad NXShieldBank NXTCam NXTHID NXTMMX NXTPowerMeter NXTServo PFMate PiLight PSPNx RTC VoltMeter

Public Member Functions

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=NULL, uint8_t sdaPin=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

uint8_t * _so_buffer
 

Detailed Description

This class implements software i2c interface used by NXShield on Arduino.

Constructor & Destructor Documentation

SoftI2cMaster::SoftI2cMaster ( uint8_t  devAddr)

class constructor supplies the device address

Member Function Documentation

bool SoftI2cMaster::checkAddress ( )

this function checks to see if there is any device at its specified address

char * SoftI2cMaster::getDeviceID ( )

get the name of the device

char * SoftI2cMaster::getFirmwareVersion ( )

get the version of the firmware

char * SoftI2cMaster::getVendorID ( )

get the name of the vendor

uint8_t SoftI2cMaster::getWriteErrorCode ( )

Get error of last i2c operation

void SoftI2cMaster::initProtocol ( uint8_t  sclPin = NULL,
uint8_t  sdaPin = NULL 
)

init bus custom scl and sda pins are optional

uint8_t SoftI2cMaster::read ( uint8_t  last)

read a byte and send Ack if last is false else Nak to terminate read

uint8_t SoftI2cMaster::readByte ( uint8_t  location)

read one byte starting at the location

int16_t SoftI2cMaster::readInteger ( uint8_t  location)

read two bytes and parse as an integer starting at the location

uint32_t SoftI2cMaster::readLong ( uint8_t  location)

read and parse as integer type long at the location

uint8_t * SoftI2cMaster::readRegisters ( uint8_t  startRegister,
uint8_t  bytes,
uint8_t *  buf = NULL 
)

read number of bytes from start register and return values; optional buffer

char * SoftI2cMaster::readString ( uint8_t  startRegister,
uint8_t  bytes,
uint8_t *  buf = NULL,
uint8_t  len = 0 
)

read specified number of bytes starting at the startRegister

uint8_t SoftI2cMaster::restart ( uint8_t  addressRW)

issue stop condition, pull down scl, and start again

bool SoftI2cMaster::setAddress ( uint8_t  address)
set the i2c address for this device 
Parameters
addressnew device address.
uint8_t SoftI2cMaster::start ( uint8_t  addressRW)

issue a start condition for i2c address with read/write bit

void SoftI2cMaster::stop ( void  )

issue a stop condition

uint8_t SoftI2cMaster::write ( uint8_t  b)

write byte and return true for Ack or false for Nak

bool SoftI2cMaster::writeByte ( uint8_t  location,
uint8_t  data 
)

write one byte starting at the specified register location

bool SoftI2cMaster::writeInteger ( uint8_t  location,
uint16_t  data 
)

write integer starting at the specified register location

bool SoftI2cMaster::writeLong ( uint8_t  location,
uint32_t  data 
)

write integer type long starting at the specified register location

bool SoftI2cMaster::writeRegisters ( uint8_t  location,
uint8_t  bytes_to_write,
uint8_t *  buffer = 0 
)

write bytes starting at the specified register location

bool SoftI2cMaster::writeRegistersWithLocation ( int  bytes,
uint8_t *  buf 
)

write number of bytes from buffer

Member Data Documentation

uint8_t* SoftI2cMaster::_so_buffer

internal buffer


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