a121_sys/
lib.rs

1#![cfg_attr(not(any(test, feature = "std")), no_std)]
2#![allow(non_upper_case_globals)]
3#![allow(non_camel_case_types)]
4#![allow(non_snake_case)]
5#![allow(improper_ctypes)]
6#![allow(dead_code)]
7
8//! # a121-sys Crate Documentation
9//!
10//! Welcome to the `a121-sys` crate, providing raw FFI bindings for the Acconeer A121 radar sensor.
11//! This crate offers low-level access to the A121 sensor's capabilities, designed for embedded systems
12//! and `no_std` environments.
13//!
14//! ## Usage
15//!
16//! Add `a121-sys` to your `Cargo.toml`:
17//!
18//! ```toml
19//! [dependencies]
20//! # For real hardware
21//! a121-sys = { version = "0.5", features = ["distance", "presence"] }
22//!
23//! # For testing/development with stub library
24//! a121-sys = { version = "0.5", features = ["stub_library", "distance", "presence"] }
25//! ```
26//!
27//! ## Features
28//!
29//! - **distance**: Enable distance measurement functionality
30//! - **presence**: Enable presence detection functionality
31//! - **stub_library**: Use stub implementations for testing/development without hardware
32//! - **std**: Enable functionality requiring the standard library
33//!
34//! ## Library Requirements
35//!
36//! This crate requires the Acconeer A121 static libraries and the `arm-none-eabi-gcc` toolchain. You can either:
37//!
38//! 1. Use the real libraries:
39//!    - Obtain the official Acconeer A121 SDK
40//!    - Set `ACC_RSS_LIBS` environment variable to the library location
41//!
42//! 2. Use stub libraries (for testing/development):
43//!    - Enable the `stub_library` feature
44//!
45//! ## Logging Integration
46//!
47//! The crate provides a way to integrate with the sensor's native logging through a C log wrapper.
48//! Implement the `rust_log` function to capture log messages:
49//!
50//! ```no_run
51//! use core::ffi::c_char;
52//!
53//! #[no_mangle]
54//! pub extern "C" fn rust_log(level: u32, message: *const c_char) {
55//!     // Your logging implementation here
56//! }
57//! ```
58//!
59//! ## Embedded Usage
60//!
61//! The crate is designed for embedded systems and supports:
62//!
63//! - `no_std` environments
64//! - Cortex-M4 targets (specifically `thumbv7em-none-eabihf`, or risc)
65//! - Both real hardware and stub implementations
66//!
67//! Example target configuration:
68//!
69//! ```toml
70//! [build]
71//! target = "thumbv7em-none-eabihf"
72//!
73//! [target.thumbv7em-none-eabihf]
74//! rustflags = [
75//!     "-C", "link-arg=-mcpu=cortex-m4",
76//!     "-C", "link-arg=-mthumb",
77//!     "-C", "link-arg=-mfloat-abi=hard",
78//!     "-C", "link-arg=-mfpu=fpv4-sp-d16",
79//! ]
80//! ```
81//!
82//! ## Safety
83//!
84//! This crate provides raw FFI bindings which are inherently unsafe. Users should:
85//!
86//! - Take care when implementing the logging callback
87//! - Ensure proper initialization of the sensor
88//! - Follow proper memory management practices
89//! - Consider using higher-level safe wrappers (like the `a121` crate)
90//!
91//! ## Development and Testing
92//!
93//! For development without hardware:
94//!
95//! 1. Enable the stub library feature:
96//!    ```toml
97//!    a121-sys = { version = "0.5", features = ["stub_library"] }
98//!    ```
99//!
100//! 2. Install required toolchain:
101//!    ```bash
102//!    rustup target add thumbv7em-none-eabihf
103//!    # Install ARM GCC toolchain for your platform
104//!    ```
105//!
106//! ## Environment Variables
107//!
108//! - `ACC_RSS_LIBS`: Path to the Acconeer A121 libraries
109//! - `CPATH`: Additional C header paths (usually set automatically)
110//!
111//! ## Version Compatibility
112//!
113//! - Current bindings version: 1.8.0
114//! - Minimum Supported Rust Version (MSRV): 1.82.0
115//!
116
117use core::concat;
118use core::env;
119use core::include;
120
121include!(concat!(env!("OUT_DIR"), "/bindings.rs"));