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