Add optional BMA456 accelerometer init on shared I2C bus.
Probe and configure the sensor when present; log and continue boot if init fails so boards without BMA456 still run normally. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+10
-1
@@ -13,6 +13,7 @@
|
||||
#include "esp_ota_ops.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/idf_additions.h"
|
||||
#include "bosch456.h"
|
||||
#include "led_ring.h"
|
||||
#include "uart.h"
|
||||
#include <stdint.h>
|
||||
@@ -76,7 +77,8 @@ void app_main(void) {
|
||||
|
||||
err = i2c_new_master_bus(&i2c_mst_config, &bus_handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGI(TAG, "I2C Master Could not Init Bus");
|
||||
ESP_LOGI(TAG, "I2C master bus init failed: %s", esp_err_to_name(err));
|
||||
bus_handle = NULL;
|
||||
}
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
@@ -110,6 +112,13 @@ void app_main(void) {
|
||||
1; // map network to 0-8, 0 is not a valid network
|
||||
}
|
||||
|
||||
if (bus_handle != NULL) {
|
||||
esp_err_t bma_err = init_bma456(bus_handle);
|
||||
if (bma_err != ESP_OK) {
|
||||
ESP_LOGI(TAG, "BMA456 init skipped: %s", esp_err_to_name(bma_err));
|
||||
}
|
||||
}
|
||||
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
|
||||
app_config.master = (master != 0);
|
||||
|
||||
Reference in New Issue
Block a user