![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
IMU library: LSM6DSV16X (gyro + acc) with the LIS2MDL and the barometer (LPS22DF on the X-NUCLEO-IKS4A1 in Mode 3, LPS22HB on the ACwing FC rev A) read by the internal sensor hub and placed in the same FIFO. More...
Go to the source code of this file.
Data Structures | |
| struct | imu_config_t |
| struct | imu_event_t |
| struct | imu_parse_stats_t |
| struct | imu_t |
Macros | |
| #define | IMU_I2C_ADDR_7BIT 0x6Bu |
| SA0 = 1 (default IKS4A1: 0xD6/0xD7) | |
| #define | IMU_FIFO_REG LSM6DSV16X_FIFO_DATA_OUT_TAG |
| 0x78 | |
| #define | IMU_FIFO_WORD_BYTES 7u |
| #define | IMU_FIFO_MAX_WORDS 48u |
| burst buffer: 336 bytes | |
| #define | IMU_SH_HZ(fast) ((fast) ? 120.0f : 60.0f) |
Enumerations | |
| enum | imu_odr_t { IMU_ODR_960HZ = 0 , IMU_ODR_1920HZ = 1 } |
| enum | imu_baro_t { IMU_BARO_NONE = 0 , IMU_BARO_LPS22DF = 1 , IMU_BARO_LPS22HB = 2 } |
| enum | imu_status_t { IMU_OK = 0 , IMU_ERR_BUS = -1 , IMU_ERR_ID = -2 , IMU_ERR_MAG_ID = -3 , IMU_ERR_SH_TIMEOUT = -4 , IMU_ERR_ARG = -5 } |
| enum | imu_ev_type_t { IMU_EV_GYRO = 1 , IMU_EV_ACC = 2 , IMU_EV_MAG = 3 , IMU_EV_BARO = 4 } |
Functions | |
| int32_t | imu_init (imu_t *imu, const sensor_bus_t *bus, const imu_config_t *cfg) |
| int32_t | imu_fifo_level (imu_t *imu, uint16_t *words) |
| Number of 7-byte words in the FIFO. | |
| int32_t | imu_fifo_read_burst (imu_t *imu, uint8_t *raw, uint16_t words) |
| Blocking read via sensor_bus (for tests or when DMA is not used) | |
| size_t | imu_fifo_parse (imu_t *imu, const uint8_t *raw, uint16_t words, imu_event_t *ev, size_t cap, imu_parse_stats_t *st) |
| Decodes 'words' words read in a burst from IMU_FIFO_REG. | |
IMU library: LSM6DSV16X (gyro + acc) with the LIS2MDL and the barometer (LPS22DF on the X-NUCLEO-IKS4A1 in Mode 3, LPS22HB on the ACwing FC rev A) read by the internal sensor hub and placed in the same FIFO.
Built on top of the official ST driver lsm6dsv16x-pid (third_party/), which provides register access; this library adds:
Dependencies: sensor_bus.h + lsm6dsv16x_reg.[ch]. No HAL, no RTOS.
Definition in file imu_lsm6dsv16x.h.
| #define IMU_I2C_ADDR_7BIT 0x6Bu |
SA0 = 1 (default IKS4A1: 0xD6/0xD7)
Definition at line 25 of file imu_lsm6dsv16x.h.
| #define IMU_FIFO_REG LSM6DSV16X_FIFO_DATA_OUT_TAG |
0x78
Definition at line 26 of file imu_lsm6dsv16x.h.
| #define IMU_FIFO_WORD_BYTES 7u |
Definition at line 27 of file imu_lsm6dsv16x.h.
| #define IMU_FIFO_MAX_WORDS 48u |
burst buffer: 336 bytes
Definition at line 28 of file imu_lsm6dsv16x.h.
| #define IMU_SH_HZ | ( | fast | ) | ((fast) ? 120.0f : 60.0f) |
Definition at line 46 of file imu_lsm6dsv16x.h.
| enum imu_odr_t |
| Enumerator | |
|---|---|
| IMU_ODR_960HZ | |
| IMU_ODR_1920HZ | |
Definition at line 29 of file imu_lsm6dsv16x.h.
| enum imu_baro_t |
| Enumerator | |
|---|---|
| IMU_BARO_NONE | |
| IMU_BARO_LPS22DF | |
| IMU_BARO_LPS22HB | |
Definition at line 43 of file imu_lsm6dsv16x.h.
| enum imu_status_t |
| Enumerator | |
|---|---|
| IMU_OK | |
| IMU_ERR_BUS | |
| IMU_ERR_ID | |
| IMU_ERR_MAG_ID | |
| IMU_ERR_SH_TIMEOUT | |
| IMU_ERR_ARG | |
Definition at line 48 of file imu_lsm6dsv16x.h.
| enum imu_ev_type_t |
| Enumerator | |
|---|---|
| IMU_EV_GYRO | |
| IMU_EV_ACC | |
| IMU_EV_MAG | |
| IMU_EV_BARO | |
Definition at line 53 of file imu_lsm6dsv16x.h.
| int32_t imu_init | ( | imu_t * | imu, |
| const sensor_bus_t * | bus, | ||
| const imu_config_t * | cfg | ||
| ) |
Definition at line 128 of file imu_lsm6dsv16x.c.
References imu_t::baro_addr8, imu_config_t::baro_enable, imu_t::baro_enabled, baro_setup(), imu_t::baro_slot, imu_t::bus, imu_t::ctx, sensor_bus_t::delay_ms, dly(), imu_config_t::gy_lpf1_bw, sensor_bus_t::handle, IMU_ERR_ARG, IMU_ERR_BUS, IMU_ERR_ID, IMU_ODR_1920HZ, IMU_OK, LIS2MDL_ADDR_8BIT, LIS2MDL_OUTX_L, LPS22_PRESS_OUT_XL, imu_config_t::mag_enable, imu_t::mag_enabled, imu_config_t::mag_fast, mag_setup(), imu_config_t::odr, imu_t::odr_hz, sensor_bus_t::read, st(), imu_config_t::watermark_words, sensor_bus_t::write, imu_config_t::xl_lpf2_bw, and imu_config_t::xl_lpf2_enable.
Referenced by ImuTask().
| int32_t imu_fifo_level | ( | imu_t * | imu, |
| uint16_t * | words | ||
| ) |
Number of 7-byte words in the FIFO.
Definition at line 216 of file imu_lsm6dsv16x.c.
References imu_t::ctx, IMU_ERR_BUS, IMU_OK, and s.
Referenced by ImuTask().
| int32_t imu_fifo_read_burst | ( | imu_t * | imu, |
| uint8_t * | raw, | ||
| uint16_t | words | ||
| ) |
Blocking read via sensor_bus (for tests or when DMA is not used)
Definition at line 224 of file imu_lsm6dsv16x.c.
References imu_t::bus, sensor_bus_t::handle, IMU_ERR_BUS, IMU_FIFO_MAX_WORDS, IMU_FIFO_REG, IMU_FIFO_WORD_BYTES, IMU_OK, and sensor_bus_t::read.
| size_t imu_fifo_parse | ( | imu_t * | imu, |
| const uint8_t * | raw, | ||
| uint16_t | words, | ||
| imu_event_t * | ev, | ||
| size_t | cap, | ||
| imu_parse_stats_t * | st | ||
| ) |
Decodes 'words' words read in a burst from IMU_FIFO_REG.
Returns the number of events written to ev (<= cap). Pure function of the data; the only state is the magnetometer duplicate filter.
Definition at line 233 of file imu_lsm6dsv16x.c.
References imu_t::baro_enabled, imu_t::baro_slot, cap, DEG2RAD_F, imu_t::have_baro, imu_t::have_mag, IMU_EV_ACC, IMU_EV_BARO, IMU_EV_GYRO, IMU_EV_MAG, IMU_FIFO_WORD_BYTES, imu_t::last_baro_raw, imu_t::last_mag_raw, le16(), LIS2MDL_UT_PER_LSB, imu_t::mag_enabled, n, slot(), st(), imu_event_t::type, and imu_event_t::v.
Referenced by ImuTask().