Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT_SMBusBase Class Reference

Detailed Description

Definition at line 60 of file LT_SMBusBase.h.

Inheritance diagram for LT_SMBusBase:
LT_SMBus LT_SMBusGroup LT_SMBusNoPec LT_SMBusPec

Public Member Functions

LT_I2CBusi2cbus (void)
 
void i2cbus (LT_I2CBus *i2cbus)
 
void writeByte (uint8_t address, uint8_t command, uint8_t data)
 SMBus write byte command. More...
 
void writeBytes (uint8_t *addresses, uint8_t *commands, uint8_t *data, uint8_t no_addresses)
 SMBus write byte command for a list of addresses. More...
 
uint8_t readByte (uint8_t address, uint8_t command)
 SMBus read byte command. More...
 
void writeWord (uint8_t address, uint8_t command, uint16_t data)
 SMBus write word command. More...
 
uint16_t readWord (uint8_t address, uint8_t command)
 SMBus read word command. More...
 
void writeBlock (uint8_t address, uint8_t command, uint8_t *block, uint16_t block_size)
 SMBus write block command. More...
 
uint8_t writeReadBlock (uint8_t address, uint8_t command, uint8_t *block_out, uint16_t block_out_size, uint8_t *block_in, uint16_t block_in_size)
 SMBus write then read block command. More...
 
uint8_t readBlock (uint8_t address, uint8_t command, uint8_t *block, uint16_t block_size)
 SMBus read block command. More...
 
void sendByte (uint8_t address, uint8_t command)
 SMBus send byte command. More...
 
uint8_t readAlert (void)
 Perform ARA. More...
 
uint8_t waitForAck (uint8_t address, uint8_t command)
 Read with the address and command in loop until ack, then issue stop. More...
 
uint8_t * probe (uint8_t command)
 SMBus bus probe. More...
 
uint8_t * probeUnique (uint8_t command)
 SMBus bus probe. More...
 
- Public Member Functions inherited from LT_SMBus
virtual ~LT_SMBus ()
 
bool pecEnabled (void)
 Check if PEC is enabled. More...
 
void pecClear (void)
 Clear the pec value so it can start a new calculation. More...
 
void pecAdd (uint8_t byte_value)
 Add a byte to the pec calculation. More...
 
uint8_t pecGet (void)
 Get the current pec result. More...
 
bool checkCRC (uint8_t *data)
 Check CRC of block data organized as 31 data bytes plus CRC. More...
 
uint8_t getCRC (uint8_t *data)
 Get CRC of block data organized as 31 bytes pluse CRC. More...
 
uint8_t calculate (uint8_t *data, uint8_t begining_value, uint8_t start_index, uint8_t length)
 Helper function for pec. More...
 

Protected Member Functions

 LT_SMBusBase ()
 
 LT_SMBusBase (uint32_t speed)
 
virtual ~LT_SMBusBase ()
 
- Protected Member Functions inherited from LT_SMBus
void constructTable (uint16_t user_polynomial)
 Initialize the table used to speed up pec calculations. More...
 
uint8_t doCalculate (uint8_t data, uint8_t begining_value)
 Helper function for pec. More...
 
 LT_SMBus ()
 

Protected Attributes

LT_I2CBusi2cbus_
 
- Protected Attributes inherited from LT_SMBus
bool pec_enabled_
 
uint8_t running_pec_
 Temporary pec calc value. More...
 
unsigned char poly_
 The poly used in the calc. More...
 
uint16_t crc_polynomial_
 The crc poly used in the calc. More...
 

Static Protected Attributes

static bool open_ = false
 Used to ensure initialisation of i2c once. More...
 
static uint8_t found_address_ []
 

Member Function Documentation

◆ i2cbus() [1/2]

LT_I2CBus* LT_SMBusBase::i2cbus ( void  )
virtual

Implements LT_SMBus.

Definition at line 73 of file LT_SMBusBase.h.

◆ i2cbus() [2/2]

void LT_SMBusBase::i2cbus ( LT_I2CBus i2cbus)
virtual

Implements LT_SMBus.

Definition at line 78 of file LT_SMBusBase.h.

◆ probe()

uint8_t * LT_SMBusBase::probe ( uint8_t  command)
virtual

SMBus bus probe.

Returns
array of addresses
Parameters
commandCommand byte

Implements LT_SMBus.

Definition at line 119 of file LT_SMBusBase.cpp.

◆ probeUnique()

uint8_t * LT_SMBusBase::probeUnique ( uint8_t  command)
virtual

SMBus bus probe.

Returns
array of unique addresses (no global addresses)
Parameters
commandCommand byte

Implements LT_SMBus.

Definition at line 145 of file LT_SMBusBase.cpp.

◆ readAlert()

uint8_t LT_SMBusBase::readAlert ( void  )
virtual

Perform ARA.

Returns
address

Implements LT_SMBus.

Definition at line 95 of file LT_SMBusBase.cpp.

◆ readBlock()

uint8_t LT_SMBusBase::readBlock ( uint8_t  address,
uint8_t  command,
uint8_t *  block,
uint16_t  block_size 
)
virtual

SMBus read block command.

Returns
actual size
Parameters
addressSlave Address
commandCommand byte
blockMemory to receive data
block_sizeSize of receive data memory

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 459 of file LT_SMBusBase.cpp.

◆ readByte()

uint8_t LT_SMBusBase::readByte ( uint8_t  address,
uint8_t  command 
)
virtual

SMBus read byte command.

Returns
byte
Parameters
addressSlave Address
commandCommand byte

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 234 of file LT_SMBusBase.cpp.

◆ readWord()

uint16_t LT_SMBusBase::readWord ( uint8_t  address,
uint8_t  command 
)
virtual

SMBus read word command.

Returns
word
Parameters
addressSlave Address
commandCommand byte

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 301 of file LT_SMBusBase.cpp.

◆ sendByte()

void LT_SMBusBase::sendByte ( uint8_t  address,
uint8_t  command 
)
virtual

SMBus send byte command.

Returns
void
Parameters
addressSlave Address
commandCommand byte

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 508 of file LT_SMBusBase.cpp.

◆ waitForAck()

uint8_t LT_SMBusBase::waitForAck ( uint8_t  address,
uint8_t  command 
)
virtual

Read with the address and command in loop until ack, then issue stop.

Returns
void
Parameters
addressSlave Address
commandCommand byte

Implements LT_SMBus.

Definition at line 105 of file LT_SMBusBase.cpp.

◆ writeBlock()

void LT_SMBusBase::writeBlock ( uint8_t  address,
uint8_t  command,
uint8_t *  block,
uint16_t  block_size 
)
virtual

SMBus write block command.

Returns
void
Parameters
addressSlave Address
commandCommand byte
blockData to send

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 345 of file LT_SMBusBase.cpp.

◆ writeByte()

void LT_SMBusBase::writeByte ( uint8_t  address,
uint8_t  command,
uint8_t  data 
)
virtual

SMBus write byte command.

Returns
void
Parameters
addressSlave address
commandCommand byte
dataData to send

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 177 of file LT_SMBusBase.cpp.

◆ writeBytes()

void LT_SMBusBase::writeBytes ( uint8_t *  addresses,
uint8_t *  commands,
uint8_t *  data,
uint8_t  no_addresses 
)
virtual

SMBus write byte command for a list of addresses.

Returns
void
Parameters
addressesSlave Addresses
commandsCommand bytes
dataData to send

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 199 of file LT_SMBusBase.cpp.

◆ writeReadBlock()

uint8_t LT_SMBusBase::writeReadBlock ( uint8_t  address,
uint8_t  command,
uint8_t *  block_out,
uint16_t  block_out_size,
uint8_t *  block_in,
uint16_t  block_in_size 
)
virtual

SMBus write then read block command.

Returns
actual size
Parameters
addressSlave Address
commandCommand byte
block_outData to send
block_out_sizeSize of data to send
block_inMemory to receive data
block_in_sizeSize of receive data memory

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 381 of file LT_SMBusBase.cpp.

◆ writeWord()

void LT_SMBusBase::writeWord ( uint8_t  address,
uint8_t  command,
uint16_t  data 
)
virtual

SMBus write word command.

Returns
void
Parameters
addressSlave Address
commandCommand byte
dataData to send

Implements LT_SMBus.

Reimplemented in LT_SMBusGroup.

Definition at line 265 of file LT_SMBusBase.cpp.

Constructor & Destructor Documentation

◆ LT_SMBusBase() [1/2]

LT_SMBusBase::LT_SMBusBase ( )
protected

Definition at line 64 of file LT_SMBusBase.cpp.

◆ LT_SMBusBase() [2/2]

LT_SMBusBase::LT_SMBusBase ( uint32_t  speed)
protected

Definition at line 77 of file LT_SMBusBase.cpp.

◆ ~LT_SMBusBase()

LT_SMBusBase::~LT_SMBusBase ( )
protectedvirtual

Definition at line 90 of file LT_SMBusBase.cpp.

Field Documentation

◆ found_address_

uint8_t LT_SMBusBase::found_address_
staticprotected

Definition at line 64 of file LT_SMBusBase.h.

◆ i2cbus_

LT_I2CBus* LT_SMBusBase::i2cbus_
protected

Definition at line 65 of file LT_SMBusBase.h.

◆ open_

bool LT_SMBusBase::open_ = false
staticprotected

Used to ensure initialisation of i2c once.

Definition at line 63 of file LT_SMBusBase.h.


The documentation for this class was generated from the following files: