ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
imu_i2c.h File Reference

STM32 HAL (STM32WB55) binding of the sensor_bus_t interface + DMA burst read of the FIFO with task notification. More...

#include "main.h"
#include "sensor_bus.h"
#include "cmsis_os2.h"
Include dependency graph for imu_i2c.h:
This graph shows which files directly or indirectly include this file:

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)
 

Detailed Description

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.

Function Documentation

◆ imu_i2c_bus_init()

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().

Here is the caller graph for this function:

◆ imu_i2c_lock()

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().

Here is the caller graph for this function:

◆ imu_i2c_unlock()

void imu_i2c_unlock ( void  )

Definition at line 34 of file imu_i2c.c.

References s_lock.

Referenced by imu_i2c_read_dma(), rd(), wr(), and xfer().

Here is the caller graph for this function:

◆ imu_i2c_handle()

I2C_HandleTypeDef * imu_i2c_handle ( void  )

Definition at line 39 of file imu_i2c.c.

References s_hi2c.

Referenced by xfer().

Here is the caller graph for this function:

◆ imu_i2c_make_bus()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ imu_i2c_read_dma()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ imu_i2c_rx_cplt_isr()

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().

Here is the caller graph for this function:

◆ imu_i2c_error_isr()

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().

Here is the caller graph for this function: