X_NUCLEO_NFC02A1 library for M24LR

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_NFC02A1_mbedOS HelloWorld_NFC02A1laatste HelloWorld_NFC02A1

Fork of X_NUCLEO_NFC02A1 by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

DevI2C Class Reference

DevI2C Class Reference

Helper class DevI2C providing functions for multi-register I2C communication common for a series of I2C devices. More...

#include <DevI2C.h>

Public Member Functions

 DevI2C (PinName sda, PinName scl)
 Create a DevI2C Master interface, connected to the specified pins.
int i2c_write (uint8_t *pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToWrite)
 Writes a buffer towards the I2C peripheral device.
int i2c_write (uint8_t *pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite)
 Writes a buffer towards the I2C peripheral device.
int i2c_read (uint8_t *pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToRead)
 Reads a buffer from the I2C peripheral device.
int i2c_read (uint8_t *pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead)
 Reads a buffer from the I2C peripheral device.

Detailed Description

Helper class DevI2C providing functions for multi-register I2C communication common for a series of I2C devices.

Definition at line 50 of file DevI2C.h.


Constructor & Destructor Documentation

DevI2C ( PinName  sda,
PinName  scl 
)

Create a DevI2C Master interface, connected to the specified pins.

Parameters:
sdaI2C data line pin
sclI2C clock line pin

Definition at line 59 of file DevI2C.h.


Member Function Documentation

int i2c_read ( uint8_t *  pBuffer,
uint8_t  DeviceAddr,
uint16_t  RegisterAddr,
uint16_t  NumByteToRead 
)

Reads a buffer from the I2C peripheral device.

Parameters:
pBufferpointer to the byte-array to read data in to
DaviceAddrspecifies the peripheral device slave address.
RegisterAddrspecifies the internal address register where to start reading from (must be correctly masked).
NumByteToReadnumber of bytes to be read.
Return values:
0if ok,
-1if an I2C error has occured
Note:
On some devices if NumByteToWrite is greater than one, the RegisterAddr must be masked correctly!

Definition at line 135 of file DevI2C.h.

int i2c_read ( uint8_t *  pBuffer,
uint8_t  DeviceAddr,
uint8_t  RegisterAddr,
uint16_t  NumByteToRead 
)

Reads a buffer from the I2C peripheral device.

Parameters:
pBufferpointer to the byte-array to read data in to
DaviceAddrspecifies the peripheral device slave address.
RegisterAddrspecifies the internal address register where to start reading from (must be correctly masked).
NumByteToReadnumber of bytes to be read.
Return values:
0if ok,
-1if an I2C error has occured
Note:
On some devices if NumByteToWrite is greater than one, the RegisterAddr must be masked correctly!

Definition at line 167 of file DevI2C.h.

int i2c_write ( uint8_t *  pBuffer,
uint8_t  DeviceAddr,
uint8_t  RegisterAddr,
uint16_t  NumByteToWrite 
)

Writes a buffer towards the I2C peripheral device.

Parameters:
pBufferpointer to the byte-array data to send
DeviceAddrspecifies the peripheral device slave address.
RegisterAddrspecifies the internal address register where to start writing to (must be correctly masked).
NumByteToWritenumber of bytes to be written.
Return values:
0if ok,
-1if an I2C error has occured, or
-2on temporary buffer overflow (i.e. NumByteToWrite was too high)
Note:
On some devices if NumByteToWrite is greater than one, the RegisterAddr must be masked correctly!

Definition at line 74 of file DevI2C.h.

int i2c_write ( uint8_t *  pBuffer,
uint8_t  DeviceAddr,
uint16_t  RegisterAddr,
uint16_t  NumByteToWrite 
)

Writes a buffer towards the I2C peripheral device.

Parameters:
pBufferpointer to the byte-array data to send
DeviceAddrspecifies the peripheral device slave address.
RegisterAddrspecifies the internal address register where to start writing to (must be correctly masked).
NumByteToWritenumber of bytes to be written.
Return values:
0if ok,
-1if an I2C error has occured, or
-2on temporary buffer overflow (i.e. NumByteToWrite was too high)
Note:
On some devices if NumByteToWrite is greater than one, the RegisterAddr must be masked correctly!

Definition at line 105 of file DevI2C.h.