Instances of this class handle access to a "generic" implementation of the I2C interface, version 2.0, for the MityDSP.
More...
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.
|
Instances of this class handle access to a "generic" implementation of the I2C interface, version 2.0, for the MityDSP.
- See also:
- tcDspI2c2 Page
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:
-
anSlaveAddr | 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 |
( |
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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[in] | val | 8 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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[in] | reg | 8 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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[in] | reg | 8 bit device subaddress |
[in] | val | 8 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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[in] | reg | 8 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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[in] | reg | 8 bit device subaddress |
[in] | val | 16 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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[in] | apWriteBuf | output buffer (typically 1 or 2 bytes containing device subaddress) |
[in] | anWriteSize | number of bytes in apWriteBuf to transmit |
[out] | apReadBuf | pointer to receive buffer |
[in] | anReadSize | number of bytes to read and store in receive buffer |
[in] | ab10BitAddr | (default false), set to true if slave device is 10 bit mode |
[in] | anTimeout | Time (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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[out] | apBuffer | pointer to receive buffer |
[in] | anSize | number of bytes to read and store in receive buffer |
[in] | abSendStop | w(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] | anTimeout | Time (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] | anSlaveAddr | Addr to transmit (7-bit device address only) |
[out] | apBuffer | pointer to transmit data buffer |
[in] | anSize | number of bytes to transmit from the transmit buffer |
[in] | abSendStop | w(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] | anTimeout | Time (default SYS_FOREVER) to wait to acquire the device (for threading support) |
- Returns:
- gnI2C_OK, gnI2C_NO_ACK, or gnI2C_BUSY