Add UART ACCEL_READ command for on-demand BMA456 samples.

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>
This commit is contained in:
2026-05-28 19:55:02 +02:00
co-authored by Cursor
parent 16c521f71c
commit ba20544762
16 changed files with 479 additions and 99 deletions
+34
View File
@@ -0,0 +1,34 @@
#include "bosch456.h"
#include "cmd_accel_read.h"
#include "uart_cmd.h"
static const char *TAG = "[ACCEL_READ]";
static void reply(bool success, int16_t x, int16_t y, int16_t z) {
alox_UartMessage response;
uart_cmd_init_response(&response, alox_MessageType_ACCEL_READ,
alox_UartMessage_accel_read_response_tag);
response.payload.accel_read_response.success = success;
response.payload.accel_read_response.x = x;
response.payload.accel_read_response.y = y;
response.payload.accel_read_response.z = z;
uart_cmd_send(&response, TAG);
}
static void handle_accel_read(const uint8_t *data, size_t len) {
(void)data;
(void)len;
int16_t x = 0;
int16_t y = 0;
int16_t z = 0;
if (bma456_read_accel(&x, &y, &z) == ESP_OK) {
reply(true, x, y, z);
return;
}
reply(false, 0, 0, 0);
}
void cmd_accel_read_register(void) {
uart_cmd_register(alox_MessageType_ACCEL_READ, handle_accel_read);
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef CMD_ACCEL_READ_H
#define CMD_ACCEL_READ_H
void cmd_accel_read_register(void);
#endif
+2
View File
@@ -48,6 +48,8 @@ static const char *message_type_name(uint16_t id) {
return "FIND_ME";
case alox_MessageType_RESTART:
return "RESTART";
case alox_MessageType_ACCEL_READ:
return "ACCEL_READ";
default:
return "UNKNOWN";
}