MityDSP Documentation Index
tcDspI2c2

Introduction

The tcDspI2c2 class is used to provide a consistent method to access devices via an instance of the MityDSP I2C (version 2) bus. Although tcDspI2c2 may be used directly by applications, it is usually used by higher-level classes to provide access to a specific device.

An instance of the tcDspI2c2 class is created by specifying the firmware base address of the core and the interrupt level used. This core supports specifying a level of gnAutoLevel, which automatically installs a vectored interrupt.

See also:
MityDSP::tcDspInterruptDispatch Class Reference
MityDSP::tcDspI2c2 Class Reference

Example

This is a simple example of tcDspI2cs creation and usage:

{
SEM_handle MyClass::myDoneFlag;
tcDspI2cs *MyClass::myI2cs;
void MyClass::doSomething(void)
{
int i;
unsigned char writedata[5] = { 0x03, 0xDE, 0xAD, 0xBE, 0xEF };
unsigned char readdata[4];
unsigned int my_base_addr = 0xB0000200;
// Assume device is EEPROM, a 7 bit slave device with 1 byte
// subaddressing (the EPROM ADDRESS)
unsigned char mySlave = 0x50;
// create access to the I2C
myI2c = new tcDspI2c2((void *)my_base_addr);
// write data sequence (4 bytes to offset 0x3 of EEPROM)
// DATA (Sender) (Bits)
// Start (MityDSP) (1)
// SlaveAddr (MityDSP) (7)
// W (MityDSP) (1)
// Ack (Slave ) (1)
// 0x03 (MityDSP) (8)
// Ack (Slave ) (1)
// 0xDE (MityDSP) (8)
// Ack (Slave ) (1)
// 0xAD (MityDSP) (8)
// Ack (Slave ) (1)
// 0xBE (MityDSP) (8)
// Ack (Slave ) (1)
// 0xEF (MityDSP) (8)
// Ack (Slave ) (1)
// Stop (MityDSP) (1)
myI2c->write(mySlave, writedata, 5);
// Perform an addressed read from offset 0x3
// DATA (Sender) (Bits)
// Start (MityDSP) (1)
// SlaveAddr (MityDSP) (7)
// W (MityDSP) (1)
// Ack (Slave ) (1)
// 0x03 (MityDSP) (8)
// Ack (Slave ) (1)
// Start (MityDSP) (1)
// SlaveAddr (MityDSP) (7)
// R (MityDSP) (1)
// Ack (Slave ) (1)
// 0xDE (Slave ) (8)
// Ack (MityDSP) (1)
// 0xAD (Slave ) (8)
// Ack (MityDSP) (1)
// 0xBE (Slave ) (8)
// Ack (MityDSP) (1)
// 0xEF (Slave ) (8)
// NAck (MityDSP) (1)
// Stop (MityDSP) (1)
myI2c->write_read(mySlave, writedata, 1, readdata, 4);
// read the next four bytes (don't reset the address)
myI2c->read(mySlave, slaveWord, 4);
}
}

  
Generated on Mon Apr 22 2013 11:33:02 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.