#![no_std]
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, doc(auto_cfg))]
macro_rules! defmt_trace {
($($arg:tt)*) => {
#[cfg(all(feature = "defmt", not(test)))]
defmt::trace!($($arg)*);
};
}
macro_rules! defmt_debug {
($($arg:tt)*) => {
#[cfg(all(feature = "defmt", not(test)))]
defmt::debug!($($arg)*);
};
}
macro_rules! defmt_warn {
($($arg:tt)*) => {
#[cfg(all(feature = "defmt", not(test)))]
defmt::warn!($($arg)*);
};
}
macro_rules! defmt_error {
($($arg:tt)*) => {
#[cfg(all(feature = "defmt", not(test)))]
defmt::error!($($arg)*);
};
}
macro_rules! impl_try_from_u8 {
($enum:ty { $($val:expr => $variant:ident),+ $(,)? }) => {
impl TryFrom<u8> for $enum {
type Error = u8;
fn try_from(val: u8) -> Result<Self, u8> {
match val {
$($val => Ok(Self::$variant),)+
other => {
defmt_warn!("invalid register value: 0x{:02X}", other);
Err(other)
}
}
}
}
};
($struct:ty) => {
impl TryFrom<u8> for $struct {
type Error = u8;
fn try_from(val: u8) -> Result<Self, u8> {
match Self::from_code(val) {
Some(val) => Ok(val),
None => {
defmt_warn!("invalid register value: 0x{:02X}", val);
Err(val)
}
}
}
}
};
}
mod config;
mod device;
mod error;
mod register;
mod rotation;
mod types;
#[cfg(feature = "libm")]
mod angle;
#[cfg(feature = "libm")]
pub use angle::{AxisCalibrator, AxisRecommendation, PlaneAngle, PlaneAngles, PlaneAxis, Welford};
pub use config::{
CalibrationConfig, Config, ConfigBuilder, InterruptConfig, ThresholdConfig, ThresholdHysteresis,
};
pub use device::{Configured, Tmag5273, Unconfigured};
pub use error::{ConfigError, Error, InitError};
pub use rotation::{Cordic, CordicTracker, RotationTracker, TrackingMode, ZeroCrossing};
pub use types::{
AngleEnable, AngleReading, Axis, Celsius, ConversionAverage, ConversionStatus, CordicMagnitude,
Crossings, Degrees, DeviceStatus, DeviceVariant, Diagnostics, I2cReadMode, InterruptMode,
InterruptState, Lsb, MagneticChannel, MagneticGainChannel, MagneticReading,
MagneticTempCoefficient, MagneticThresholdDirection, MicrosIsr, MicrosRange, MilliTesla,
NoDelay, OperatingMode, PoleCount, PowerNoiseMode, Range, Rpm, SensorReading, SignedDegrees,
SleepTime, TempThresholdConfig, ThresholdCrossingCount, TriggerMode, WAKE_DELAY,
WAKE_RETRY_DELAY,
};