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

The hal_i2c.h file declares low-level interface functions for reading and writing sensor registers using I2C. More...

#include <stdint.h>
#include <stdbool.h>
#include "driver_sensors_types.h"
Include dependency graph for hal_i2c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define I2C_ERROR_OK   (0)
 

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 (uint8_t address, uint8_t reg, uint8_t *destination)
 
bool I2CReadBytes (uint8_t address, uint8_t reg, uint8_t *destination, int num_bytes)
 
bool I2CWriteByte (uint8_t address, uint8_t reg, uint8_t value)
 
bool I2CWriteBytes (uint8_t address, uint8_t reg, const uint8_t *value, unsigned int num_bytes)
 
int8_t Sensor_I2C_Write_List (registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
 Write register data to a sensor.
 
int32_t Sensor_I2C_Read (registerDeviceInfo_t *devInfo, uint16_t slaveAddress, 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.h file declares low-level interface functions for reading and writing sensor registers using I2C.

Definition in file hal_i2c.h.

Macro Definition Documentation

◆ I2C_ERROR_OK

#define I2C_ERROR_OK   (0)

Definition at line 32 of file hal_i2c.h.

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.

◆ 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.