How wyatt-mattas/bmi323-rs works
Main Components
• BMI323 Driver Core: Represent the central library (located in src/lib.rs) that binds together all the driver functionality.
• Device & Interface Modules: Show the modules that manage low-level operations – notably, the device.rs (likely handling initialization and device-specific logic), interface.rs (defining communication methods), registers.rs (abstraction of sensor registers), sensor_data.rs (handling raw and processed sensor data), and types.rs (defining data types and configurations).
• Configuration & Initialization: Include the initialization flow (init() method in the device abstraction) and configuration of sensor parameters (accelerometer and gyroscope via builder patterns in AccelConfig and GyroConfig).
• Examples: Diagrammatically illustrate the two example implementations:
• embassy-stm32-implementation: Likely demonstrating integration with the Embassy ecosystem on STM32 boards.
• peripheral-crate-implementation: Illustrating another approach (possibly using direct hardware abstraction) including a memory.x linker script and custom build.rs.
• Testing: Show that the project incorporates a test suite with both integration and unit tests (located in the tests directory).
Relationships and Data Flow
• Testing and Examples Integration: Represent examples as distinct nodes that make use of the driver core, demonstrating how the configuration and reading functions are utilized. Similarly, include a node for "Tests" that validate various components (unit and integration tests).
Architectural Patterns & Design Principles
• Modularity: Emphasize how the project is divided into distinct modules, each handling a separate concern (communication, device state, register mapping, and sensor data processing).
• Abstraction Layers: Illustrate the use of abstraction (via traits or wrapper interfaces) that decouples hardware-specific details from generic driver logic.
• Builder Pattern: Note the use of builder patterns in configuration structures (for accelerometer and gyroscope settings) ensuring that configurations are validated and set in a controlled manner.
• Dependency Injection: Point out that the embedded_hal (and possibly other dependency injection patterns) allow the driver to be hardware-agnostic.
Relevant Technologies, Frameworks, or Libraries
• Rust and Cargo: Indicate that the project is built using Rust (Cargo.toml, Cargo.lock).
• Embedded HAL: This is a key external dependency for handling I2C/SPI abstractions.
• Example Integrations: Reference the embassy-stm32 and peripheral crate examples, which show real-world hardware integrations and how the driver can be practically used.
Putting It All Together
• Follow that with the "BMI323 Driver Core" that interacts with the HAL and consists of multiple internal modules (device, interface, registers, sensor_data, types).