AS5600_Driver/lib.rs
1//! # AS5600 Driver
2//!
3//! A platform-agnostic Rust driver for the AS5600 magnetic rotary encoder,
4//! based on the `embedded-hal` traits.
5//!
6//! The AS5600 is a contactless magnetic rotary encoder with high-resolution 12-bit
7//! contactless on-axis angular position measurement over a full turn of 360°.
8//!
9//! ## Features
10//! - Read raw and filtered angle (12-bit resolution)
11//! - Configure power modes, hysteresis, and filters
12//! - Read magnet status (detected, too weak, too strong)
13//! - Automatic Gain Control (AGC) and Magnitude reading
14//! - Programming support (ZPOS, MPOS, MANG, and permanent BURN)
15//! - Mock driver for testing and simulation
16//!
17//! ## Example (ESP32)
18//! ```rust,ignore
19//! use AS5600_Driver::{AS5600Driver, AS5600Interface};
20//!
21//! // Setup I2C from your HAL
22//! let i2c = ...;
23//! let mut sensor = AS5600Driver::new(i2c);
24//!
25//! match sensor.read_angle() {
26//! Ok(angle) => println!("Angle: {}", angle),
27//! Err(e) => eprintln!("Error: {:?}", e),
28//! }
29//! ```
30
31#![no_std]
32#![allow(non_snake_case)]
33
34#[cfg(feature = "std")]
35extern crate std;
36
37pub mod driver;
38pub mod error;
39pub mod regs;
40pub mod traits;
41pub mod types;
42
43#[cfg(feature = "mock")]
44pub mod mock;
45
46// Re-exports for convenience
47pub use driver::AS5600Driver;
48pub use error::AS56Error;
49pub use regs::*;
50pub use traits::AS5600Interface;
51pub use types::*;
52
53#[cfg(feature = "mock")]
54pub use mock::AS56Mock;