use super::super::{
BusOperation, DelayNs, Error, Lis2dux12, PROPERTY_ENABLE, RegisterOperation, SensorOperation,
bisync,
register::{BankState, MainBank},
};
use bitfield_struct::bitfield;
use derive_more::TryFrom;
use st_mem_bank_macro::register;
#[repr(u8)]
#[derive(Clone, Copy, PartialEq)]
pub enum Reg {
ExtClkCfg = 0x08,
PinCtrl = 0x0C,
WakeUpDurExt = 0x0E,
WhoAmI = 0x0F,
Ctrl1 = 0x10,
Ctrl2 = 0x11,
Ctrl3 = 0x12,
Ctrl4 = 0x13,
Ctrl5 = 0x14,
FifoCtrl = 0x15,
FifoWtm = 0x16,
InterruptCfg = 0x17,
Sixd = 0x18,
WakeUpThs = 0x1C,
WakeUpDur = 0x1D,
FreeFall = 0x1E,
Md1Cfg = 0x1F,
Md2Cfg = 0x20,
WakeUpSrc = 0x21,
TapSrc = 0x22,
SixdSrc = 0x23,
AllIntSrc = 0x24,
Status = 0x25,
FifoStatus1 = 0x26,
FifoStatus2 = 0x27,
OutXL = 0x28,
OutXH = 0x29,
OutYL = 0x2A,
OutYH = 0x2B,
OutZL = 0x2C,
OutZH = 0x2D,
OutTL = 0x2E,
OutTH = 0x2F,
SelfTest = 0x32,
I3cIfCtrl = 0x33,
EmbFuncStatusMainpage = 0x34,
FsmStatusMainpage = 0x35,
MlcStatusMainpage = 0x36,
Sleep = 0x3D,
EnDeviceConfig = 0x3E,
FuncCfgAccess = 0x3F,
FifoDataOutTag = 0x40,
FifoDataOutXL = 0x41,
FifoDataOutXH = 0x42,
FifoDataOutYL = 0x43,
FifoDataOutYH = 0x44,
FifoDataOutZL = 0x45,
FifoDataOutZH = 0x46,
FifoBatchDec = 0x47,
TapCfg0 = 0x6F,
TapCfg1 = 0x70,
TapCfg2 = 0x71,
TapCfg3 = 0x72,
TapCfg4 = 0x73,
TapCfg5 = 0x74,
TapCfg6 = 0x75,
Timestamp0 = 0x7A,
Timestamp1 = 0x7B,
Timestamp2 = 0x7C,
Timestamp3 = 0x7D,
}
#[register(address = Reg::WhoAmI, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WhoAmI {
#[bits(8, default = 0x47, access = RO)]
pub id: u8,
}
#[register(address = Reg::ExtClkCfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct ExtClkCfg {
#[bits(7, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub ext_clk_en: u8,
}
#[register(address = Reg::PinCtrl, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct PinCtrl {
#[bits(1)]
pub sim: u8,
#[bits(1)]
pub pp_od: u8,
#[bits(1)]
pub cs_pu_dis: u8,
#[bits(1)]
pub h_lactive: u8,
#[bits(1)]
pub pd_dis_int1: u8,
#[bits(1)]
pub pd_dis_int2: u8,
#[bits(1)]
pub sda_pu_en: u8,
#[bits(1)]
pub sdo_pu_en: u8,
}
#[register(address = Reg::WakeUpDurExt, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpDurExt {
#[bits(4, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub wu_dur_extended: u8,
#[bits(3, access = RO, default = 0)]
not_used1: u8,
}
#[register(address = Reg::Ctrl1, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl1 {
#[bits(1)]
pub wu_z_en: u8,
#[bits(1)]
pub wu_y_en: u8,
#[bits(1)]
pub wu_x_en: u8,
#[bits(1)]
pub drdy_pulsed: u8,
#[bits(1, default = 1)]
pub if_add_inc: u8,
#[bits(1)]
pub sw_reset: u8,
#[bits(1)]
pub int1_on_res: u8,
#[bits(1)]
pub smart_power_en: u8,
}
#[register(address = Reg::Ctrl2, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl2 {
#[bits(3, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub int1_drdy: u8,
#[bits(1)]
pub int1_fifo_ovr: u8,
#[bits(1)]
pub int1_fifo_th: u8,
#[bits(1)]
pub int1_fifo_full: u8,
#[bits(1)]
pub int1_boot: u8,
}
#[register(address = Reg::Ctrl3, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl3 {
#[bits(1)]
pub st_sign_x: u8,
#[bits(1)]
pub st_sign_y: u8,
#[bits(1)]
pub hp_en: u8,
#[bits(1)]
pub int2_drdy: u8,
#[bits(1)]
pub int2_fifo_ovr: u8,
#[bits(1)]
pub int2_fifo_th: u8,
#[bits(1)]
pub int2_fifo_full: u8,
#[bits(1)]
pub int2_boot: u8,
}
#[register(address = Reg::Ctrl4, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl4 {
#[bits(1)]
pub boot: u8,
#[bits(1)]
pub soc: u8,
#[bits(1, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub fifo_en: u8,
#[bits(1)]
pub emb_func_en: u8,
#[bits(1)]
pub bdu: u8,
#[bits(2)]
pub inact_odr: u8,
}
#[register(address = Reg::Ctrl5, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl5 {
#[bits(2)]
pub fs: u8,
#[bits(2)]
pub bw: u8,
#[bits(4)]
pub odr: u8,
}
#[register(address = Reg::FifoCtrl, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoCtrl {
#[bits(3)]
pub fifo_mode: u8,
#[bits(1)]
pub stop_on_fth: u8,
#[bits(1, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub dis_hard_rst_cs: u8,
#[bits(1)]
pub fifo_depth: u8,
#[bits(1)]
pub cfg_chg_en: u8,
}
#[register(address = Reg::FifoWtm, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoWtm {
#[bits(7)]
pub fth: u8,
#[bits(1)]
pub xl_only_fifo: u8,
}
#[register(address = Reg::InterruptCfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct InterruptCfg {
#[bits(1)]
pub interrupts_enable: u8,
#[bits(1)]
pub lir: u8,
#[bits(1)]
pub dis_rst_lir_all_int: u8,
#[bits(1)]
pub sleep_status_on_int: u8,
#[bits(1, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub wake_ths_w: u8,
#[bits(1, access = RO, default = 0)]
not_used1: u8,
#[bits(1)]
pub timestamp_en: u8,
}
#[register(address = Reg::Sixd, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Sixd {
#[bits(5, access = RO, default = 0)]
not_used0: u8,
#[bits(2)]
pub d6d_ths: u8,
#[bits(1)]
pub d4d_en: u8,
}
#[register(address = Reg::WakeUpThs, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpThs {
#[bits(6)]
pub wk_ths: u8,
#[bits(1)]
pub sleep_on: u8,
#[bits(1, access = RO, default = 0)]
not_used0: u8,
}
#[register(address = Reg::WakeUpDur, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpDur {
#[bits(4)]
pub sleep_dur: u8,
#[bits(1)]
pub st_sign_z: u8,
#[bits(2)]
pub wake_dur: u8,
#[bits(1)]
pub ff_dur: u8,
}
#[register(address = Reg::FreeFall, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FreeFall {
#[bits(3)]
pub ff_ths: u8,
#[bits(5)]
pub ff_dur: u8,
}
#[register(address = Reg::Md1Cfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Md1Cfg {
#[bits(1)]
pub int1_emb_func: u8,
#[bits(1)]
pub int1_timestamp: u8,
#[bits(1)]
pub int1_6d: u8,
#[bits(1)]
pub int1_tap: u8,
#[bits(1)]
pub int1_ff: u8,
#[bits(1)]
pub int1_wu: u8,
#[bits(1, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub int1_sleep_change: u8,
}
#[register(address = Reg::Md2Cfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Md2Cfg {
#[bits(1)]
pub int2_emb_func: u8,
#[bits(1)]
pub int2_timestamp: u8,
#[bits(1)]
pub int2_6d: u8,
#[bits(1)]
pub int2_tap: u8,
#[bits(1)]
pub int2_ff: u8,
#[bits(1)]
pub int2_wu: u8,
#[bits(1, access = RO, default = 0)]
not_used0: u8,
#[bits(1)]
pub int2_sleep_change: u8,
}
#[register(address = Reg::WakeUpSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpSrc {
#[bits(1)]
pub z_wu: u8,
#[bits(1)]
pub y_wu: u8,
#[bits(1)]
pub x_wu: u8,
#[bits(1)]
pub wu_ia: u8,
#[bits(1)]
pub sleep_state: u8,
#[bits(1)]
pub ff_ia: u8,
#[bits(1)]
pub sleep_change_ia: u8,
#[bits(1, access = RO)]
not_used0: u8,
}
#[register(address = Reg::TapSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapSrc {
#[bits(4, access = RO)]
not_used0: u8,
#[bits(1, access = RO)]
pub triple_tap_ia: u8,
#[bits(1, access = RO)]
pub double_tap_ia: u8,
#[bits(1, access = RO)]
pub single_tap_ia: u8,
#[bits(1, access = RO)]
pub tap_ia: u8,
}
#[register(address = Reg::SixdSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct SixdSrc {
#[bits(1, access = RO)]
pub xl: u8,
#[bits(1, access = RO)]
pub xh: u8,
#[bits(1, access = RO)]
pub yl: u8,
#[bits(1, access = RO)]
pub yh: u8,
#[bits(1, access = RO)]
pub zl: u8,
#[bits(1, access = RO)]
pub zh: u8,
#[bits(1, access = RO)]
pub d6d_ia: u8,
#[bits(1, access = RO)]
not_used0: u8,
}
#[register(address = Reg::AllIntSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct AllIntSrc {
#[bits(1, access = RO)]
pub ff_ia_all: u8,
#[bits(1, access = RO)]
pub wu_ia_all: u8,
#[bits(1, access = RO)]
pub single_tap_all: u8,
#[bits(1, access = RO)]
pub double_tap_all: u8,
#[bits(1, access = RO)]
pub triple_tap_all: u8,
#[bits(1, access = RO)]
pub d6d_ia_all: u8,
#[bits(1, access = RO)]
pub sleep_change_ia_all: u8,
#[bits(1, access = RO)]
not_used0: u8,
}
#[register(address = Reg::Status, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct StatusRegister {
#[bits(1, access = RO)]
pub drdy: u8,
#[bits(4, access = RO)]
not_used0: u8,
#[bits(1, access = RO)]
pub int_global: u8,
#[bits(2, access = RO)]
not_used1: u8,
}
#[register(address = Reg::FifoStatus1, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoStatus1 {
#[bits(6, access = RO)]
not_used0: u8,
#[bits(1, access = RO)]
pub fifo_ovr_ia: u8,
#[bits(1, access = RO)]
pub fifo_wtm_ia: u8,
}
#[register(address = Reg::FifoStatus2, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoStatus2 {
#[bits(8, access = RO)]
pub fss: u8,
}
#[register(address = Reg::OutXL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutX {
#[bits(16, access = RO)]
pub outx: u16,
}
#[register(address = Reg::OutYL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutY {
#[bits(16, access = RO)]
pub outy: u16,
}
#[register(address = Reg::OutZL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutZ {
#[bits(16, access = RO)]
pub outz: u16,
}
#[register(address = Reg::OutTL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutT {
#[bits(16, access = RO)]
pub outt: u16,
}
#[register(address = Reg::SelfTest, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct SelfTest {
#[bits(1)]
pub t_dis: u8,
#[bits(3, access = RO)]
not_used0: u8,
#[bits(2)]
pub st: u8,
#[bits(2, access = RO)]
not_used1: u8,
}
#[register(address = Reg::I3cIfCtrl, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct I3cIfCtrl {
#[bits(2, default = 0b01)]
pub bus_act_sel: u8,
#[bits(3, access = RO)]
not_used0: u8,
#[bits(1)]
pub asf_on: u8,
#[bits(1, access = RO)]
not_used1: u8,
#[bits(1)]
pub dis_drstdaa: u8,
}
#[register(address = Reg::EmbFuncStatusMainpage, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct EmbFuncStatusMainpage {
#[bits(3, access = RO)]
not_used0: u8,
#[bits(1, access = RO)]
pub is_step_det: u8,
#[bits(1, access = RO)]
pub is_tilt: u8,
#[bits(1, access = RO)]
pub is_sigmot: u8,
#[bits(1, access = RO)]
not_used1: u8,
#[bits(1, access = RO)]
pub is_fsm_lc: u8,
}
#[register(address = Reg::FsmStatusMainpage, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FsmStatusMainpage {
#[bits(1, access = RO)]
pub is_fsm1: u8,
#[bits(1, access = RO)]
pub is_fsm2: u8,
#[bits(1, access = RO)]
pub is_fsm3: u8,
#[bits(1, access = RO)]
pub is_fsm4: u8,
#[bits(1, access = RO)]
pub is_fsm5: u8,
#[bits(1, access = RO)]
pub is_fsm6: u8,
#[bits(1, access = RO)]
pub is_fsm7: u8,
#[bits(1, access = RO)]
pub is_fsm8: u8,
}
#[register(address = Reg::MlcStatusMainpage, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct MlcStatusMainpage {
#[bits(1, access = RO)]
pub is_mlc1: u8,
#[bits(1, access = RO)]
pub is_mlc2: u8,
#[bits(1, access = RO)]
pub is_mlc3: u8,
#[bits(1, access = RO)]
pub is_mlc4: u8,
#[bits(4, access = RO)]
not_used0: u8,
}
#[register(address = Reg::Sleep, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Sleep {
#[bits(1)]
pub deep_pd: u8,
#[bits(7, access = RO, default = 0)]
not_used0: u8,
}
#[register(address = Reg::EnDeviceConfig, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct EnDeviceConfig {
#[bits(1, access = WO)]
pub soft_pd: u8,
#[bits(7, access = RO)]
not_used0: u8,
}
#[register(address = Reg::FuncCfgAccess, access_type = "Lis2dux12<B, T, S>", multi_state = true)]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FuncCfgAccess {
#[bits(1)]
pub fsm_wr_ctrl_en: u8,
#[bits(6, access = RO)]
not_used0: u8,
#[bits(1)]
pub emb_func_reg_access: u8,
}
#[register(address = Reg::FifoDataOutTag, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutTag {
#[bits(3, access = RO)]
not_used0: u8,
#[bits(5)]
pub tag_sensor: u8,
}
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutXL {
#[bits(8)]
pub fifo_data_out: u8,
}
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutXH {
#[bits(8)]
pub fifo_data_out: u8,
}
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutYL {
#[bits(8)]
pub fifo_data_out: u8,
}
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutYH {
#[bits(8)]
pub fifo_data_out: u8,
}
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutZL {
#[bits(8)]
pub fifo_data_out: u8,
}
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutZH {
#[bits(8)]
pub fifo_data_out: u8,
}
#[register(address = Reg::FifoBatchDec, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoBatchDec {
#[bits(3)]
pub bdr_xl: u8,
#[bits(2)]
pub dec_ts_batch: u8,
#[bits(3, access = RO)]
not_used0: u8,
}
#[register(address = Reg::TapCfg0, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg0 {
#[bits(1, access = RO)]
not_used0: u8,
#[bits(5)]
pub invert_t: u8,
#[bits(2)]
pub axis: u8,
}
#[register(address = Reg::TapCfg1, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg1 {
#[bits(4)]
pub post_still_t: u8,
#[bits(4)]
pub pre_still_ths: u8,
}
#[register(address = Reg::TapCfg2, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg2 {
#[bits(6)]
pub wait_t: u8,
#[bits(2)]
pub post_still_t: u8,
}
#[register(address = Reg::TapCfg3, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg3 {
#[bits(4)]
pub latency_t: u8,
#[bits(4)]
pub post_still_ths: u8,
}
#[register(address = Reg::TapCfg4, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg4 {
#[bits(6)]
pub peak_ths: u8,
#[bits(1, access = RO)]
not_used0: u8,
#[bits(1)]
pub wait_end_latency: u8,
}
#[register(address = Reg::TapCfg5, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg5 {
#[bits(5)]
pub rebound_t: u8,
#[bits(1)]
pub single_tap_en: u8,
#[bits(1)]
pub double_tap_en: u8,
#[bits(1)]
pub triple_tap_en: u8,
}
#[register(address = Reg::TapCfg6, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg6 {
#[bits(4)]
pub pre_still_n: u8,
#[bits(4)]
pub pre_still_st: u8,
}
#[register(address = Reg::Timestamp0, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u32, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u32, order = Lsb))]
pub struct Timestamp {
#[bits(32, access = RO)]
pub timestamp: u32,
}
pub struct Status {
pub sw_reset: u8,
pub boot: u8,
pub drdy: u8,
}
#[derive(Default)]
pub struct Md {
pub odr: Odr,
pub fs: Fs,
pub bw: Bw,
}
pub struct AllSources {
pub drdy: u8,
pub free_fall: u8,
pub wake_up: u8,
pub wake_up_z: u8,
pub wake_up_y: u8,
pub wake_up_x: u8,
pub single_tap: u8,
pub double_tap: u8,
pub triple_tap: u8,
pub six_d: u8,
pub six_d_xl: u8,
pub six_d_xh: u8,
pub six_d_yl: u8,
pub six_d_yh: u8,
pub six_d_zl: u8,
pub six_d_zh: u8,
pub sleep_change: u8,
pub sleep_state: u8,
}
pub struct XlData {
pub mg: [f32; 3],
pub raw: [i16; 3],
}
pub struct I3cCfg {
pub bus_act_sel: BusActSel,
pub asf_on: u8,
pub drstdaa_dis: u8,
}
pub struct PinConf {
pub sdo_pull_up: u8,
pub sda_pull_up: u8,
pub cs_pull_up: u8,
pub int1_int2_push_pull: u8,
pub int1_pull_down: u8,
pub int2_pull_down: u8,
}
#[derive(Default)]
pub struct PinInt1Route {
pub int_on_res: u8,
pub drdy: u8,
pub boot: u8,
pub fifo_th: u8,
pub fifo_ovr: u8,
pub fifo_full: u8,
pub free_fall: u8,
pub six_d: u8,
pub tap: u8,
pub wake_up: u8,
pub sleep_change: u8,
pub emb_function: u8,
pub timestamp: u8,
}
#[derive(Default)]
pub struct PinInt2Route {
pub drdy: u8,
pub boot: u8,
pub fifo_th: u8,
pub fifo_ovr: u8,
pub fifo_full: u8,
pub free_fall: u8,
pub six_d: u8,
pub tap: u8,
pub wake_up: u8,
pub sleep_change: u8,
pub emb_function: u8,
pub timestamp: u8,
}
#[derive(Default)]
pub struct IntConfig {
pub int_cfg: IntCfg,
pub sleep_status_on_int: u8,
pub dis_rst_lir_all_int: u8,
}
#[derive(Default, Clone)]
pub struct SixdConfig {
pub threshold: Threshold,
pub mode: Mode,
}
#[derive(Default, Clone)]
pub struct WakeupConfig {
pub wake_dur: WakeDur,
pub sleep_dur: u8,
pub wake_ths: u8,
pub wake_ths_weight: u8,
pub wake_enable: WakeEnable,
pub inact_odr: InactOdr,
}
pub struct TapConfig {
pub axis: Axis,
pub inverted_peak_time: u8,
pub pre_still_ths: u8,
pub post_still_ths: u8,
pub post_still_time: u8,
pub shock_wait_time: u8,
pub latency: u8,
pub wait_end_latency: u8,
pub peak_ths: u8,
pub rebound: u8,
pub pre_still_start: u8,
pub pre_still_n: u8,
pub single_tap_on: u8,
pub double_tap_on: u8,
pub triple_tap_on: u8,
}
#[derive(Default)]
pub struct OuttData {
pub heat: Heat,
}
#[derive(Default)]
pub struct Heat {
pub deg_c: f32,
pub raw: i16,
}
#[derive(Default)]
pub struct FifoMode {
pub operation: FifoOperation,
pub store: Store,
pub xl_only: u8,
pub cfg_change_in_fifo: u8,
}
#[derive(Default)]
pub struct Batch {
pub dec_ts: DecTs,
pub bdr_xl: BdrXl,
}
#[derive(Default)]
pub struct FifoData {
pub tag: u8,
pub xl: [Xl; 2],
pub heat: Heat,
pub pedo: Pedo,
pub cfg_chg: CfgChg,
}
#[derive(Default)]
pub struct Xl {
pub mg: [f32; 3],
pub raw: [i16; 3],
}
#[derive(Default)]
pub struct AhQvar {
pub mv: f32,
pub raw: i16,
}
#[derive(Default)]
pub struct Pedo {
pub steps: u32,
pub timestamp: u32,
}
#[derive(Default)]
pub struct CfgChg {
pub cfg_change: u8,
pub odr: u8,
pub bw: u8,
pub lp_hp: u8,
pub fs: u8,
pub dec_ts: u8,
pub odr_xl_batch: u8,
pub timestamp: u32,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum BusActSel {
_20us = 0x0,
#[default]
_50us = 0x1,
_1ms = 0x2,
_25ms = 0x3,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default)]
pub enum IntCfg {
#[default]
Disabled = 0x0,
Level = 0x1,
Latched = 0x2,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Threshold {
#[default]
_80deg = 0x0,
_70deg = 0x1,
_60deg = 0x2,
_50deg = 0x3,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Mode {
#[default]
_6d = 0x0,
_4d = 0x1,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default)]
pub enum WakeDur {
#[default]
_0Odr,
_1Odr,
_2Odr,
_3Odr,
_7Odr,
_11Odr,
_15Odr,
}
impl WakeDur {
pub fn wake_up_dur_ext(&self) -> u8 {
match self {
WakeDur::_0Odr | WakeDur::_1Odr | WakeDur::_2Odr => 0x0,
WakeDur::_3Odr | WakeDur::_7Odr | WakeDur::_11Odr | WakeDur::_15Odr => 0x1,
}
}
pub fn wake_dur(&self) -> u8 {
match self {
WakeDur::_0Odr | WakeDur::_3Odr => 0x00,
WakeDur::_1Odr | WakeDur::_7Odr => 0x01,
WakeDur::_2Odr | WakeDur::_11Odr => 0x02,
WakeDur::_15Odr => 0x03,
}
}
pub fn new(wup_dur_ext: u8, wake_dur: u8) -> Self {
match wake_dur {
0x0 => {
if wup_dur_ext == 1 {
WakeDur::_3Odr
} else {
WakeDur::_0Odr
}
}
0x1 => {
if wup_dur_ext == 1 {
WakeDur::_7Odr
} else {
WakeDur::_1Odr
}
}
0x2 => {
if wup_dur_ext == 1 {
WakeDur::_11Odr
} else {
WakeDur::_2Odr
}
}
_ => WakeDur::_15Odr,
}
}
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum WakeEnable {
#[default]
SleepOff = 0,
SleepOn = 1,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum InactOdr {
#[default]
NoChange = 0,
_1_6hz = 1,
_3hz = 2,
_25hz = 3,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Axis {
#[default]
TapNone = 0x0,
TapOnX = 0x1,
TapOnY = 0x2,
TapOnZ = 0x3,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FifoOperation {
#[default]
BypassMode = 0x0,
FifoMode = 0x1,
StreamToFifoMode = 0x3,
BypassToStreamMode = 0x4,
StreamMode = 0x6,
BypassToFifoMode = 0x7,
FifoOff = 0x8,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Store {
#[default]
Fifo1x = 0,
Fifo2x = 1,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum DecTs {
#[default]
Off = 0x0,
_1 = 0x1,
_8 = 0x2,
_32 = 0x3,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum BdrXl {
#[default]
Odr = 0x0,
OdrDiv2 = 0x1,
OdrDiv4 = 0x2,
OdrDiv8 = 0x3,
OdrDiv16 = 0x4,
OdrDiv32 = 0x5,
OdrDiv64 = 0x6,
OdrOff = 0x7,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FifoEvent {
#[default]
Wtm = 0x1,
Full = 0x0,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq)]
pub enum Init {
SensorOnlyOn = 0x00,
Boot = 0x01,
Reset = 0x02,
SensorEmbFuncOn = 0x03,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, Debug, TryFrom)]
#[try_from(repr)]
pub enum DataReadyMode {
#[default]
Latched = 0x0,
Pulsed = 0x1,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default)]
pub enum Odr {
#[default]
Off = 0x00,
_1_6hzUlp = 0x01,
_3hzUlp = 0x02,
_25hzUlp = 0x03,
_6hzLp = 0x04,
_12_5hzLp = 0x05,
_25hzLp = 0x06,
_50hzLp = 0x07,
_100hzLp = 0x08,
_200hzLp = 0x09,
_400hzLp = 0x0A,
_800hzLp = 0x0B,
_6hzHp = 0x14,
_12_5hzHp = 0x15,
_25hzHp = 0x16,
_50hzHp = 0x17,
_100hzHp = 0x18,
_200hzHp = 0x19,
_400hzHp = 0x1A,
_800hzHp = 0x1B,
TrigPin = 0x2E,
TrigSw = 0x2F,
}
impl Odr {
pub fn new(odr: u8, hp_en: u8) -> Self {
match odr {
0x00 => Odr::Off,
0x01 => Odr::_1_6hzUlp,
0x02 => Odr::_3hzUlp,
0x03 => Odr::_25hzUlp,
0x04 => {
if hp_en == PROPERTY_ENABLE {
Odr::_6hzHp
} else {
Odr::_6hzLp
}
}
0x05 => {
if hp_en == PROPERTY_ENABLE {
Odr::_12_5hzHp
} else {
Odr::_12_5hzLp
}
}
0x06 => {
if hp_en == PROPERTY_ENABLE {
Odr::_25hzHp
} else {
Odr::_25hzLp
}
}
0x07 => {
if hp_en == PROPERTY_ENABLE {
Odr::_50hzHp
} else {
Odr::_50hzLp
}
}
0x08 => {
if hp_en == PROPERTY_ENABLE {
Odr::_100hzHp
} else {
Odr::_100hzLp
}
}
0x09 => {
if hp_en == PROPERTY_ENABLE {
Odr::_200hzHp
} else {
Odr::_200hzLp
}
}
0x0A => {
if hp_en == PROPERTY_ENABLE {
Odr::_400hzHp
} else {
Odr::_400hzLp
}
}
0x0B => {
if hp_en == PROPERTY_ENABLE {
Odr::_800hzHp
} else {
Odr::_800hzLp
}
}
0x0E => Odr::TrigPin,
0x0F => Odr::TrigSw,
_ => Odr::Off,
}
}
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Fs {
#[default]
_2g = 0,
_4g = 1,
_8g = 2,
_16g = 3,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Bw {
#[default]
OdrDiv2 = 0,
OdrDiv4 = 1,
OdrDiv8 = 2,
OdrDiv16 = 3,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq)]
pub enum XlSelfTest {
Disable = 0x0,
Positive = 0x1,
Negative = 0x2,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, Debug, TryFrom)]
#[try_from(repr)]
pub enum IntPinPolarity {
#[default]
ActiveHigh = 0x0,
ActiveLow = 0x1,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum SpiMode {
#[default]
Spi4Wire = 0x0,
Spi3Wire = 0x1,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FifoSensorTag {
#[default]
FifoEmpty = 0x0,
XlTempTag = 0x2,
XlOnly2xTag = 0x3,
TimestampTag = 0x4,
StepCounterTag = 0x12,
MlcResultTag = 0x1A,
MlcFilterTag = 0x1B,
MlcFeature = 0x1C,
FsmResultTag = 0x1D,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FfThreshold {
#[default]
_156mg = 0x0,
_219mg = 0x1,
_250mg = 0x2,
_312mg = 0x3,
_344mg = 0x4,
_406mg = 0x5,
_469mg = 0x6,
_500mg = 0x7,
}