Smart sensor data access though on-board MCU

Problem Statement:
I am developing support for a new sensor module that combines both differential pressure (airspeed) and static pressure (baro) sensing with an onboard MCU. The sensor outputs a single 56-byte packet containing all measurements via I2C. Current architecture requires separate drivers in AP_Airspeed and AP_Baro, which creates challenges for:

  1. Coordinated access to the shared I2C device
  2. Maintaining data consistency between modules
  3. Managing different update rate requirements

Proposed Solution:
Create a new parent driver architecture with the following components:

  1. New Library: AP_I2C_Sensors (or AP_CombinedSensors)
  • Location: libraries/AP_I2C_Sensors/
  • Contains AP_IADP_Singular as a singleton managing the physical sensor
  1. Parent Driver Features:
  • Implements single periodic callback (50Hz)
  • Handles all I2C communication
  • Parses complete sensor packet
  • Provides thread-safe data access methods
  • Supports different effective update rates for children
  1. Child Drivers:
  • AP_Airspeed_IADP: Gets differential pressure (50Hz)
  • AP_Baro_IADP: Gets static pressure/temperature (10Hz)

Technical Benefits:

  1. Clean Architecture: Separation of hardware access from sensor-specific logic
  2. Thread Safety: Single point of synchronization
  3. Efficiency: No duplicate I2C transactions
  4. Maintainability: Changes isolated to one driver
  5. Flexibility: Adaptable to similar combined sensors

Implementation Details:

  1. New files:
  • libraries/AP_I2C_Sensors/AP_IADP_Singular.{h,cpp}
  1. Modified files:
  • Child drivers in AP_Airspeed and AP_Baro
  1. Build system updates

Request for Feedback:

  1. Is the proposed library location appropriate?
  2. Any concerns about the singleton pattern for hardware access?
  3. Has anyone implemented a singleton/shared proxy backend that provides data to multiple ArduPilot frontend modules?
  4. Is there a preferred pattern for this? (e.g., global registration, proxy routing, HAL device sharing?)
  5. Should I manage my own static instance of the backend, or hook it in via a dedicated sensor manager?

Example Usage:

// Parent driver
auto sensor = AP_IADP_Singular::get_instance();
sensor->init(bus, address);

// Airspeed child
float diff_press;
sensor->get_differential_pressure(diff_press);

// Baro child 
float static_press, temp;
sensor->get_static_pressure(static_press);
sensor->get_temperature(temp);

Cheers,
Theodosis