IZAR Flight Controller 1.0.0
IZAR Flight Controller running with an ESP32.
|
Classes | |
struct | i2c_dev_t |
Macros | |
#define | CONFIG_I2CDEV_TIMEOUT 1000 |
#define | I2CDEV_MAX_STRETCH_TIME I2C_TIME_OUT_REG_V |
#define | I2C_DEV_TAKE_MUTEX(dev) |
#define | I2C_DEV_GIVE_MUTEX(dev) |
#define | I2C_DEV_CHECK(dev, X) |
#define | I2C_DEV_CHECK_LOGE(dev, X, msg, ...) |
Enumerations | |
enum | i2c_dev_type_t { I2C_DEV_WRITE = 0 , I2C_DEV_READ } |
Functions | |
esp_err_t | i2cdev_init () |
Init library. | |
esp_err_t | i2cdev_done () |
Finish work with library. | |
esp_err_t | i2c_dev_create_mutex (i2c_dev_t *dev) |
Create mutex for device descriptor. | |
esp_err_t | i2c_dev_delete_mutex (i2c_dev_t *dev) |
Delete mutex for device descriptor. | |
esp_err_t | i2c_dev_take_mutex (i2c_dev_t *dev) |
Take device mutex. | |
esp_err_t | i2c_dev_give_mutex (i2c_dev_t *dev) |
Give device mutex. | |
esp_err_t | i2c_dev_probe (const i2c_dev_t *dev, i2c_dev_type_t operation_type) |
Check the availability of the device. | |
esp_err_t | i2c_dev_read (const i2c_dev_t *dev, const void *out_data, size_t out_size, void *in_data, size_t in_size) |
Read from slave device. | |
esp_err_t | i2c_dev_write (const i2c_dev_t *dev, const void *out_reg, size_t out_reg_size, const void *out_data, size_t out_size) |
Write to slave device. | |
esp_err_t | i2c_dev_read_reg (const i2c_dev_t *dev, uint8_t reg, void *in_data, size_t in_size) |
Read from register with an 8-bit address. | |
esp_err_t | i2c_dev_write_reg (const i2c_dev_t *dev, uint8_t reg, const void *out_data, size_t out_size) |
Write to register with an 8-bit address. |
ESP-IDF I2C master thread-safe functions for communication with I2C slave
Copyright (c) 2018 Ruslan V. Uss uncle.nosp@m.rus@.nosp@m.gmail.nosp@m..com
MIT Licensed as described in the file LICENSE
#define CONFIG_I2CDEV_TIMEOUT 1000 |
#define I2C_DEV_CHECK | ( | dev, | |
X ) |
#define I2C_DEV_CHECK_LOGE | ( | dev, | |
X, | |||
msg, | |||
... ) |
#define I2C_DEV_GIVE_MUTEX | ( | dev | ) |
#define I2C_DEV_TAKE_MUTEX | ( | dev | ) |
#define I2CDEV_MAX_STRETCH_TIME I2C_TIME_OUT_REG_V |
enum i2c_dev_type_t |
esp_err_t i2c_dev_create_mutex | ( | i2c_dev_t * | dev | ) |
Create mutex for device descriptor.
This function does nothing if option CONFIG_I2CDEV_NOLOCK is enabled.
dev | Device descriptor |
< Invalid argument
< Generic esp_err_t code indicating failure
< esp_err_t value indicating success (no error)
esp_err_t i2c_dev_delete_mutex | ( | i2c_dev_t * | dev | ) |
Delete mutex for device descriptor.
This function does nothing if option CONFIG_I2CDEV_NOLOCK is enabled.
dev | Device descriptor |
< Invalid argument
< esp_err_t value indicating success (no error)
esp_err_t i2c_dev_give_mutex | ( | i2c_dev_t * | dev | ) |
Give device mutex.
This function does nothing if option CONFIG_I2CDEV_NOLOCK is enabled.
dev | Device descriptor |
< Invalid argument
< Generic esp_err_t code indicating failure
< esp_err_t value indicating success (no error)
esp_err_t i2c_dev_probe | ( | const i2c_dev_t * | dev, |
i2c_dev_type_t | operation_type ) |
Check the availability of the device.
Issue an operation of operation_type
to the I2C device then stops.
dev | Device descriptor |
operation_type | Operation type |
< Invalid argument
< Operation timed out
< esp_err_t value indicating success (no error)
< Generic esp_err_t code indicating failure
esp_err_t i2c_dev_read | ( | const i2c_dev_t * | dev, |
const void * | out_data, | ||
size_t | out_size, | ||
void * | in_data, | ||
size_t | in_size ) |
Read from slave device.
Issue a send operation of out_data
register address, followed by reading in_size
bytes from slave into in_data
. Function is thread-safe.
dev | Device descriptor | |
out_data | Pointer to data to send if non-null | |
out_size | Size of data to send | |
[out] | in_data | Pointer to input data buffer |
in_size | Number of byte to read |
< Invalid argument
< Operation timed out
< esp_err_t value indicating success (no error)
< esp_err_t value indicating success (no error)
< Generic esp_err_t code indicating failure
esp_err_t i2c_dev_read_reg | ( | const i2c_dev_t * | dev, |
uint8_t | reg, | ||
void * | in_data, | ||
size_t | in_size ) |
Read from register with an 8-bit address.
Shortcut to i2c_dev_read().
dev | Device descriptor | |
reg | Register address | |
[out] | in_data | Pointer to input data buffer |
in_size | Number of byte to read |
esp_err_t i2c_dev_take_mutex | ( | i2c_dev_t * | dev | ) |
Take device mutex.
This function does nothing if option CONFIG_I2CDEV_NOLOCK is enabled.
dev | Device descriptor |
< Invalid argument
< Operation timed out
< esp_err_t value indicating success (no error)
esp_err_t i2c_dev_write | ( | const i2c_dev_t * | dev, |
const void * | out_reg, | ||
size_t | out_reg_size, | ||
const void * | out_data, | ||
size_t | out_size ) |
Write to slave device.
Write out_size
bytes from out_data
to slave into out_reg
register address. Function is thread-safe.
dev | Device descriptor |
out_reg | Pointer to register address to send if non-null |
out_reg_size | Size of register address |
out_data | Pointer to data to send |
out_size | Size of data to send |
< Invalid argument
< Operation timed out
< esp_err_t value indicating success (no error)
< esp_err_t value indicating success (no error)
< Generic esp_err_t code indicating failure
esp_err_t i2c_dev_write_reg | ( | const i2c_dev_t * | dev, |
uint8_t | reg, | ||
const void * | out_data, | ||
size_t | out_size ) |
Write to register with an 8-bit address.
Shortcut to i2c_dev_write().
dev | Device descriptor |
reg | Register address |
out_data | Pointer to data to send |
out_size | Size of data to send |
esp_err_t i2cdev_done | ( | ) |
Finish work with library.
Uninstall i2c drivers.
< Operation timed out
< Generic esp_err_t code indicating failure
< esp_err_t value indicating success (no error)
esp_err_t i2cdev_init | ( | ) |
Init library.
The function must be called before any other functions of this library.
< Generic esp_err_t code indicating failure
< esp_err_t value indicating success (no error)