![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
The sensor-hub configuration sequence follows the official ST example lsm6dsv16x_sensor_hub.c (STMems_Standard_C_drivers), with explicit timeouts instead of infinite loops. More...
Go to the source code of this file.
Macros | |
| #define | LIS2MDL_ADDR_8BIT 0x3Du /* same as LIS2MDL_I2C_ADD in lis2mdl_reg.h */ |
| #define | LIS2MDL_WHO_AM_I 0x4Fu |
| #define | LIS2MDL_ID 0x40u |
| #define | LIS2MDL_CFG_A 0x60u |
| #define | LIS2MDL_CFG_B 0x61u |
| #define | LIS2MDL_CFG_C 0x62u |
| #define | LIS2MDL_OUTX_L 0x68u |
| #define | LIS2MDL_UT_PER_LSB 0.15f |
| #define | LPS22_ADDR_8BIT_H 0xBAu /* SA0 = 1 -> 0x5D */ |
| #define | LPS22_ADDR_8BIT_L 0xB8u /* SA0 = 0 -> 0x5C */ |
| #define | LPS22_WHO_AM_I 0x0Fu |
| #define | LPS22DF_ID 0xB4u |
| #define | LPS22HB_ID 0xB1u |
| #define | LPS22_CTRL_REG1 0x10u |
| #define | LPS22_CTRL_REG2 0x11u |
| #define | LPS22_PRESS_OUT_XL 0x28u /* PRESS XL, L, H, TEMP L, H */ |
| #define | DEG2RAD_F 0.017453292519943295f |
| #define | SH_POLL_MAX 50u /* x 5 ms */ |
Functions | |
| static void | dly (imu_t *imu, uint32_t ms) |
| static int32_t | sh_run_once (imu_t *imu) |
| static int32_t | sh_write (imu_t *imu, uint8_t addr8, uint8_t reg, uint8_t val) |
| static int32_t | sh_read (imu_t *imu, uint8_t addr8, uint8_t reg, uint8_t *buf, uint8_t len) |
| static int32_t | mag_setup (imu_t *imu, uint8_t fast) |
| static int32_t | baro_setup (imu_t *imu) |
| 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) | |
| static int16_t | le16 (const uint8_t *p) |
| 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. | |
The sensor-hub configuration sequence follows the official ST example lsm6dsv16x_sensor_hub.c (STMems_Standard_C_drivers), with explicit timeouts instead of infinite loops.
Definition in file imu_lsm6dsv16x.c.
| #define LIS2MDL_ADDR_8BIT 0x3Du /* same as LIS2MDL_I2C_ADD in lis2mdl_reg.h */ |
Definition at line 12 of file imu_lsm6dsv16x.c.
| #define LIS2MDL_WHO_AM_I 0x4Fu |
Definition at line 13 of file imu_lsm6dsv16x.c.
| #define LIS2MDL_ID 0x40u |
Definition at line 14 of file imu_lsm6dsv16x.c.
| #define LIS2MDL_CFG_A 0x60u |
Definition at line 15 of file imu_lsm6dsv16x.c.
| #define LIS2MDL_CFG_B 0x61u |
Definition at line 16 of file imu_lsm6dsv16x.c.
| #define LIS2MDL_CFG_C 0x62u |
Definition at line 17 of file imu_lsm6dsv16x.c.
| #define LIS2MDL_OUTX_L 0x68u |
Definition at line 18 of file imu_lsm6dsv16x.c.
| #define LIS2MDL_UT_PER_LSB 0.15f |
Definition at line 19 of file imu_lsm6dsv16x.c.
| #define LPS22_ADDR_8BIT_H 0xBAu /* SA0 = 1 -> 0x5D */ |
Definition at line 22 of file imu_lsm6dsv16x.c.
| #define LPS22_ADDR_8BIT_L 0xB8u /* SA0 = 0 -> 0x5C */ |
Definition at line 23 of file imu_lsm6dsv16x.c.
| #define LPS22_WHO_AM_I 0x0Fu |
Definition at line 24 of file imu_lsm6dsv16x.c.
| #define LPS22DF_ID 0xB4u |
Definition at line 25 of file imu_lsm6dsv16x.c.
| #define LPS22HB_ID 0xB1u |
Definition at line 26 of file imu_lsm6dsv16x.c.
| #define LPS22_CTRL_REG1 0x10u |
Definition at line 27 of file imu_lsm6dsv16x.c.
| #define LPS22_CTRL_REG2 0x11u |
Definition at line 28 of file imu_lsm6dsv16x.c.
Definition at line 29 of file imu_lsm6dsv16x.c.
| #define DEG2RAD_F 0.017453292519943295f |
Definition at line 31 of file imu_lsm6dsv16x.c.
| #define SH_POLL_MAX 50u /* x 5 ms */ |
Definition at line 32 of file imu_lsm6dsv16x.c.
|
static |
Definition at line 34 of file imu_lsm6dsv16x.c.
References imu_t::bus, sensor_bus_t::delay_ms, and ms.
Referenced by baro_setup(), imu_init(), mag_setup(), and sh_run_once().
|
static |
Definition at line 37 of file imu_lsm6dsv16x.c.
References imu_t::ctx, dly(), IMU_ERR_BUS, IMU_ERR_SH_TIMEOUT, IMU_OK, ms, and SH_POLL_MAX.
Referenced by sh_read(), and sh_write().
|
static |
Definition at line 62 of file imu_lsm6dsv16x.c.
References imu_t::ctx, IMU_ERR_BUS, and sh_run_once().
Referenced by baro_setup(), and mag_setup().
|
static |
Definition at line 71 of file imu_lsm6dsv16x.c.
References imu_t::ctx, IMU_ERR_BUS, IMU_OK, sh_run_once(), and st().
Referenced by baro_setup(), and mag_setup().
|
static |
Definition at line 82 of file imu_lsm6dsv16x.c.
References dly(), IMU_ERR_MAG_ID, LIS2MDL_ADDR_8BIT, LIS2MDL_CFG_A, LIS2MDL_CFG_B, LIS2MDL_CFG_C, LIS2MDL_ID, LIS2MDL_WHO_AM_I, sh_read(), sh_write(), and st().
Referenced by imu_init().
|
static |
Definition at line 100 of file imu_lsm6dsv16x.c.
References addr(), imu_t::baro_addr8, imu_t::baro_model, dly(), IMU_BARO_LPS22DF, IMU_BARO_LPS22HB, IMU_OK, LPS22_ADDR_8BIT_H, LPS22_ADDR_8BIT_L, LPS22_CTRL_REG1, LPS22_CTRL_REG2, LPS22_WHO_AM_I, LPS22DF_ID, LPS22HB_ID, sh_read(), and sh_write().
Referenced by imu_init().
| 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.
|
static |
Definition at line 231 of file imu_lsm6dsv16x.c.
Referenced by imu_fifo_parse().
| 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().