Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sonar_i2c.c File Reference
#include "generated/airframe.h"
#include "modules/sonar/sonar_i2c.h"
#include "modules/core/abi.h"
#include "modules/datalink/telemetry.h"
#include "pprzlink/messages.h"
#include "filters/median_filter.h"
+ Include dependency graph for sonar_i2c.c:

Go to the source code of this file.

Macros

#define SONAR_I2C_ADDR   0xE0
 
#define READ_MODE_SINGLE   0x51
 
#define SONAR_I2C_MIN_RANGE   0.24f
 The minimum chosen distance for the device to be give readings.
 
#define SONAR_I2C_MAX_RANGE   4.0f
 The maximum chosen distance for the device to be give readings.
 
#define SONAR_I2C_OFFSET   0.0f
 Rangefinder distance offset value for what should be considered zero distance, e.g. high landing gear of 1.1m to tarmac still could be considered zero.
 
#define USE_SONAR_I2C_AGL   0
 Send AGL data over ABI.
 
#define SONAR_I2C_USE_FILTER   1
 Filter the raw measuread sonar data.
 
#define SONAR_I2C_MEDIAN_SIZE   7
 The amount of sensor samples to keep in the median filter buffer.
 
#define SONAR_I2C_COMPENSATE_ROTATION   0
 
#define SONAR_I2C_SCALE   0.000044f
 

Functions

static void sonar_i2c_send_sonar (struct transport_tx *trans, struct link_device *dev)
 Send measured value and status information so it can be read back in e.g.
 
void sonar_i2c_init (void)
 Set the default values at initialization.
 
void sonar_i2c_event (void)
 Rangefinder event function Basically just check the progress of the transation to prevent overruns during high speed operation (ie.
 
void sonar_i2c_periodic (void)
 Get the ranger current distance value.
 
void sonar_i2c_report (void)
 Option to send debug informative values over telemetry if you do not want sonar message in telemetry.
 

Variables

struct MedianFilterFloat sonar_i2c_filter
 
struct SonarI2C sonar_i2c
 

Macro Definition Documentation

◆ READ_MODE_SINGLE

#define READ_MODE_SINGLE   0x51

Definition at line 54 of file sonar_i2c.c.

◆ SONAR_I2C_ADDR

#define SONAR_I2C_ADDR   0xE0

Definition at line 51 of file sonar_i2c.c.

◆ SONAR_I2C_COMPENSATE_ROTATION

#define SONAR_I2C_COMPENSATE_ROTATION   0

Definition at line 93 of file sonar_i2c.c.

◆ SONAR_I2C_MAX_RANGE

#define SONAR_I2C_MAX_RANGE   4.0f

The maximum chosen distance for the device to be give readings.

Definition at line 65 of file sonar_i2c.c.

◆ SONAR_I2C_MEDIAN_SIZE

#define SONAR_I2C_MEDIAN_SIZE   7

The amount of sensor samples to keep in the median filter buffer.

Definition at line 87 of file sonar_i2c.c.

◆ SONAR_I2C_MIN_RANGE

#define SONAR_I2C_MIN_RANGE   0.24f

The minimum chosen distance for the device to be give readings.

Definition at line 60 of file sonar_i2c.c.

◆ SONAR_I2C_OFFSET

#define SONAR_I2C_OFFSET   0.0f

Rangefinder distance offset value for what should be considered zero distance, e.g. high landing gear of 1.1m to tarmac still could be considered zero.

Definition at line 70 of file sonar_i2c.c.

◆ SONAR_I2C_SCALE

#define SONAR_I2C_SCALE   0.000044f

Definition at line 98 of file sonar_i2c.c.

◆ SONAR_I2C_USE_FILTER

#define SONAR_I2C_USE_FILTER   1

Filter the raw measuread sonar data.

Definition at line 80 of file sonar_i2c.c.

◆ USE_SONAR_I2C_AGL

#define USE_SONAR_I2C_AGL   0

Send AGL data over ABI.

Definition at line 75 of file sonar_i2c.c.

Function Documentation

◆ sonar_i2c_event()

void sonar_i2c_event ( void  )

Rangefinder event function Basically just check the progress of the transation to prevent overruns during high speed operation (ie.

polling the sensor at more than maximum, e.g. > 10Hz)

Definition at line 142 of file sonar_i2c.c.

References I2CTransDone, I2CTransFailed, I2CTransPending, I2CTransRunning, I2CTransSuccess, sonar_i2c, sonar_i2c_report(), i2c_transaction::status, and SonarI2C::trans.

+ Here is the call graph for this function:

◆ sonar_i2c_init()

◆ sonar_i2c_periodic()

◆ sonar_i2c_report()

void sonar_i2c_report ( void  )

Option to send debug informative values over telemetry if you do not want sonar message in telemetry.

Definition at line 246 of file sonar_i2c.c.

References DefaultChannel, DefaultDevice, SonarI2C::distance, foo, SonarI2C::raw, and sonar_i2c.

Referenced by sonar_i2c_event().

+ Here is the caller graph for this function:

◆ sonar_i2c_send_sonar()

static void sonar_i2c_send_sonar ( struct transport_tx trans,
struct link_device dev 
)
static

Send measured value and status information so it can be read back in e.g.

log file for debugging

Definition at line 106 of file sonar_i2c.c.

References dev, SonarI2C::distance, foo, SonarI2C::raw, sonar_i2c, and SonarI2C::trans.

Referenced by sonar_i2c_init().

+ Here is the caller graph for this function:

Variable Documentation

◆ sonar_i2c

struct SonarI2C sonar_i2c

◆ sonar_i2c_filter

struct MedianFilterFloat sonar_i2c_filter

Definition at line 89 of file sonar_i2c.c.

Referenced by sonar_i2c_init(), and sonar_i2c_periodic().