MityDSP Documentation Index

MityDSP::tcDspI2c Class Reference

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

#include <core/DspI2c.h>

List of all members.

Public Types

typedef void(* tfIsrCallback )(tcDspI2c *)
 prototype for the ISR callbacks.
typedef void(* tfIsrCallbackWithArg )(tcDspI2c *, void *)

Public Member Functions

 tcDspI2c (void *apAddress, int anLevel=gnAutoLevel)
 This constructor is used to open an istance of the DspI2c interface.
 ~tcDspI2c ()
 This destructor is used to close up and free the resources tied to the associated I2C interface.
bool IsDone (void)
 Routine returns true if the previous operation is complete.
bool IsTxEmpty (void)
 Checks the transmit FIFO to see if it's empty.
bool IsRxEmpty (void)
 Checks the receive FIFO to see if it's empty.
unsigned int GetFIFODepth (void)
 Returns the depth of the transmit and receive FIFO.
void FlushRxFIFO (void)
 This routine will flush the I2C read FIFO.
int ReadFIFO (unsigned char *apData, int anMaxWords)
 Reads 8-bit words from the receive FIFO until either the FIFO is empty or the maximum specified words have been read.
int ReadFIFO (unsigned short *apData, int anMaxWords)
 Reads 16-bit words from the receive FIFO until either the FIFO is empty or the maximum specified words have been read.
void FlushTxFIFO (void)
 This routine will flush the I2C transmit FIFO.
int WriteFIFO (unsigned char *apData, int anNumWords)
 Writes the specified number of 8-bit words to the transmit FIFO.
int WriteFIFO (unsigned short *apData, int anNumWords)
 Writes the specified number of 16-bit words to the transmit FIFO.
bool IssueReadRequest (unsigned char anSlaveAddr, unsigned char anWordAddr, int anNumWords, unsigned int anTimeout=0)
 Posts a read request on the I2C bus.
bool IssueWriteRequest (unsigned char anSlaveAddr, unsigned char anWordAddr, int anNumWords, unsigned int anTimeout=0)
 Posts a write request on the I2C bus.
void EnableInterrupt (bool abEnable)
 Sets or clears the I2C interrupt enable.
void RegisterIsrCallback (tfIsrCallback afCallback)
 Registers the specified ISR callback for the "done" interrupt.
void RegisterIsrCallback (tfIsrCallbackWithArg afCallback, void *apUserArg=NULL)
 Registers the specified ISR callback for the "done" interrupt.

Static Public Member Functions

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

Public Attributes

unsigned int mnInterruptCount
 ISR counter (debug).

Protected Member Functions

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

Protected Attributes

SEM_Handle mhMyMutex
 To serialize access.
SEM_Handle mhDone
 Used to indicate command done.
unsigned int mnFifoDepth
 depth of firmware FIFO
bool mbIntState
 state of interrupt enable
tfIsrCallback mfIsrCallback
 Callback without argument.
tfIsrCallbackWithArg mfIsrCallbackWithArg
 Callback with argument.
void * mpUserArg
 User supplied ISR arg.
volatile unsigned int * mpBaseAddr
 firmware base address
unsigned short mnMyIntMask
 core interrupt mask
int mnMyIntLevel
 core interrupt level
int mnMyIntVector
 core interrupt vector

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 for the MityDSP.

See also:
tcDspI2c Page

Member Typedef Documentation

prototype for the ISR callbacks.


Constructor & Destructor Documentation

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

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

Parameters:
[in] apAddress Base Address of I2C core
[in] anLevel Optional parameter to force a chained interrupt at the specified level.
Returns:
None.
See also:
DspI2c.h
tcDspI2c::~tcDspI2c (  ) 

This destructor is used to close up and free the resources tied to the associated I2C interface.

Returns:
None.
See also:
DspI2c.h

Member Function Documentation

int tcDspI2c::interrupt_dispatch ( Arg  ahMyObject  )  [static]

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] ahMyObject The "this->" pointer for the instance of tcDspI2c associated with this ISR.
Returns:
0
bool tcDspI2c::IsDone ( void   ) 

Routine returns true if the previous operation is complete.

Returns:
true if the "done" bit is set, false otherwise
See also:
DspI2c.h
bool tcDspI2c::IsTxEmpty ( void   ) 

Checks the transmit FIFO to see if it's empty.

Returns:
true if the FIFO is empty, false otherwise
See also:
DspI2c.h
bool tcDspI2c::IsRxEmpty ( void   ) 

Checks the receive FIFO to see if it's empty.

Returns:
true if the FIFO is empty, false otherwise
See also:
DspI2c.h
unsigned int tcDspI2c::GetFIFODepth ( void   ) 

Returns the depth of the transmit and receive FIFO.

Both FIFOs have the same depth.

Returns:
The depth (in words) of the FIFOs.
See also:
DspI2c.h
void tcDspI2c::FlushRxFIFO ( void   ) 

This routine will flush the I2C read FIFO.

It is useful when a clearing operation is require or after initialization.

Returns:
None.
See also:
DspI2c.h
int tcDspI2c::ReadFIFO ( unsigned char *  apData,
int  anMaxWords 
)

Reads 8-bit words from the receive FIFO until either the FIFO is empty or the maximum specified words have been read.

Parameters:
[out] apData Pointer to storage for the received data.
[in] anMaxWords Maximum words to store in apData.
Returns:
Number of words of data actually stored.
See also:
DspI2c.h
int tcDspI2c::ReadFIFO ( unsigned short *  apData,
int  anMaxWords 
)

Reads 16-bit words from the receive FIFO until either the FIFO is empty or the maximum specified words have been read.

Parameters:
[out] apData Pointer to storage for the received data.
[in] anMaxWords Maximum words to store in apData.
Returns:
Number of words of data actually stored.
See also:
DspI2c.h
void tcDspI2c::FlushTxFIFO ( void   ) 

This routine will flush the I2C transmit FIFO.

It is useful when a clearing operation is require or after initialization.

Returns:
None.
See also:
DspI2c.h
int tcDspI2c::WriteFIFO ( unsigned char *  apData,
int  anNumWords 
)

Writes the specified number of 8-bit words to the transmit FIFO.

Note:
The routine limits the number of words written to the depth of the transmit FIFO. It is up to the application to ensure that the FIFO is empty before writing.
Parameters:
[in] apData Pointer to the data to transmit.
[in] anNumWords Number of words in apData.
Returns:
Number of words of data actually written.
See also:
DspI2c.h
int tcDspI2c::WriteFIFO ( unsigned short *  apData,
int  anNumWords 
)

Writes the specified number of 16-bit words to the transmit FIFO.

Note:
The routine limits the number of words written to the depth of the transmit FIFO. It is up to the application to ensure that the FIFO is empty before writing.
Parameters:
[in] apData Pointer to the data to transmit.
[in] anNumWords Number of words in apData.
Returns:
Number of words of data actually written.
See also:
DspI2c.h
bool tcDspI2c::IssueReadRequest ( unsigned char  anSlaveAddr,
unsigned char  anWordAddr,
int  anNumWords,
unsigned int  anTimeout = 0 
)

Posts a read request on the I2C bus.

The address of the slave device, the word address within the device, and the number of sequential words to read are provided.

If a non-zero timeout is provided, the routine waits for the specified number of milliseconds for the request to complete.

Note:
It is up to the application to ensure enough words exist in the receive FIFO to hold the requested data.
Parameters:
[in] anSlaveAddr Address of device on I2C bus
[in] anWordAddr Address of word to read within selected device
[in] anNumWords Number of words to read sequentially from device
[in] anTimeout Time (in millisecs) to wait for completion
Returns:
True if operation completed, false otherwise.
See also:
DspI2c.h
bool tcDspI2c::IssueWriteRequest ( unsigned char  anSlaveAddr,
unsigned char  anWordAddr,
int  anNumWords,
unsigned int  anTimeout = 0 
)

Posts a write request on the I2C bus.

The address of the slave device, the word address within the device, and the number of sequential words to write are provided.

If a non-zero timeout is provided, the routine waits for the specified number of milliseconds for the request to complete.

Note:
It is up to the application to pre-load the write FIFO with the appropriate number of words of data.
Parameters:
[in] anSlaveAddr Address of device on I2C bus
[in] anWordAddr Address of word to write within selected device
[in] anNumWords Number of words to write sequentially to device
[in] anTimeout Time (in millisecs) to wait for completion
Returns:
True if operation completed, false otherwise.
See also:
DspI2c.h
void tcDspI2c::EnableInterrupt ( bool  abEnable  ) 

Sets or clears the I2C interrupt enable.

Returns:
None.
See also:
DspI2c.h
void tcDspI2c::RegisterIsrCallback ( tfIsrCallback  afCallback  ) 

Registers the specified ISR callback for the "done" interrupt.

Parameters:
[in] afCallback The callback to associate with the interrupt (or NULL for none).
Returns:
None.
See also:
DspI2c.h
void tcDspI2c::RegisterIsrCallback ( tfIsrCallbackWithArg  afCallback,
void *  apUserArg = NULL 
)

Registers the specified ISR callback for the "done" interrupt.

Parameters:
[in] afCallback The callback to associate with the interrupt (or NULL for none).
[in] apUserArg An argument to be supplied with the callback.
Returns:
None.
See also:
DspI2c.h
void tcDspI2c::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

ISR counter (debug).

unsigned int tcDspI2c::mnTicksPerSec = (1000 * CLK_countspms()) / CLK_getprd() [static, protected]

Conversion from low resolution.

SEM_Handle MityDSP::tcDspI2c::mhMyMutex [protected]

To serialize access.

SEM_Handle MityDSP::tcDspI2c::mhDone [protected]

Used to indicate command done.

unsigned int MityDSP::tcDspI2c::mnFifoDepth [protected]

depth of firmware FIFO

state of interrupt enable

Callback without argument.

Callback with argument.

void* MityDSP::tcDspI2c::mpUserArg [protected]

User supplied ISR arg.

volatile unsigned int* MityDSP::tcDspI2c::mpBaseAddr [protected]

firmware base address

unsigned short MityDSP::tcDspI2c::mnMyIntMask [protected]

core interrupt mask

core interrupt level

core interrupt vector


  
Generated on Fri Sep 23 16:33:51 2011 for MityDSP Core by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.