34#include "freertos/FreeRTOS.h"
40static const char *TAG =
"BMA";
46static bool init_done =
false;
48esp_err_t bma423_init()
50 uint8_t address = BMA423_I2C_ADDR_SECONDARY;
52 ESP_LOGI(TAG,
"----DRIVER BMA423----");
55#if CONFIG_I2C_COMMUNICATION_METHOD_CALLBACK_RW
59 i2c_drv_device_init(address);
61 ESP_LOGI(TAG,
"Implemented using read and write callback methods");
63 ESP_LOGI(TAG,
"Initialization of BMA423 accelerometer is successful!");
65 ESP_LOGE(TAG,
"Failed to initialize the BMA423 accelerometer!");
71#if CONFIG_I2C_COMMUNICATION_METHOD_BUILTIN_RW
72#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
74 ESP_LOGI(TAG,
"Implemented using built-in read and write methods (Use higher version >= 5.0 API)");
78 extern i2c_master_bus_handle_t bus_handle;
80 if (
accel.begin(bus_handle, address)) {
81 ESP_LOGI(TAG,
"Initialization of BMA423 accelerometer is successful!");
83 ESP_LOGE(TAG,
"Failed to initialize the BMA423 accelerometer!");
89 ESP_LOGI(TAG,
"Implemented using built-in read and write methods (Use lower version < 5.0 API)");
90 if (
accel.begin((i2c_port_t)CONFIG_I2C_MASTER_PORT_NUM, address, CONFIG_SENSOR_SDA, CONFIG_SENSOR_SCL)) {
91 ESP_LOGI(TAG,
"Initialization of BMA423 accelerometer is successful!");
93 ESP_LOGE(TAG,
"Failed to initialize the BMA423 accelerometer!");
109 ESP_LOGI(
"BMA423",
"Temperature:%.2f*C",
accel.getTemperature());
uint32_t hal_callback(SensorCommCustomHal::Operation op, void *param1, void *param2)
bool i2c_wr_function(uint8_t addr, uint8_t reg, uint8_t *buf, size_t len, bool writeReg, bool isWrite)
IMUdata accel[buffer_size]