mlx90393 0.1.2

MLX90393 magnetometer driver
Documentation
// MLX90393 registers

#![allow(nonstandard_style)]
pub const GAIN_REGISTER: u8 = 0x00;
pub const RES_XYZ_REGISTER: u8 = 0x02;
pub const DIGITAL_FILTER_REGISTER: u8 = 0x02;  // yes, same as above, better read this way
pub const REGISTER_01: u8 = 0x01;
pub const REGISTER_00: u8 = 0x00;
pub const REGISTER_03: u8 = 0x03;
pub const REGISTER_04: u8 = 0x04;
pub const REGISTER_05: u8 = 0x05;
pub const REGISTER_06: u8 = 0x06;
pub const REGISTER_07: u8 = 0x07;
pub const REGISTER_08: u8 = 0x08;
pub const REGISTER_09: u8 = 0x09;


/// commands
pub const Start_Burst_Mode: u8 = 0b00010000;  /// 0b0001zyxt
pub const Start_Wake_On_Change: u8 = 0b00100000; /// 0b0010zyxt
pub const Start_Single_Measurement: u8 = 0b00110000; /// 0b0011zyxt
pub const Read_Measurement: u8 = 0b01000000; /// 0b0100zyxt
pub const Read_Register: u8 = 0b01010000;  /// 0b01010abc
pub const Write_Register: u8 = 0b01100000; /// 0b01100abc
pub const Exit_mode: u8 = 0b1000_0000;
pub const Memory_Recall: u8 = 0b11010000;
pub const Memory_Store: u8 = 0b11100000;
pub const Reset: u8 = 0b11110000;



#[repr(u8)]
/// MlX90393 I2C device addresses
#[derive(Debug, Clone, Copy, Default)]
pub enum DeviceAddress {
    #[default]
    A1_0_A0_0 = 0x0c,
    A1_0_A0_1 = 0x0c|0x01,
    A1_1_A0_0 = 0x0c|0x02,
    A1_1_A0_1 = 0x0c|0x03,
}

impl From<DeviceAddress> for u8 {
    fn from(value: DeviceAddress) -> Self {
        match value {
            DeviceAddress::A1_0_A0_0 => 0x0c,
            DeviceAddress::A1_0_A0_1 => 0x0c | 0x01,
            DeviceAddress::A1_1_A0_0 => 0x0c | 0x02,
            DeviceAddress::A1_1_A0_1 => 0x0c | 0x03,
        }
    }
}

pub const SENS_XY: [f32; 8] = [0.751, 0.601, 0.451, 0.376, 0.300, 0.250, 0.200, 0.150];
pub const SENS_Z:  [f32; 8] = [1.210, 0.968, 0.726, 0.605, 0.484, 0.403, 0.323, 0.242];