Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
Loading...
Searching...
No Matches
hal_i2c.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3 * Copyright (c) 2016-2017 NXP
4 * Copyright (c) 2020 Bjarne Hansen
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 * Modified for Espressif ESP environment
10 */
11
18#ifndef __HAL_I2C_H
19#define __HAL_I2C_H
20
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <stdint.h>
27#include <stdbool.h>
28
30
31#ifndef I2C_ERROR_OK
32 #define I2C_ERROR_OK (0) //not defined in ESP8266 Wire library, but is in the ESP32 version
33#endif
34
35/*******************************************************************************
36 * API
37 ******************************************************************************/
38
39//TODO put these in a class
40bool I2CInitialize(int pin_sda, int pin_scl);
41bool I2CReadByte(uint8_t address, uint8_t reg, uint8_t *destination);
42bool I2CReadBytes(uint8_t address, uint8_t reg, uint8_t *destination, int num_bytes);
43bool I2CWriteByte(uint8_t address, uint8_t reg, uint8_t value);
44bool I2CWriteBytes(uint8_t address, uint8_t reg, const uint8_t *value,
45 unsigned int num_bytes);
46
57 uint16_t slaveAddress,
58 const registerwritelist_t *pRegWriteList);
59
72 uint16_t slaveAddress,
73 const registerReadlist_t *pReadList,
74 uint8_t *pOutBuffer);
75
76int32_t Sensor_I2C_Read_Register(registerDeviceInfo_t *devInfo,
77 uint16_t peripheralAddress, uint8_t offset,
78 uint8_t length, uint8_t *pOutBuffer);
79
80
81#ifdef __cplusplus
82}
83#endif
84
85
86#endif /* __HAL_I2C_H */
The driver_sensors_types.h file contains sensor state structs and error definitions.
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....
Definition hal_i2c.cc:69
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 regis...
Definition hal_i2c.cc:120
bool I2CReadByte(byte address, byte reg, byte *destination)
Read single byte from address and place in destination Returns true if successful,...
Definition hal_i2c.cc:57
bool I2CWriteByte(byte address, byte reg, byte value)
Write single byte to register at address Returns true if successful, false if error.
Definition hal_i2c.cc:102
int8_t Sensor_I2C_Write_List(registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
Write register data to a sensor.
Definition hal_i2c.cc:145
int32_t Sensor_I2C_Read(registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerReadlist_t *pReadList, uint8_t *pOutBuffer)
Read register data from a sensor.
Definition hal_i2c.cc:177
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 pi...
Definition hal_i2c.cc:37
This structure defines the device specific info required by register I/O.
This structure defines the Read command List.
This structure defines the Write command List.