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

Expansion sensors on the Qwiic bus (ACwing Flow rev A): VL53L1X ToF and the optical-flow bridge. More...

#include <stdint.h>
#include "vl53l1x.h"
#include "sensor_bus.h"
Include dependency graph for ext_sens.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ext_sample_t
 
struct  ext_buses_t
 

Macros

#define EXT_PERIOD_MS   10u
 
#define EXT_PROBE_MS   5000u
 
#define EXT_ERR_LIMIT   50u
 consecutive errors: device lost, probe again
 

Enumerations

enum  { EXT_TOF = 1 , EXT_FLOW = 2 }
 

Functions

void ext_init (const ext_buses_t *buses)
 
void ext_step (uint32_t now_ms)
 one 10 ms cycle
 
void ext_sens_start (void)
 creates the task (after imu_i2c_bus_init)
 
int ext_take (ext_sample_t *s)
 flight context: 1 if a sample was taken
 
uint16_t ext_sensors (void)
 PV2_S_TOF | PV2_S_FLOW currently detected.
 
uint32_t ext_errors (void)
 

Detailed Description

Expansion sensors on the Qwiic bus (ACwing Flow rev A): VL53L1X ToF and the optical-flow bridge.

Own low-priority task (ExtTask).

Logic (ext_init / ext_step) is portable and host-tested: the devices are probed at boot and every 5 s while one is missing (the board can be plugged in later), polled every 10 ms, declared lost after 50 consecutive bus errors, and every new sample is handed to the flight-control context through a lock-free SPSC queue (ext_take). The bus bindings are in bsp/ext_i2c.c; the RTOS task shell is at the end of ext_sens.c.

Definition in file ext_sens.h.

Macro Definition Documentation

◆ EXT_PERIOD_MS

#define EXT_PERIOD_MS   10u

Definition at line 20 of file ext_sens.h.

◆ EXT_PROBE_MS

#define EXT_PROBE_MS   5000u

Definition at line 21 of file ext_sens.h.

◆ EXT_ERR_LIMIT

#define EXT_ERR_LIMIT   50u

consecutive errors: device lost, probe again

Definition at line 22 of file ext_sens.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EXT_TOF 
EXT_FLOW 

Definition at line 23 of file ext_sens.h.

Function Documentation

◆ ext_init()

void ext_init ( const ext_buses_t *  buses)

Definition at line 22 of file ext_sens.c.

References b, flow_t::ok, vl53_t::ok, s_bus, s_err, s_flow, s_flow_err, s_probed, s_q, s_sens, s_tof, s_tof_err, and spsc_reset().

Referenced by ext_sens_start().

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

◆ ext_step()

void ext_step ( uint32_t  now_ms)

one 10 ms cycle

Definition at line 36 of file ext_sens.c.

References flow_frame_t::dt_s, flow_frame_t::dx, flow_frame_t::dy, EXT_ERR_LIMIT, EXT_FLOW, EXT_PROBE_MS, EXT_TOF, EXT_TOF_BUDGET_MS, ext_buses_t::flow, flow_init(), flow_read(), vl53_sample_t::mm, flow_t::ok, vl53_t::ok, publish(), s, s_bus, s_err, s_flow, s_flow_err, s_next_probe, s_probed, s_q, s_tof, s_tof_err, spsc_push(), flow_frame_t::squal, flow_frame_t::status, vl53_sample_t::status, ext_buses_t::tof, vl53_init(), and vl53_poll().

Referenced by ExtTask().

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

◆ ext_sens_start()

void ext_sens_start ( void  )

creates the task (after imu_i2c_bus_init)

Definition at line 100 of file ext_sens.c.

References b, ext_i2c_flow_bus(), ext_i2c_tof_bus(), ext_init(), ExtTask(), FLOW_BRIDGE_ADDR_7BIT, and VL53L1X_ADDR_7BIT.

Referenced by app_start().

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

◆ ext_take()

int ext_take ( ext_sample_t *  s)

flight context: 1 if a sample was taken

Definition at line 81 of file ext_sens.c.

References s, s_q, and spsc_pop().

Referenced by take_ext().

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

◆ ext_sensors()

uint16_t ext_sensors ( void  )

PV2_S_TOF | PV2_S_FLOW currently detected.

Definition at line 82 of file ext_sens.c.

References s_sens.

Referenced by log_sensors(), sensors_now(), and take_ext().

Here is the caller graph for this function:

◆ ext_errors()

uint32_t ext_errors ( void  )

Definition at line 83 of file ext_sens.c.

References s_err.