|
ICM42670 Portable Driver
Public API reference for the ICM-42670-P IMU driver
|
ESP-IDF I2C and SPI transport adapters for the ICM-42670-P driver. More...
#include "ICM42670_driver.h"#include "driver/gpio.h"#include "driver/i2c_master.h"#include "driver/spi_master.h"#include "esp_err.h"#include <stdbool.h>#include <stdint.h>

Go to the source code of this file.
Data Structures | |
| struct | ICM42670_ESP_I2CBus |
| ESP-IDF I2C bus state used by the portable driver callbacks. More... | |
| struct | ICM42670_ESP_SPIBus |
| ESP-IDF SPI bus state used by the portable driver callbacks. More... | |
Macros | |
| #define | ICM42670_ESP_DEFAULT_I2C_SPEED_HZ 400000U |
| #define | ICM42670_ESP_DEFAULT_SPI_SPEED_HZ 1000000 |
Functions | |
| esp_err_t | ICM42670_ESP_I2C_Init (ICM42670_Config *config, ICM42670_ESP_I2CBus *bus, int i2c_port, gpio_num_t sda_pin, gpio_num_t scl_pin, uint8_t device_addr, uint32_t scl_speed_hz) |
| Create an ESP-IDF I2C bus/device and populate ICM42670_Config. | |
| esp_err_t | ICM42670_ESP_I2C_AttachDevice (ICM42670_Config *config, ICM42670_ESP_I2CBus *bus, i2c_master_bus_handle_t bus_handle, i2c_master_dev_handle_t dev_handle) |
| Attach an existing ESP-IDF I2C device to ICM42670_Config. | |
| esp_err_t | ICM42670_ESP_I2C_Deinit (ICM42670_ESP_I2CBus *bus) |
| Release ESP-IDF I2C resources owned by this adapter. | |
| esp_err_t | ICM42670_ESP_I2C_Probe (ICM42670_ESP_I2CBus *bus, uint8_t device_addr) |
| Probe an I2C address on the adapter's bus. | |
| int8_t | ICM42670_ESP_I2C_ReadReg (void *handle, uint8_t reg_addr, uint8_t *data, uint16_t len) |
| ESP-IDF I2C register-read callback for ICM42670_Config. | |
| int8_t | ICM42670_ESP_I2C_WriteReg (void *handle, uint8_t reg_addr, const uint8_t *data, uint16_t len) |
| ESP-IDF I2C register-write callback for ICM42670_Config. | |
| esp_err_t | ICM42670_ESP_SPI_Init (ICM42670_Config *config, ICM42670_ESP_SPIBus *bus, spi_host_device_t host_id, gpio_num_t miso_pin, gpio_num_t mosi_pin, gpio_num_t sclk_pin, gpio_num_t cs_pin, int clock_speed_hz) |
| Create an ESP-IDF SPI bus/device and populate ICM42670_Config. | |
| esp_err_t | ICM42670_ESP_SPI_AttachDevice (ICM42670_Config *config, ICM42670_ESP_SPIBus *bus, spi_host_device_t host_id, spi_device_handle_t dev_handle) |
| Attach an existing ESP-IDF SPI device to ICM42670_Config. | |
| esp_err_t | ICM42670_ESP_SPI_Deinit (ICM42670_ESP_SPIBus *bus) |
| Release ESP-IDF SPI resources owned by this adapter. | |
| int8_t | ICM42670_ESP_SPI_ReadReg (void *handle, uint8_t reg_addr, uint8_t *data, uint16_t len) |
| ESP-IDF SPI register-read callback for ICM42670_Config. | |
| int8_t | ICM42670_ESP_SPI_WriteReg (void *handle, uint8_t reg_addr, const uint8_t *data, uint16_t len) |
| ESP-IDF SPI register-write callback for ICM42670_Config. | |
ESP-IDF I2C and SPI transport adapters for the ICM-42670-P driver.
| #define ICM42670_ESP_DEFAULT_I2C_SPEED_HZ 400000U |
Default I2C bus speed.
| #define ICM42670_ESP_DEFAULT_SPI_SPEED_HZ 1000000 |
Default SPI clock speed.
| esp_err_t ICM42670_ESP_I2C_AttachDevice | ( | ICM42670_Config * | config, |
| ICM42670_ESP_I2CBus * | bus, | ||
| i2c_master_bus_handle_t | bus_handle, | ||
| i2c_master_dev_handle_t | dev_handle | ||
| ) |
Attach an existing ESP-IDF I2C device to ICM42670_Config.
The adapter does not own attached handles and will not remove them during deinit.
| config | Driver configuration to populate. |
| bus | I2C bus state owned by the caller. |
| bus_handle | Existing ESP-IDF I2C master bus handle. |
| dev_handle | Existing ESP-IDF I2C device handle. |
References ICM42670_ESP_I2CBus::bus_handle, ICM42670_ESP_I2CBus::dev_handle, ICM42670_ESP_I2C_ReadReg(), ICM42670_ESP_I2C_WriteReg(), and ICM42670_ESP_I2CBus::timeout_ms.
| esp_err_t ICM42670_ESP_I2C_Deinit | ( | ICM42670_ESP_I2CBus * | bus | ) |
Release ESP-IDF I2C resources owned by this adapter.
| bus | I2C bus state. |
References ICM42670_ESP_I2CBus::bus_handle, ICM42670_ESP_I2CBus::dev_handle, ICM42670_ESP_I2CBus::owns_bus, and ICM42670_ESP_I2CBus::owns_device.
Referenced by ICM42670_ESP_I2C_Init().
| esp_err_t ICM42670_ESP_I2C_Init | ( | ICM42670_Config * | config, |
| ICM42670_ESP_I2CBus * | bus, | ||
| int | i2c_port, | ||
| gpio_num_t | sda_pin, | ||
| gpio_num_t | scl_pin, | ||
| uint8_t | device_addr, | ||
| uint32_t | scl_speed_hz | ||
| ) |
Create an ESP-IDF I2C bus/device and populate ICM42670_Config.
The adapter owns the created bus and device until ICM42670_ESP_I2C_Deinit() is called.
| config | Driver configuration to populate. |
| bus | I2C bus state owned by the caller. |
| i2c_port | ESP-IDF I2C port number. |
| sda_pin | SDA GPIO. |
| scl_pin | SCL GPIO. |
| device_addr | 7-bit I2C device address. |
| scl_speed_hz | I2C clock speed, or 0 for the default. |
References ICM42670_ESP_I2CBus::bus_handle, ICM42670_ESP_I2CBus::dev_handle, ICM42670_ESP_DEFAULT_I2C_SPEED_HZ, ICM42670_ESP_I2C_Deinit(), ICM42670_ESP_I2C_ReadReg(), ICM42670_ESP_I2C_WriteReg(), ICM42670_ESP_I2CBus::owns_bus, ICM42670_ESP_I2CBus::owns_device, and ICM42670_ESP_I2CBus::timeout_ms.
| esp_err_t ICM42670_ESP_I2C_Probe | ( | ICM42670_ESP_I2CBus * | bus, |
| uint8_t | device_addr | ||
| ) |
Probe an I2C address on the adapter's bus.
| bus | I2C bus state with a valid bus handle. |
| device_addr | 7-bit I2C address to probe. |
References ICM42670_ESP_I2CBus::bus_handle, and ICM42670_ESP_I2CBus::timeout_ms.
| int8_t ICM42670_ESP_I2C_ReadReg | ( | void * | handle, |
| uint8_t | reg_addr, | ||
| uint8_t * | data, | ||
| uint16_t | len | ||
| ) |
ESP-IDF I2C register-read callback for ICM42670_Config.
| handle | Pointer to ICM42670_ESP_I2CBus. |
| reg_addr | Register address to read from. |
| data | Destination buffer. |
| len | Number of bytes to read. |
References ICM42670_ESP_I2CBus::bus_handle, ICM42670_ESP_I2CBus::dev_handle, ICM42670_ERROR, ICM42670_OK, and ICM42670_ESP_I2CBus::timeout_ms.
Referenced by ICM42670_ESP_I2C_AttachDevice(), and ICM42670_ESP_I2C_Init().
| int8_t ICM42670_ESP_I2C_WriteReg | ( | void * | handle, |
| uint8_t | reg_addr, | ||
| const uint8_t * | data, | ||
| uint16_t | len | ||
| ) |
ESP-IDF I2C register-write callback for ICM42670_Config.
| handle | Pointer to ICM42670_ESP_I2CBus. |
| reg_addr | Register address to write to. |
| data | Source buffer. |
| len | Number of bytes to write. |
References ICM42670_ESP_I2CBus::bus_handle, ICM42670_ESP_I2CBus::dev_handle, ICM42670_ERROR, ICM42670_OK, and ICM42670_ESP_I2CBus::timeout_ms.
Referenced by ICM42670_ESP_I2C_AttachDevice(), and ICM42670_ESP_I2C_Init().
| esp_err_t ICM42670_ESP_SPI_AttachDevice | ( | ICM42670_Config * | config, |
| ICM42670_ESP_SPIBus * | bus, | ||
| spi_host_device_t | host_id, | ||
| spi_device_handle_t | dev_handle | ||
| ) |
Attach an existing ESP-IDF SPI device to ICM42670_Config.
The adapter does not own attached handles and will not remove them during deinit.
| config | Driver configuration to populate. |
| bus | SPI bus state owned by the caller. |
| host_id | ESP-IDF SPI host used by dev_handle. |
| dev_handle | Existing ESP-IDF SPI device handle. |
References ICM42670_ESP_SPIBus::dev_handle, ICM42670_ESP_SPIBus::host_id, ICM42670_ESP_SPI_ReadReg(), ICM42670_ESP_SPI_WriteReg(), and ICM42670_ESP_SPIBus::timeout_ms.
| esp_err_t ICM42670_ESP_SPI_Deinit | ( | ICM42670_ESP_SPIBus * | bus | ) |
Release ESP-IDF SPI resources owned by this adapter.
| bus | SPI bus state. |
References ICM42670_ESP_SPIBus::dev_handle, ICM42670_ESP_SPIBus::host_id, ICM42670_ESP_SPIBus::owns_bus, and ICM42670_ESP_SPIBus::owns_device.
Referenced by ICM42670_ESP_SPI_Init().
| esp_err_t ICM42670_ESP_SPI_Init | ( | ICM42670_Config * | config, |
| ICM42670_ESP_SPIBus * | bus, | ||
| spi_host_device_t | host_id, | ||
| gpio_num_t | miso_pin, | ||
| gpio_num_t | mosi_pin, | ||
| gpio_num_t | sclk_pin, | ||
| gpio_num_t | cs_pin, | ||
| int | clock_speed_hz | ||
| ) |
Create an ESP-IDF SPI bus/device and populate ICM42670_Config.
The adapter owns the created bus and device until ICM42670_ESP_SPI_Deinit() is called.
| config | Driver configuration to populate. |
| bus | SPI bus state owned by the caller. |
| host_id | ESP-IDF SPI host. |
| miso_pin | MISO GPIO. |
| mosi_pin | MOSI GPIO. |
| sclk_pin | SCLK GPIO. |
| cs_pin | Chip-select GPIO. |
| clock_speed_hz | SPI clock speed, or 0 for the default. |
References ICM42670_ESP_SPIBus::dev_handle, ICM42670_ESP_SPIBus::host_id, ICM42670_ESP_DEFAULT_SPI_SPEED_HZ, ICM42670_ESP_SPI_Deinit(), ICM42670_ESP_SPI_ReadReg(), ICM42670_ESP_SPI_WriteReg(), ICM42670_ESP_SPIBus::owns_bus, ICM42670_ESP_SPIBus::owns_device, and ICM42670_ESP_SPIBus::timeout_ms.
| int8_t ICM42670_ESP_SPI_ReadReg | ( | void * | handle, |
| uint8_t | reg_addr, | ||
| uint8_t * | data, | ||
| uint16_t | len | ||
| ) |
ESP-IDF SPI register-read callback for ICM42670_Config.
| handle | Pointer to ICM42670_ESP_SPIBus. |
| reg_addr | Register address to read from. |
| data | Destination buffer. |
| len | Number of bytes to read. |
References ICM42670_ESP_SPIBus::dev_handle, ICM42670_ERROR, and ICM42670_OK.
Referenced by ICM42670_ESP_SPI_AttachDevice(), and ICM42670_ESP_SPI_Init().
| int8_t ICM42670_ESP_SPI_WriteReg | ( | void * | handle, |
| uint8_t | reg_addr, | ||
| const uint8_t * | data, | ||
| uint16_t | len | ||
| ) |
ESP-IDF SPI register-write callback for ICM42670_Config.
| handle | Pointer to ICM42670_ESP_SPIBus. |
| reg_addr | Register address to write to. |
| data | Source buffer. |
| len | Number of bytes to write. |
References ICM42670_ESP_SPIBus::dev_handle, ICM42670_ERROR, and ICM42670_OK.
Referenced by ICM42670_ESP_SPI_AttachDevice(), and ICM42670_ESP_SPI_Init().