DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
Public Member Functions
dhcom::I2CSlave Class Reference

Class representing a slave device of a I2C bus. This is a convenience class, which simplifies operations with I2C slave devices. It automates the selection of I2C slave in case when several slaves are operating on the same bus. More...

#include <I2CSlave.h>

Public Member Functions

 I2CSlave (I2CBus *bus, uint16_t address)
 Create an I2CSlave object and remember its properties (address and the bus).
 
STATUS read (uint8_t *buffer, uint32_t count) const
 Reads a block of bytes from the I2C slave device.
 
uint8_t read (STATUS *status=NULL) const
 Read one byte from the I2C slave device.
 
STATUS write (const uint8_t *buffer, uint32_t count)
 Write a block of bytes to the I2C slave device.
 
STATUS write (uint8_t byte)
 Write one byte to the I2C slave device.
 

Detailed Description

Class representing a slave device of a I2C bus. This is a convenience class, which simplifies operations with I2C slave devices. It automates the selection of I2C slave in case when several slaves are operating on the same bus.

Constructor & Destructor Documentation

dhcom::I2CSlave::I2CSlave ( I2CBus bus,
uint16_t  address 
)

Create an I2CSlave object and remember its properties (address and the bus).

Parameters
bus- a pointer to the I2CBus object, must not be NULL.
address- the address of the slave on the bus.

Member Function Documentation

STATUS dhcom::I2CSlave::read ( uint8_t buffer,
uint32_t  count 
) const

Reads a block of bytes from the I2C slave device.

Parameters
buffer- a pointer to the buffer to receive the incoming data.
count- number of bytes to receive.
Returns
- may return same values as I2CBus::selectSlave() and I2CBus::read().
uint8_t dhcom::I2CSlave::read ( STATUS status = NULL) const

Read one byte from the I2C slave device.

Parameters
status- if NULL - no status is returned, otherwise status is assigned from same set of values as for I2CBus::selectSlave() and I2CBus::read().
Returns
The value of the received byte.
STATUS dhcom::I2CSlave::write ( const uint8_t buffer,
uint32_t  count 
)

Write a block of bytes to the I2C slave device.

Parameters
buffer- a pointer to the buffer from which to send the data;
count- number of bytes to send.
Returns
- may return same values as I2CBus::selectSlave() and I2CBus::write().
STATUS dhcom::I2CSlave::write ( uint8_t  byte)

Write one byte to the I2C slave device.

Parameters
byte- the value to send.
Returns
- may return same values as I2CBus::selectSlave() and I2CBus::write().

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