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

ExtTask: VL53L1X + flow bridge on the Qwiic bus (see ext_sens.h). More...

#include "ext_sens.h"
#include "flow_bridge.h"
#include "proto_v2.h"
#include "spsc.h"
#include "cmsis_os2.h"
#include "ext_i2c.h"
Include dependency graph for ext_sens.c:

Go to the source code of this file.

Macros

#define EXT_TOF_BUDGET_MS   33u
 

Functions

 SPSC_DEFINE (s_q, ext_sample_t, 16u)
 
void ext_init (const ext_buses_t *b)
 
static void publish (void)
 
void ext_step (uint32_t now)
 one 10 ms cycle
 
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)
 
static void ExtTask (void *arg)
 
void ext_sens_start (void)
 creates the task (after imu_i2c_bus_init)
 

Variables

static ext_buses_t s_bus
 
static vl53_t s_tof
 
static flow_t s_flow
 
static uint32_t s_next_probe
 
static uint32_t s_tof_err
 
static uint32_t s_flow_err
 
static uint8_t s_probed
 
static volatile uint16_t s_sens
 
static volatile uint32_t s_err
 

Detailed Description

ExtTask: VL53L1X + flow bridge on the Qwiic bus (see ext_sens.h).

Definition in file ext_sens.c.

Macro Definition Documentation

◆ EXT_TOF_BUDGET_MS

#define EXT_TOF_BUDGET_MS   33u

Definition at line 10 of file ext_sens.c.

Function Documentation

◆ SPSC_DEFINE()

SPSC_DEFINE ( s_q  ,
ext_sample_t  ,
16u   
)

◆ ext_init()

void ext_init ( const ext_buses_t *  b)

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:

◆ publish()

static void publish ( void  )
static

Definition at line 31 of file ext_sens.c.

References flow_t::ok, vl53_t::ok, PV2_S_FLOW, PV2_S_TOF, s_flow, s_sens, and s_tof.

Referenced by ext_step().

Here is the caller graph for this function:

◆ ext_step()

void ext_step ( uint32_t  now)

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_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.

◆ ExtTask()

static void ExtTask ( void *  arg)
static

Definition at line 90 of file ext_sens.c.

References EXT_PERIOD_MS, and ext_step().

Referenced by ext_sens_start().

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:

Variable Documentation

◆ s_bus

ext_buses_t s_bus
static

Definition at line 14 of file ext_sens.c.

Referenced by ext_init(), and ext_step().

◆ s_tof

vl53_t s_tof
static

Definition at line 15 of file ext_sens.c.

Referenced by ext_init(), ext_step(), and publish().

◆ s_flow

flow_t s_flow
static

Definition at line 16 of file ext_sens.c.

Referenced by ext_init(), ext_step(), and publish().

◆ s_next_probe

uint32_t s_next_probe
static

Definition at line 17 of file ext_sens.c.

Referenced by ext_step().

◆ s_tof_err

uint32_t s_tof_err
static

Definition at line 17 of file ext_sens.c.

Referenced by ext_init(), and ext_step().

◆ s_flow_err

uint32_t s_flow_err
static

Definition at line 17 of file ext_sens.c.

Referenced by ext_init(), and ext_step().

◆ s_probed

uint8_t s_probed
static

Definition at line 18 of file ext_sens.c.

Referenced by ext_init(), and ext_step().

◆ s_sens

volatile uint16_t s_sens
static

Definition at line 19 of file ext_sens.c.

Referenced by ext_init(), ext_sensors(), and publish().

◆ s_err

volatile uint32_t s_err
static

Definition at line 20 of file ext_sens.c.

Referenced by ext_errors(), ext_init(), and ext_step().