Library for supporting the Nucleo Sensor Shield.

Dependents:   Nucleo_Sensors_Demo m2x-temp_ethernet_demo m2x-MEMS_ACKme_Wifi_demo m2x_MEMS_Ublox_Cellular_demo ... more

Fork of Nucleo_Sensor_Shield by Daniel Griffin

Embed: (wiki syntax)

« Back to documentation index

DevI2C Class Reference

DevI2C Class Reference

Helper class DevI2C providing some common functionality useful for on-board communication. More...

#include <x_cube_mems_i2c.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 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 some common functionality useful for on-board communication.

Definition at line 56 of file x_cube_mems_i2c.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 64 of file x_cube_mems_i2c.h.


Member Function Documentation

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 data to be read.
DaviceAddrspecifies the peripheral device slave address (correctly masked)..
RegisterAddrspecifies internal address register to read from.
NumByteToReadnumber of bytes to be read.
Return values:
0if ok, -1 if an I2C error has occured
Note:
on some devices if NumByteToRead is greater than one, the DeviceAddr must be masked correctly

Definition at line 112 of file x_cube_mems_i2c.h.

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

Writes a buffer from the I2C peripheral device.

Parameters:
pBufferpointer to data to be read.
DeviceAddrspecifies the peripheral device slave address (correctly masked).
RegisterAddrspecifies internal address register to read from.
NumByteToWritenumber of bytes to be written.
Return values:
0if ok, -1 if an I2C error has occured
Note:
on some devices if NumByteToWrite is greater than one, the DeviceAddr must be masked correctly

Definition at line 77 of file x_cube_mems_i2c.h.