- Renamed mamba_protocol.py → balance_protocol.py; updated all importers - can_bridge_node.py rewritten to use balance_protocol.py API (ESP32-S3 BALANCE) - test_can_bridge.py rewritten to test actual balance_protocol.py constants/functions - All STM32/Mamba references in Python, YAML, Markdown, shell scripts replaced: * Hardware: MAMBA F722S → ESP32-S3 BALANCE/IO * Device paths: /dev/stm32-bridge → /dev/esp32-io * Node names: stm32_serial_bridge → esp32_io_serial_bridge * hardware_id: stm32f722 → esp32s3-balance/esp32s3-io - C/C++ src/include/lib/test files: added DEPRECATED header comment - Covers: saltybot_bridge, saltybot_can_bridge, saltybot_can_e2e_test, saltybot_bringup, saltybot_diagnostics, saltybot_mode_switch, and all chassis, docs, scripts, and project files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
2.3 KiB
C
68 lines
2.3 KiB
C
/* DEPRECATED: STM32/Mamba firmware -- replaced by ESP32-S3. Do not modify. */
|
||
#ifndef BARO_H
|
||
#define BARO_H
|
||
|
||
#include <stdint.h>
|
||
#include <stdbool.h>
|
||
|
||
/*
|
||
* baro — BME280/BMP280 barometric pressure & ambient temperature module
|
||
* (Issue #672).
|
||
*
|
||
* Reads pressure and temperature from the BME280 at BARO_READ_HZ (1 Hz),
|
||
* computes pressure altitude using the ISA barometric formula, and publishes
|
||
* JLINK_TLM_BARO (0x8D) telemetry to the Orin at BARO_TLM_HZ (1 Hz).
|
||
*
|
||
* Runs entirely on the Mamba F722S — no Orin dependency.
|
||
* Altitude is exposed via baro_get_alt_cm() for use by slope compensation
|
||
* in the balance PID (Issue #672 requirement).
|
||
*
|
||
* Usage:
|
||
* 1. Call i2c1_init() then bmp280_init() and pass the chip_id result.
|
||
* 2. Call baro_tick(now_ms) every ms from the main loop.
|
||
* 3. Call baro_get_alt_cm() to read the latest altitude.
|
||
*/
|
||
|
||
/* ---- Configuration ---- */
|
||
#define BARO_READ_HZ 1u /* sensor poll rate (Hz) */
|
||
#define BARO_TLM_HZ 1u /* JLink telemetry rate (Hz) */
|
||
|
||
/* ---- Data ---- */
|
||
typedef struct {
|
||
int32_t pressure_pa; /* barometric pressure (Pa) */
|
||
int16_t temp_x10; /* ambient temperature (°C × 10; e.g. 235 = 23.5 °C) */
|
||
int32_t alt_cm; /* pressure altitude above ISA sea level (cm) */
|
||
int16_t humidity_pct_x10; /* %RH × 10 (BME280 only); -1 if BMP280/absent */
|
||
bool valid; /* true once at least one reading has been obtained */
|
||
} baro_data_t;
|
||
|
||
/* ---- API ---- */
|
||
|
||
/*
|
||
* baro_init(chip_id) — register chip type from bmp280_init() result.
|
||
* chip_id : 0x58 = BMP280, 0x60 = BME280, 0 = absent/not found.
|
||
* Call after i2c1_init() and bmp280_init(); no-op if chip_id == 0.
|
||
*/
|
||
void baro_init(int chip_id);
|
||
|
||
/*
|
||
* baro_tick(now_ms) — rate-limited sensor read + JLink telemetry publish.
|
||
* Call every ms from the main loop. No-op if chip absent.
|
||
* Reads at BARO_READ_HZ; sends JLINK_TLM_BARO at BARO_TLM_HZ.
|
||
*/
|
||
void baro_tick(uint32_t now_ms);
|
||
|
||
/*
|
||
* baro_get(out) — copy latest baro data into *out.
|
||
* Returns true on success; false if no valid reading yet.
|
||
*/
|
||
bool baro_get(baro_data_t *out);
|
||
|
||
/*
|
||
* baro_get_alt_cm() — latest pressure altitude (cm above ISA sea level).
|
||
* Returns 0 if no valid reading. Used by slope compensation in balance PID.
|
||
*/
|
||
int32_t baro_get_alt_cm(void);
|
||
|
||
#endif /* BARO_H */
|