![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
STM32 HAL (STM32WB55) binding of the sensor_bus_t interface + DMA burst read of the FIFO with task notification. More...
Go to the source code of this file.
Functions | |
| void | imu_i2c_bus_init (I2C_HandleTypeDef *hi2c) |
| Creates the bus lock: call once before starting the tasks that use the bus. | |
| int | imu_i2c_lock (void) |
| 0 = taken (or no kernel yet), -1 = timeout | |
| void | imu_i2c_unlock (void) |
| I2C_HandleTypeDef * | imu_i2c_handle (void) |
| void | imu_i2c_make_bus (sensor_bus_t *bus, I2C_HandleTypeDef *hi2c, uint8_t addr7) |
| int32_t | imu_i2c_read_dma (uint8_t reg, uint8_t *buf, uint16_t len, uint32_t timeout_ms) |
| Starts the DMA read and blocks the calling task until completion. | |
| void | imu_i2c_rx_cplt_isr (I2C_HandleTypeDef *hi2c) |
| To be called from HAL_I2C_MemRxCpltCallback / HAL_I2C_ErrorCallback. | |
| void | imu_i2c_error_isr (I2C_HandleTypeDef *hi2c) |
STM32 HAL (STM32WB55) binding of the sensor_bus_t interface + DMA burst read of the FIFO with task notification.
In IKS4A1 Mode 3 the LIS2MDL and the LPS22DF sit behind the LSM6DSV16X sensor hub. The expansion devices (ACwing Flow: VL53L1X 0x29, flow bridge 0x3B) share the bus on the bench, so every transaction takes a mutex with priority inheritance (imu_i2c_lock). On the ACwing FC rev A the IMU is on SPI and I2C1 is the expansion bus only.
Definition in file imu_i2c.h.
| void imu_i2c_bus_init | ( | I2C_HandleTypeDef * | hi2c | ) |
Creates the bus lock: call once before starting the tasks that use the bus.
Definition at line 21 of file imu_i2c.c.
References s_hi2c, and s_lock.
Referenced by app_start().
| int imu_i2c_lock | ( | void | ) |
0 = taken (or no kernel yet), -1 = timeout
Definition at line 28 of file imu_i2c.c.
References LOCK_TIMEOUT_MS, and s_lock.
Referenced by imu_i2c_read_dma(), rd(), wr(), and xfer().
| void imu_i2c_unlock | ( | void | ) |
| I2C_HandleTypeDef * imu_i2c_handle | ( | void | ) |
| void imu_i2c_make_bus | ( | sensor_bus_t * | bus, |
| I2C_HandleTypeDef * | hi2c, | ||
| uint8_t | addr7 | ||
| ) |
Definition at line 66 of file imu_i2c.c.
References sensor_bus_t::delay_ms, dly(), sensor_bus_t::handle, rd(), sensor_bus_t::read, s_addr8, s_hi2c, wr(), and sensor_bus_t::write.
Referenced by ImuTask().
| int32_t imu_i2c_read_dma | ( | uint8_t | reg, |
| uint8_t * | buf, | ||
| uint16_t | len, | ||
| uint32_t | timeout_ms | ||
| ) |
Starts the DMA read and blocks the calling task until completion.
0 = OK, -1 error/timeout.
Definition at line 76 of file imu_i2c.c.
References FLAG_DMA_DONE, FLAG_DMA_ERR, imu_i2c_lock(), imu_i2c_unlock(), s_addr8, s_hi2c, and s_waiter.
Referenced by ImuTask().
| void imu_i2c_rx_cplt_isr | ( | I2C_HandleTypeDef * | hi2c | ) |
To be called from HAL_I2C_MemRxCpltCallback / HAL_I2C_ErrorCallback.
Definition at line 91 of file imu_i2c.c.
References FLAG_DMA_DONE, s_hi2c, and s_waiter.
Referenced by app_i2c_rx_cplt().
| void imu_i2c_error_isr | ( | I2C_HandleTypeDef * | hi2c | ) |
Definition at line 96 of file imu_i2c.c.
References FLAG_DMA_ERR, s_hi2c, and s_waiter.
Referenced by app_i2c_error().