Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
Loading...
Searching...
No Matches
Functions
hal_i2c.cc File Reference

The hal_i2c.cc file contains definitions for low-level interface functions for reading and writing data from/to sensor using I2C. More...

#include "Arduino.h"
#include <Wire.h>
#include "driver_sensors_types.h"
#include "hal_i2c.h"
Include dependency graph for hal_i2c.cc:

Go to the source code of this file.

Functions

bool I2CInitialize (int pin_sda, int pin_scl)
 Initialize the I2C system at max clock rate supported by sensors. pin_sda and pin_scl indicate the pin numbers to which the I2C SDA and SCL lines of the sensors are connected. Pass -1 to use the default Arduino pins.
 
bool I2CReadByte (byte address, byte reg, byte *destination)
 Read single byte from address and place in destination Returns true if successful, false if error.
 
bool I2CReadBytes (byte address, byte reg, byte *destination, int num_bytes)
 Read num_bytes bytes from address starting at register. Assumes device auto-increments the register. Bytes read are placed in destination. Returns true if successful, false if error.
 
bool I2CWriteByte (byte address, byte reg, byte value)
 Write single byte to register at address Returns true if successful, false if error.
 
bool I2CWriteBytes (byte address, byte reg, const byte *value, unsigned int num_bytes)
 Write multiple bytes starting at register to I2C address Assumes device auto-increments the I2C register being written to. Returns true if successful, false if error.
 
int8_t Sensor_I2C_Write_List (registerDeviceInfo_t *devInfo, uint16_t peripheralAddress, const registerwritelist_t *pRegWriteList)
 Write register data to a sensor.
 
int32_t Sensor_I2C_Read (registerDeviceInfo_t *devInfo, uint16_t peripheralAddress, const registerReadlist_t *pReadList, uint8_t *pOutBuffer)
 Read register data from a sensor.
 
int32_t Sensor_I2C_Read_Register (registerDeviceInfo_t *devInfo, uint16_t peripheralAddress, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
 

Detailed Description

The hal_i2c.cc file contains definitions for low-level interface functions for reading and writing data from/to sensor using I2C.

Definition in file hal_i2c.cc.

Function Documentation

◆ I2CInitialize()

bool I2CInitialize ( int  pin_sda,
int  pin_scl 
)

Initialize the I2C system at max clock rate supported by sensors. pin_sda and pin_scl indicate the pin numbers to which the I2C SDA and SCL lines of the sensors are connected. Pass -1 to use the default Arduino pins.

Returns true if successful, false if problem initializing I2C.

Definition at line 37 of file hal_i2c.cc.

◆ I2CReadByte()

bool I2CReadByte ( byte  address,
byte  reg,
byte *  destination 
)

Read single byte from address and place in destination Returns true if successful, false if error.

Definition at line 57 of file hal_i2c.cc.

◆ I2CReadBytes()

bool I2CReadBytes ( byte  address,
byte  reg,
byte *  destination,
int  num_bytes 
)

Read num_bytes bytes from address starting at register. Assumes device auto-increments the register. Bytes read are placed in destination. Returns true if successful, false if error.

Definition at line 69 of file hal_i2c.cc.

◆ I2CWriteByte()

bool I2CWriteByte ( byte  address,
byte  reg,
byte  value 
)

Write single byte to register at address Returns true if successful, false if error.

Definition at line 102 of file hal_i2c.cc.

◆ I2CWriteBytes()

bool I2CWriteBytes ( byte  address,
byte  reg,
const byte *  value,
unsigned int  num_bytes 
)

Write multiple bytes starting at register to I2C address Assumes device auto-increments the I2C register being written to. Returns true if successful, false if error.

Definition at line 120 of file hal_i2c.cc.

◆ Sensor_I2C_Read()

int32_t Sensor_I2C_Read ( registerDeviceInfo_t devInfo,
uint16_t  slaveAddress,
const registerReadlist_t pReadList,
uint8_t *  pOutBuffer 
)

Read register data from a sensor.

Parameters
[in]pCommDrvpointer to the I2C ARM driver to use
[in]devInfoThe I2C device number and idle function.
[in]slaveAddressthe I2C slave address to read from
[in]pReadLista list of one or more register addresses and lengths to read
[in]pOutBuffera pointer of sufficient size to contain the requested read data
Returns
returns the execution status of the operation using ESensorErrors

Definition at line 177 of file hal_i2c.cc.

◆ Sensor_I2C_Read_Register()

int32_t Sensor_I2C_Read_Register ( registerDeviceInfo_t devInfo,
uint16_t  peripheralAddress,
uint8_t  offset,
uint8_t  length,
uint8_t *  pOutBuffer 
)

Definition at line 204 of file hal_i2c.cc.

◆ Sensor_I2C_Write_List()

int8_t Sensor_I2C_Write_List ( registerDeviceInfo_t devInfo,
uint16_t  slaveAddress,
const registerwritelist_t pRegWriteList 
)

Write register data to a sensor.

Parameters
[in]pCommDrvpointer to the I2C ARM driver to use
[in]devInfoThe I2C device number and idle function.
[in]slaveAddressthe I2C slave address to write to
[in]pRegWriteLista list of one or more register/value pairs to write
Returns
returns the execution status of the operation using ESensorErrors

Definition at line 145 of file hal_i2c.cc.