NXShield
v1.07
NXShield Library Reference by OpenElectrons.com
|
This class implements I2C interfaces used by NXShield. More...
#include <NXShieldI2C.h>
Public Member Functions | |
NXShieldI2C (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=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 | |
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) |
This class implements I2C interfaces used by NXShield.
NXShieldI2C::NXShieldI2C | ( | uint8_t | i2c_address | ) |
Class constructor for the NXShieldI2C; derived from both BaseI2CDevice and SoftI2cMaster; i2c address must be passes as a parameter
char * NXShieldI2C::getDeviceID | ( | ) |
get the name of the device
uint8_t NXShieldI2C::getErrorCode | ( | ) |
get the error code of last i2c operation
char * NXShieldI2C::getFeatureSet | ( | ) |
get the features the device is capable of; only supported by some devices
char * NXShieldI2C::getFirmwareVersion | ( | ) |
get the firmware version of the device
char * NXShieldI2C::getVendorID | ( | ) |
get the name of the vendor of the device
void NXShieldI2C::init | ( | void * | shield, |
SH_BankPort | bp | ||
) |
initialized this i2c address with a pointed to the NXShield and the bankport it is connected to
uint8_t NXShieldI2C::readByte | ( | uint8_t | location | ) |
Read a byte from specified location
location | address to read at |
uint16_t NXShieldI2C::readInteger | ( | uint8_t | location | ) |
Read an integer from specified location. Integer comprises of 2 bytes.
location | address to read at |
uint32_t NXShieldI2C::readLong | ( | uint8_t | location | ) |
Read a long from specified location. Long comprises of 4 bytes.
location | address to read at |
uint8_t * NXShieldI2C::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
start_register | location to start reading from |
bytes | Number of bytes to read |
buf | buffer to read the data into |
char * NXShieldI2C::readString | ( | uint8_t | location, |
uint8_t | bytes_to_read, | ||
uint8_t * | buffer = 0 , |
||
uint8_t | buffer_length = 0 |
||
) |
Read a string from specified location
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. |
bool NXShieldI2C::setAddress | ( | uint8_t | address | ) |
set the i2c address for this device
address | new device address. |
bool NXShieldI2C::writeByte | ( | uint8_t | location, |
uint8_t | data | ||
) |
write one byte to the specified register location
location | location to write to. |
data | the data to write. |
bool NXShieldI2C::writeInteger | ( | uint8_t | location, |
uint16_t | data | ||
) |
write two bytes (int) to the specified register location
location | location to write to. |
data | the data to write. |
bool NXShieldI2C::writeLong | ( | uint8_t | location, |
uint32_t | data | ||
) |
write four bytes (long) to the specified register location
location | location to write to. |
data | the data to write. |
bool NXShieldI2C::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
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. |
uint8_t* NXShieldI2C::_i2c_buffer |
Pointer to internal i2c buffer
uint8_t NXShieldI2C::m_protocol |
global variable of the i2c protocol used
void* NXShieldI2C::mp_shield |
Pointer to the NXShield