#ifndef LSM6DSOX_H #define LSM6DSOX_H #include #define LSM6DSOX_WHO_AM_I_VALUE 0x6cu typedef struct { uint64_t timestamp_ticks; int16_t accel[3]; int16_t gyro[3]; int16_t temperature; } lsm6dsox_sample_t; typedef struct { uint32_t odr_hz; uint32_t accel_ug_per_lsb; uint32_t gyro_udps_per_lsb; uint32_t temperature_lsb_per_c; int32_t temperature_offset_millic; } lsm6dsox_scale_t; /* Initialize the PMOD SPI peripheral, identify and configure the IMU. */ int lsm6dsox_init(uint32_t odr_hz); /* Read-only helpers used by the smoke-test diagnostics. */ uint8_t lsm6dsox_read_who_am_i(void); uint8_t lsm6dsox_read_register(uint8_t reg); /* Return 1 for a new coherent gyro+accelerometer sample, 0 if not ready. */ int lsm6dsox_poll_sample(lsm6dsox_sample_t *sample); /* Route accel data-ready to sensor INT1 in latched, active-high mode. The ISR * clears that source first, then waits briefly for the same-ODR gyro block. */ int lsm6dsox_enable_data_ready_interrupt(void); void lsm6dsox_disable_data_ready_interrupt(void); /* Read one coherent sample for a timestamp captured at ISR entry. */ int lsm6dsox_read_interrupt_sample(lsm6dsox_sample_t *sample, uint64_t interrupt_timestamp_ticks); void lsm6dsox_power_down(void); const lsm6dsox_scale_t *lsm6dsox_scale(void); #endif