| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Public Member Functions | Protected Member Functions | Protected Attributes
LT_SMBus Class Referenceabstract

## Detailed Description

Definition at line 61 of file LT_SMBus.h.

Inheritance diagram for LT_SMBus:

## Public Member Functions
virtual | ~LT_SMBus ()
virtual LT_I2CBus * | i2cbus (void)=0
virtual void | i2cbus (LT_I2CBus *i2cbus)=0
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...
virtual uint8_t | readAlert (void)=0
| Perform ARA. More...
virtual void | writeByte (uint8_t address, uint8_t command, uint8_t data)=0
| SMBus write byte command. More...
virtual void | writeBytes (uint8_t *addresses, uint8_t *commands, uint8_t *data, uint8_t no_addresses)=0
| SMBus write byte command for a list of addresses. More...
virtual uint8_t | readByte (uint8_t address, uint8_t command)=0
| SMBus read byte command. More...
virtual void | writeWord (uint8_t address, uint8_t command, uint16_t data)=0
| SMBus write word command. More...
virtual uint16_t | readWord (uint8_t address, uint8_t command)=0
| SMBus read word command. More...
virtual void | writeBlock (uint8_t address, uint8_t command, uint8_t *block, uint16_t block_size)=0
| SMBus write block command. More...
virtual 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)=0
| SMBus write then read block command. More...
virtual uint8_t | readBlock (uint8_t address, uint8_t command, uint8_t *block, uint16_t block_size)=0
| SMBus read block command. More...
virtual void | sendByte (uint8_t address, uint8_t command)=0
| SMBus send byte command. More...
virtual uint8_t | waitForAck (uint8_t address, uint8_t command)=0
| Read with the address and command in loop until ack, then issue stop. More...
virtual uint8_t * | probe (uint8_t command)=0
| SMBus bus probe. More...
virtual uint8_t * | probeUnique (uint8_t command)=0
| SMBus bus probe. More...

## Protected Member Functions
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
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...

## Member Function Documentation

## ◆ calculate()

uint8_t LT_SMBus::calculate | ( | uint8_t * | data,
|  | uint8_t | begining_value,
|  | uint8_t | start_index,
|  | uint8_t | length
| ) |  |

Helper function for pec.

Returns
  value

Parameters

  data | Data to be pec'ed
  begining_value | Starting value for pec
  start_index | Starting index
  length | Length of data

Definition at line 146 of file LT_SMBus.cpp.

## ◆ checkCRC()

bool LT_SMBus::checkCRC | ( | uint8_t * | data | ) |

Check CRC of block data organized as 31 data bytes plus CRC.

Do not mix with PEC calculations. Return true if CRC does not match.

Definition at line 200 of file LT_SMBus.cpp.

## ◆ constructTable()

void LT_SMBus::constructTable | ( | uint16_t | user_polynomial | ) |
| protected

Initialize the table used to speed up pec calculations.

Returns
  void

Parameters

  user_polynomial | The controlling polynomial

Definition at line 105 of file LT_SMBus.cpp.

## ◆ doCalculate()

uint8_t LT_SMBus::doCalculate | ( | uint8_t | data,
|  | uint8_t | begining_value
| ) |  |
| protected

Helper function for pec.

Returns
  value

Parameters

  begining_value | The initial value

Definition at line 138 of file LT_SMBus.cpp.

## ◆ getCRC()

uint8_t LT_SMBus::getCRC | ( | uint8_t * | data | ) |

Get CRC of block data organized as 31 bytes pluse CRC.

Do not mix with PEC calculations. Return PEC

Definition at line 220 of file LT_SMBus.cpp.

## ◆ i2cbus() [1/2]

virtual LT_I2CBus* LT_SMBus::i2cbus | ( | void |  | ) |
| pure virtual

Implemented in LT_SMBusBase.

## ◆ i2cbus() [2/2]

virtual void LT_SMBus::i2cbus | ( | LT_I2CBus * | i2cbus | ) |
| pure virtual

Implemented in LT_SMBusBase.

## ◆ pecAdd()

void LT_SMBus::pecAdd | ( | uint8_t | byte_value | ) |

Add a byte to the pec calculation.

Returns
  void

Definition at line 170 of file LT_SMBus.cpp.

## ◆ pecClear()

void LT_SMBus::pecClear | ( | void |  | ) |

Clear the pec value so it can start a new calculation.

Returns
  void

Definition at line 162 of file LT_SMBus.cpp.

## ◆ pecEnabled()

bool LT_SMBus::pecEnabled | ( | void |  | ) |

Check if PEC is enabled.

Returns
  true if enabled

Definition at line 92 of file LT_SMBus.h.

## ◆ pecGet()

uint8_t LT_SMBus::pecGet | ( | void |  | ) |

Get the current pec result.

Returns
  the pec

Definition at line 192 of file LT_SMBus.cpp.

## ◆ probe()

virtual uint8_t* LT_SMBus::probe | ( | uint8_t | command | ) |
| pure virtual

SMBus bus probe.

Returns
  array of addresses (caller must not delete return memory)

Parameters

  command | Command byte

Implemented in LT_SMBusBase.

## ◆ probeUnique()

virtual uint8_t* LT_SMBus::probeUnique | ( | uint8_t | command | ) |
| pure virtual

SMBus bus probe.

Returns
  array of unique addresses (no global addresses)

Parameters

  command | Command byte

Implemented in LT_SMBusBase.

## ◆ readAlert()

virtual uint8_t LT_SMBus::readAlert | ( | void |  | ) |
| pure virtual

Perform ARA.

Returns
  address

Implemented in LT_SMBusBase.

## ◆ readBlock()

virtual uint8_t LT_SMBus::readBlock | ( | uint8_t | address,
|  | uint8_t | command,
|  | uint8_t * | block,
|  | uint16_t | block_size
| ) |  |
| pure virtual

SMBus read block command.

Returns
  actual size

Parameters

  address | Slave Address
  command | Command byte
  block | Memory to receive data
  block_size | Size of receive data memory

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ readByte()

virtual uint8_t LT_SMBus::readByte | ( | uint8_t | address,
|  | uint8_t | command
| ) |  |
| pure virtual

SMBus read byte command.

Returns
  byte

Parameters

  address | Slave Address
  command | Command byte

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ readWord()

virtual uint16_t LT_SMBus::readWord | ( | uint8_t | address,
|  | uint8_t | command
| ) |  |
| pure virtual

SMBus read word command.

Returns
  word

Parameters

  address | Slave Address
  command | Command byte

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ sendByte()

virtual void LT_SMBus::sendByte | ( | uint8_t | address,
|  | uint8_t | command
| ) |  |
| pure virtual

SMBus send byte command.

Returns
  void

Parameters

  address | Slave Address
  command | Command byte

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ waitForAck()

virtual uint8_t LT_SMBus::waitForAck | ( | uint8_t | address,
|  | uint8_t | command
| ) |  |
| pure virtual

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

Returns
  void

Parameters

  address | Slave Address
  command | Command byte

Implemented in LT_SMBusBase.

## ◆ writeBlock()

virtual void LT_SMBus::writeBlock | ( | uint8_t | address,
|  | uint8_t | command,
|  | uint8_t * | block,
|  | uint16_t | block_size
| ) |  |
| pure virtual

SMBus write block command.

Returns
  void

Parameters

  address | Slave Address
  command | Command byte
  block | Data to send

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ writeByte()

virtual void LT_SMBus::writeByte | ( | uint8_t | address,
|  | uint8_t | command,
|  | uint8_t | data
| ) |  |
| pure virtual

SMBus write byte command.

Returns
  void

Parameters

  address | Slave address
  command | Command byte
  data | Data to send

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ writeBytes()

virtual void LT_SMBus::writeBytes | ( | uint8_t * | addresses,
|  | uint8_t * | commands,
|  | uint8_t * | data,
|  | uint8_t | no_addresses
| ) |  |
| pure virtual

SMBus write byte command for a list of addresses.

Returns
  void

Parameters

  addresses | Slave Addresses
  commands | Command bytes
  data | Data to send

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ writeReadBlock()

virtual uint8_t LT_SMBus::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
| ) |  |
| pure virtual

SMBus write then read block command.

Returns
  actual value

Parameters

  address | Slave Address
  command | Command byte
  block_out | Data to send
  block_out_size | Size of data to send
  block_in | Memory to receive data
  block_in_size | Size of receive data memory

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## ◆ writeWord()

virtual void LT_SMBus::writeWord | ( | uint8_t | address,
|  | uint8_t | command,
|  | uint16_t | data
| ) |  |
| pure virtual

SMBus write word command.

Returns
  void

Parameters

  address | Slave Address
  command | Command byte
  data | Data to send

Implemented in LT_SMBusGroup, and LT_SMBusBase.

## Constructor & Destructor Documentation

## ◆ LT_SMBus()

LT_SMBus::LT_SMBus | ( |  | ) |
| protected

Definition at line 91 of file LT_SMBus.cpp.

## ◆ ~LT_SMBus()

virtual LT_SMBus::~LT_SMBus | ( |  | ) |
| virtual

Definition at line 85 of file LT_SMBus.h.

## Field Documentation

## ◆ crc_polynomial_

uint16_t LT_SMBus::crc_polynomial_
| protected

The crc poly used in the calc.

Definition at line 68 of file LT_SMBus.h.

## ◆ pec_enabled_

bool LT_SMBus::pec_enabled_
| protected

Definition at line 64 of file LT_SMBus.h.

## ◆ poly_

unsigned char LT_SMBus::poly_
| protected

The poly used in the calc.

Definition at line 67 of file LT_SMBus.h.

## ◆ running_pec_

uint8_t LT_SMBus::running_pec_
| protected

Temporary pec calc value.

Definition at line 66 of file LT_SMBus.h.

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

- LT_SMBus.h
- LT_SMBus.cpp