Expose MessageType 24 with protobuf response (success, x, y, z in raw LSB), firmware handler with mutex-safe I2C read, goTool `accel` CLI, and docs. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
#ifndef BOSCH456_H
|
|
#define BOSCH456_H
|
|
|
|
/**
|
|
* Powerpod driver for Bosch BMA456H (hearable variant) on the shared I2C bus.
|
|
*
|
|
* Vendor API: components/bma456 (bma4.c + bma456h.c only).
|
|
* Implementation: bosch456.c
|
|
*/
|
|
|
|
#include "driver/i2c_types.h"
|
|
#include "esp_err.h"
|
|
|
|
/** 7-bit I2C address (SDO low). */
|
|
#define BMA456_I2C_ADDR 0x18
|
|
|
|
/** Sensor interrupt line → ESP32 GPIO (active high, rising edge). */
|
|
#define BMA456_INT_GPIO 10
|
|
|
|
/** Software filter: log accel only when |axis - last| > deadzone (raw LSB). */
|
|
#define BMA456_DEFAULT_ACCEL_DEADZONE 100u
|
|
|
|
/**
|
|
* Probe and configure the sensor on bus_handle (100 kHz device).
|
|
* On failure the device is removed and ESP_ERR_NOT_FOUND / ESP_FAIL is returned;
|
|
* firmware continues without a sensor (see bma456_is_ready()).
|
|
*/
|
|
esp_err_t init_bma456(i2c_master_bus_handle_t bus_handle);
|
|
|
|
bool bma456_is_ready(void);
|
|
|
|
void bma456_set_accel_deadzone(uint32_t deadzone_lsb);
|
|
uint32_t bma456_get_accel_deadzone(void);
|
|
|
|
/** Log accel when any axis moved more than deadzone since last reported sample. */
|
|
void bma456_report_accel_if_changed(int16_t x, int16_t y, int16_t z);
|
|
|
|
/** On-demand read of current accel XYZ (raw LSB). Returns ESP_ERR_INVALID_STATE if sensor not ready. */
|
|
esp_err_t bma456_read_accel(int16_t *x, int16_t *y, int16_t *z);
|
|
|
|
#endif
|