MityDSP Documentation Index
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
MityDSP::tcDspI2c2 Class Reference

Instances of this class handle access to a "generic" implementation of the I2C interface, version 2.0, for the MityDSP. More...

#include <core/DspI2c2.h>

List of all members.

Public Member Functions

 tcDspI2c2 (void *apAddress, int anLevel=gnAutoLevel)
 This constructor is used to open an istance of the DspI2c interface.
virtual ~tcDspI2c2 (void)
 
     This destructor is used to close up and free the resources tied to the 

associated I2C interface.

int smbus_read_byte (unsigned char anSlaveAddr)
 Read a byte from the I2C bus using SMBUS protocol.
int smbus_write_byte (unsigned char anSlaveAddr, unsigned char val)
 Write a byte from the I2C bus using SMBUS protocol.
int smbus_read_byte_data (unsigned char anSlaveAddr, unsigned char reg)
 Read an 8 bit addressed byte from the I2C bus using SMBUS protocol.
int smbus_write_byte_data (unsigned char anSlaveAddr, unsigned char reg, unsigned char val)
 Write an 8-bit addressed byte to an I2C bus using SMBUS protocol.
int smbus_read_word_data (unsigned char anSlaveAddr, unsigned char reg)
 Read an 8 bit addressed byte from the I2C bus using SMBUS protocol.
int smbus_write_word_data (unsigned char anSlaveAddr, unsigned char reg, unsigned short val)
 Write an 8-bit addressed 16 bit word to an I2C bus using SMBUS protocol.
int write_read (unsigned short anSlaveAddr, unsigned char *apWriteBuf, unsigned short anWriteSize, unsigned char *apReadBuf, unsigned short anReadSize, bool ab10BitAddr=false, unsigned int anTimeout=SYS_FOREVER)
 Perform a write/read sequence typically used for sub-addressed reading of devices on an I2C Bus.
int read (unsigned short anSlaveAddr, unsigned char *apBuffer, unsigned short anSize, bool abSendStop=true, bool ab10BitAddr=false, unsigned int anTimeout=SYS_FOREVER)
 Low level I2C read call.
int write (unsigned short anSlaveAddr, unsigned char *apBuffer, unsigned short anSize, bool abSendStop=true, bool ab10BitAddr=false, unsigned int anTimeout=SYS_FOREVER)
 Low level I2C write call.
unsigned int GetClockSpeed (void)
 Get the I2C output clock speed.
unsigned int SetClockSpeed (unsigned int DesiredSpeedHz)
 Set the I2C output clock speed.

Public Attributes

unsigned int mnInterruptCount
 ISR counter (debug).

Static Public Attributes

static const int gnI2C_OK = 0
static const int gnI2C_NO_ACK = -1
static const int gnI2C_NOT_IMPLEMENTED = -2
static const int gnI2C_BUSY = -3

Protected Member Functions

void i2cInterrupt (void)
 Interrupt service routine for the I2C class.

Static Protected Member Functions

static int interrupt_dispatch (Arg arMyObject)
 Static interrupt dispatch routine.

Protected Attributes

unsigned int mnFifoDepth
 depth of firmware FIFO
volatile unsigned int * mpBaseAddr
 firmware base address
unsigned short mnMyIntMask
 core interrupt mask
int mnMyIntLevel
 core interrupt level
int mnMyIntVector
 core interrupt vector
volatile unsigned int mnBuffSize
 size of buffer
volatile unsigned char * mpBuffer
 from application
SEM_Handle mhDoneSem
 ISR to thread notifier.
LCK_Handle mhLock
 serialization of calls

Static Protected Attributes

static unsigned int mnTicksPerSec = (1000 * CLK_countspms()) / CLK_getprd()
 Conversion from low resolution.

Detailed Description

Instances of this class handle access to a "generic" implementation of the I2C interface, version 2.0, for the MityDSP.

See also:
tcDspI2c2 Page

Constructor & Destructor Documentation

tcDspI2c2::tcDspI2c2 ( void *  apAddress,
int  anLevel = gnAutoLevel 
)

This constructor is used to open an istance of the DspI2c interface.

Parameters:
[in]apAddressBase Address of I2C core
[in]anLevelOptional parameter to force a chained interrupt at the specified level.
Returns:
None.
See also:
DspI2c2.h
tcDspI2c2::~tcDspI2c2 ( void  )
virtual

     This destructor is used to close up and free the resources tied to the 

associated I2C interface.

Returns:
None.
See also:
DspI2c2.h

Member Function Documentation

int tcDspI2c2::smbus_read_byte ( unsigned char  anSlaveAddr)

Read a byte from the I2C bus using SMBUS protocol.

Sequence: Start(1), Addr(7), R(1), Ack(1), Data(8), NAck(1), Stop(1)

Note:
this method only supports 7 bit device addressing
Parameters:
anSlaveAddrAddr to transmit (7-bit device address only)
Returns:
value on success (>= 0), or gnI2C_NO_ACK or gnI2C_BUSY
int tcDspI2c2::smbus_write_byte ( unsigned char  anSlaveAddr,
unsigned char  val 
)

Write a byte from the I2C bus using SMBUS protocol.

Transmitted sequence: Start(1), Addr(7), W(1), Ack(1), val(8), Ack(1), Stop(1)

Note:
this method only supports 7 bit device addressing
Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[in]val8 bit value to transmit
Returns:
gnI2C_OK (0), or gnI2C_NO_ACK or gnI2C_BUSY (< 0)
int tcDspI2c2::smbus_read_byte_data ( unsigned char  anSlaveAddr,
unsigned char  reg 
)

Read an 8 bit addressed byte from the I2C bus using SMBUS protocol.

Sequence: Start(1), Addr(7), W(1), Ack(1), Reg(8), Ack(1), ... Start(1), Addr(7), R(1), Ack(1), Data(8), NAck(1), Stop(1)

Note:
this method only supports 7 bit device addressing
Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[in]reg8 bit Register Addr to transmit (7-bit device address only)
Returns:
value on success (>= 0), or gnI2C_NO_ACK or gnI2C_BUSY
int tcDspI2c2::smbus_write_byte_data ( unsigned char  anSlaveAddr,
unsigned char  reg,
unsigned char  val 
)

Write an 8-bit addressed byte to an I2C bus using SMBUS protocol.

Transmitted sequence: Start(1), Addr(7), W(1), Ack(1), reg(8), Ack(1), val(8), Ack(1), Stop(1)

Note:
this method only supports 7 bit device addressing
Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[in]reg8 bit device subaddress
[in]val8 bit value to transmit
Returns:
gnI2C_OK (0), or gnI2C_NO_ACK or gnI2C_BUSY (< 0)
int tcDspI2c2::smbus_read_word_data ( unsigned char  anSlaveAddr,
unsigned char  reg 
)

Read an 8 bit addressed byte from the I2C bus using SMBUS protocol.

Sequence: Start(1), Addr(7), W(1), Ack(1), Reg(8), Ack(1), ... Start(1), Addr(7), R(1), Ack(1), Reg(8), Ack(1), Data[15..8](8), Ack(1), Data[7..0](8), NAck(1), Stop(1)

Note:
this method only supports 7 bit device addressing
Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[in]reg8 bit Register Addr to transmit (7-bit device address only)
Returns:
value on success (>= 0), or gnI2C_NO_ACK or gnI2C_BUSY
int tcDspI2c2::smbus_write_word_data ( unsigned char  anSlaveAddr,
unsigned char  reg,
unsigned short  val 
)

Write an 8-bit addressed 16 bit word to an I2C bus using SMBUS protocol.

Transmitted sequence: Start(1), Addr(7), W(1), Ack(1), reg(8), Ack(1), val[15..8](8), Ack(1), val[7..0](8), Ack(1), Stop(1)

Note:
this method only supports 7 bit device addressing
Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[in]reg8 bit device subaddress
[in]val16 bit value to transmit (data transmitted MSByte, LSByte)
Returns:
gnI2C_OK (0), or gnI2C_NO_ACK or gnI2C_BUSY (< 0)
int tcDspI2c2::write_read ( unsigned short  anSlaveAddr,
unsigned char *  apWriteBuf,
unsigned short  anWriteSize,
unsigned char *  apReadBuf,
unsigned short  anReadSize,
bool  ab10BitAddr = false,
unsigned int  anTimeout = SYS_FOREVER 
)

Perform a write/read sequence typically used for sub-addressed reading of devices on an I2C Bus.

This is equivalent to calling a write() with Stop=False followed by a read() with stop=true.

Transmitted sequence (7-bit mode): Start(1), Addr(7), W(1), Ack(1), apWriteBuf[0](8), Ack(1), ... apWriteBuf[anWriteSize-1](8), Ack(1), Start(1), Addr(7), R(1), Ack(1), ... apReadBuf[0](8), Ack(1), ... apReadBuf[anReadSize-1](8), NAck(1), Stop(1)

Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[in]apWriteBufoutput buffer (typically 1 or 2 bytes containing device subaddress)
[in]anWriteSizenumber of bytes in apWriteBuf to transmit
[out]apReadBufpointer to receive buffer
[in]anReadSizenumber of bytes to read and store in receive buffer
[in]ab10BitAddr(default false), set to true if slave device is 10 bit mode
[in]anTimeoutTime (default SYS_FOREVER) to wait to acquire the device (for threading support)
Returns:
gnI2C_OK, gnI2C_NO_ACK, or gnI2C_BUSY
int tcDspI2c2::read ( unsigned short  anSlaveAddr,
unsigned char *  apBuffer,
unsigned short  anSize,
bool  abSendStop = true,
bool  ab10BitAddr = false,
unsigned int  anTimeout = SYS_FOREVER 
)

Low level I2C read call.

Transmitted sequence (7-bit mode): Start(1), anSlaveAddr(7), R(1), Ack(1), apBuffer[0](8), Ack(1), ... apBuffer[anSize-1](8), NAck(1), Stop(optional)(1)

Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[out]apBufferpointer to receive buffer
[in]anSizenumber of bytes to read and store in receive buffer
[in]abSendStopw(default true), when true a stop bit will be sent
[in]ab10BitAddr(default false), set to true if slave device is 10 bit mode
[in]anTimeoutTime (default SYS_FOREVER) to wait to acquire the device (for threading support)
Returns:
gnI2C_OK, gnI2C_NO_ACK, or gnI2C_BUSY
int tcDspI2c2::write ( unsigned short  anSlaveAddr,
unsigned char *  apBuffer,
unsigned short  anSize,
bool  abSendStop = true,
bool  ab10BitAddr = false,
unsigned int  anTimeout = SYS_FOREVER 
)

Low level I2C write call.

Transmitted sequence (7-bit mode): Start(1), anSlaveAddr(7), W(1), Ack(1), apBuffer[0](8), Ack(1), ... apBuffer[anSize-1](8), Ack(1), Stop(optional)(1)

Parameters:
[in]anSlaveAddrAddr to transmit (7-bit device address only)
[out]apBufferpointer to transmit data buffer
[in]anSizenumber of bytes to transmit from the transmit buffer
[in]abSendStopw(default true), when true a stop bit will be sent
[in]ab10BitAddr(default false), set to true if slave device is 10 bit mode
[in]anTimeoutTime (default SYS_FOREVER) to wait to acquire the device (for threading support)
Returns:
gnI2C_OK, gnI2C_NO_ACK, or gnI2C_BUSY
unsigned int tcDspI2c2::GetClockSpeed ( void  )

Get the I2C output clock speed.

Returns:
the output clock speed in Hz
unsigned int tcDspI2c2::SetClockSpeed ( unsigned int  DesiredSpeedHz)

Set the I2C output clock speed.

Returns:
the actual output clock speed in Hz
int tcDspI2c2::interrupt_dispatch ( Arg  ahMyObject)
staticprotected

Static interrupt dispatch routine.

Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.

Parameters:
[in]ahMyObjectThe "this->" pointer for the instance of tcDspI2c2 associated with this ISR.
Returns:
0
void tcDspI2c2::i2cInterrupt ( void  )
protected

Interrupt service routine for the I2C class.

The ISR reads and clears any pending done interrupt and sets the internal semaphore. If an interrupts callback is registered, the routine is called.

"Interrupt-ness" is taken care of by the 'dispatcher' in DSP/BIOS. Installed by the constructor.


Member Data Documentation

const int MityDSP::tcDspI2c2::gnI2C_OK = 0
static
const int MityDSP::tcDspI2c2::gnI2C_NO_ACK = -1
static
const int MityDSP::tcDspI2c2::gnI2C_NOT_IMPLEMENTED = -2
static
const int MityDSP::tcDspI2c2::gnI2C_BUSY = -3
static
unsigned int MityDSP::tcDspI2c2::mnInterruptCount

ISR counter (debug).

unsigned int tcDspI2c2::mnTicksPerSec = (1000 * CLK_countspms()) / CLK_getprd()
staticprotected

Conversion from low resolution.

unsigned int MityDSP::tcDspI2c2::mnFifoDepth
protected

depth of firmware FIFO

volatile unsigned int* MityDSP::tcDspI2c2::mpBaseAddr
protected

firmware base address

unsigned short MityDSP::tcDspI2c2::mnMyIntMask
protected

core interrupt mask

int MityDSP::tcDspI2c2::mnMyIntLevel
protected

core interrupt level

int MityDSP::tcDspI2c2::mnMyIntVector
protected

core interrupt vector

volatile unsigned int MityDSP::tcDspI2c2::mnBuffSize
protected

size of buffer

volatile unsigned char* MityDSP::tcDspI2c2::mpBuffer
protected

from application

SEM_Handle MityDSP::tcDspI2c2::mhDoneSem
protected

ISR to thread notifier.

LCK_Handle MityDSP::tcDspI2c2::mhLock
protected

serialization of calls


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