File espos_i2c_bus.h¶
FileList > espos_sensors > include > espos_i2c_bus.h
Go to the source code of this file
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "esp_err.h"
Classes¶
| Type | Name |
|---|---|
| struct | espos_i2c_bus_cfg_t |
Public Types¶
| Type | Name |
|---|---|
| typedef struct espos_i2c_dev * | espos_i2c_dev_handle_t |
Public Functions¶
| Type | Name |
|---|---|
| esp_err_t | espos_i2c_bus_open (const espos_i2c_bus_cfg_t * cfg) Open a bus. |
| esp_err_t | espos_i2c_dev_add (int port, uint8_t addr, espos_i2c_dev_handle_t * out) Add a device on an already-open bus. |
| void | espos_i2c_dev_remove (espos_i2c_dev_handle_t dev) |
| esp_err_t | espos_i2c_probe (int port, uint8_t addr, uint32_t timeout_ms) Whether a device answers at all: the first thing to check when a sensor reads zeros. |
| esp_err_t | espos_i2c_read_reg (espos_i2c_dev_handle_t dev, uint8_t reg, uint8_t * buf, size_t len, uint32_t timeout_ms) Register access, the shape almost every I2C sensor speaks: write the register number, then read len bytes. |
| esp_err_t | espos_i2c_write_reg (espos_i2c_dev_handle_t dev, uint8_t reg, const uint8_t * buf, size_t len, uint32_t timeout_ms) |
| esp_err_t | espos_i2c_xfer (espos_i2c_dev_handle_t dev, const uint8_t * tx, size_t tx_len, uint8_t * rx, size_t rx_len, uint32_t timeout_ms) Raw transfer, for a device that does not use registers. |
Public Types Documentation¶
typedef espos_i2c_dev_handle_t¶
Public Functions Documentation¶
function espos_i2c_bus_open¶
Open a bus.
Opening the same port twice returns ESP_ERR_INVALID_STATE: the bus is shared, so the second caller should just add its device.
function espos_i2c_dev_add¶
Add a device on an already-open bus.
addr is the 7-bit address.
function espos_i2c_dev_remove¶
function espos_i2c_probe¶
Whether a device answers at all: the first thing to check when a sensor reads zeros.
function espos_i2c_read_reg¶
Register access, the shape almost every I2C sensor speaks: write the register number, then read len bytes.
esp_err_t espos_i2c_read_reg (
espos_i2c_dev_handle_t dev,
uint8_t reg,
uint8_t * buf,
size_t len,
uint32_t timeout_ms
)
Blocking, with a timeout in milliseconds (0 = 100).
function espos_i2c_write_reg¶
esp_err_t espos_i2c_write_reg (
espos_i2c_dev_handle_t dev,
uint8_t reg,
const uint8_t * buf,
size_t len,
uint32_t timeout_ms
)
function espos_i2c_xfer¶
Raw transfer, for a device that does not use registers.
esp_err_t espos_i2c_xfer (
espos_i2c_dev_handle_t dev,
const uint8_t * tx,
size_t tx_len,
uint8_t * rx,
size_t rx_len,
uint32_t timeout_ms
)
Either half may be NULL.
The documentation for this class was generated from the following file espos_sensors/include/espos_i2c_bus.h