Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
tfmini_i2c.c File Reference
#include "generated/airframe.h"
#include "modules/lidar/tfmini_i2c.h"
#include "modules/core/abi.h"
#include "modules/datalink/telemetry.h"
#include "pprzlink/messages.h"
+ Include dependency graph for tfmini_i2c.c:

Go to the source code of this file.

Macros

#define AGL_LIDAR_TFMINI_I2C_ID   AGL_LIDAR_TFMINI_ID
 
#define TFMINI_I2C_ADDR   0x10
 
#define TFMINI_I2C_REG_ADDR   0x26
 
#define TFMINI_I2C_REG_VAL   0x10
 
#define TFMINI_I2C_READ_ADDR   0x10
 
#define DISTANCE_MODE_REG_ADDR   0x50
 
#define DISTANCE_MODE_SHORT   0x00
 
#define DISTANCE_MODE_MIDDLE   0x03
 
#define DISTANCE_MODE_LONG   0x07
 
#define DETECTION_PATTERN_REG_ADDR   0x51
 
#define AUTOMATIC_DETECTION_PATTERN   0x00
 
#define FIXED_DETECTION_PATTERN   0x01
 
#define SETTING_OF_RANGE_LIMIT_REG_ADDR   0x55
 
#define RANGE_LIMIT_DISABLED   0x00
 
#define RANGE_LIMIT_ENABLED   0x01
 
#define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_L   0x56
 
#define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_H   0x57
 
#define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L   0x58
 
#define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H   0x59
 
#define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L   0x5A
 
#define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H   0x5B
 
#define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_L   0x5C
 
#define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_H   0x5D
 
#define UNIT_OF_DISTANCE_REG_ADDR   0x66
 
#define UNIT_OF_DISTANCE_MM   0x00
 
#define UNIT_OF_DISTANCE_CM   0x01
 
#define SLAVE_ADDRESS_REG_ADDR   0x26
 
#define TRIGGER_MODE_REG_ADDR   0x27
 
#define USE_EXTERNAL_TRIGGER   0
 
#define EXTERNAL_TRIGGER_REG_ADDR   0x01
 
#define DEVICE_RESET_ADDR   0x70
 
#define TFMINI_I2C_OFFSET   0.0f
 Ranger offset value for what considered the distance should be zero, e.g. high landing gear to tarmac 60cm still could be considerd zero. More...
 
#define TFMINI_I2C_MIN_RANGE   0.3f
 The minimum range for the device to be able to measure. More...
 
#define TFMINI_I2C_MAX_RANGE   6.0f
 The maximum range for the device to be able to measure. More...
 

Functions

static void tfmini_i2c_send_lidar (struct transport_tx *trans, struct link_device *dev)
 Send measured value and status information so it can be read back in e.g. More...
 
void tfmini_i2c_init (void)
 Set the default values at initialization. More...
 
void tfmini_i2c_event (void)
 Ranger event function Basically just check the progress of the transation to prevent overruns during high speed operation (ie. More...
 
void tfmini_i2c_periodic (void)
 Get the ranger current distance value. More...
 
void tfmini_i2c_downlink (void)
 

Variables

struct TFMiniI2C tfmini_i2c
 

Macro Definition Documentation

◆ AGL_LIDAR_TFMINI_I2C_ID

#define AGL_LIDAR_TFMINI_I2C_ID   AGL_LIDAR_TFMINI_ID

Definition at line 47 of file tfmini_i2c.c.

◆ AUTOMATIC_DETECTION_PATTERN

#define AUTOMATIC_DETECTION_PATTERN   0x00

Definition at line 73 of file tfmini_i2c.c.

◆ DETECTION_PATTERN_REG_ADDR

#define DETECTION_PATTERN_REG_ADDR   0x51

Definition at line 72 of file tfmini_i2c.c.

◆ DEVICE_RESET_ADDR

#define DEVICE_RESET_ADDR   0x70

Definition at line 108 of file tfmini_i2c.c.

◆ DISTANCE_MODE_LONG

#define DISTANCE_MODE_LONG   0x07

Definition at line 70 of file tfmini_i2c.c.

◆ DISTANCE_MODE_MIDDLE

#define DISTANCE_MODE_MIDDLE   0x03

Definition at line 69 of file tfmini_i2c.c.

◆ DISTANCE_MODE_REG_ADDR

#define DISTANCE_MODE_REG_ADDR   0x50

Definition at line 67 of file tfmini_i2c.c.

◆ DISTANCE_MODE_SHORT

#define DISTANCE_MODE_SHORT   0x00

Definition at line 68 of file tfmini_i2c.c.

◆ EXTERNAL_TRIGGER_REG_ADDR

#define EXTERNAL_TRIGGER_REG_ADDR   0x01

Definition at line 106 of file tfmini_i2c.c.

◆ FIXED_DETECTION_PATTERN

#define FIXED_DETECTION_PATTERN   0x01

Definition at line 74 of file tfmini_i2c.c.

◆ LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H

#define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H   0x59

Definition at line 86 of file tfmini_i2c.c.

◆ LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L

#define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L   0x58

Definition at line 85 of file tfmini_i2c.c.

◆ OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_H

#define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_H   0x5D

Definition at line 95 of file tfmini_i2c.c.

◆ OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_L

#define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_L   0x5C

Definition at line 94 of file tfmini_i2c.c.

◆ RANGE_LIMIT_DISABLED

#define RANGE_LIMIT_DISABLED   0x00

Definition at line 77 of file tfmini_i2c.c.

◆ RANGE_LIMIT_ENABLED

#define RANGE_LIMIT_ENABLED   0x01

Definition at line 78 of file tfmini_i2c.c.

◆ RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_H

#define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_H   0x57

Definition at line 81 of file tfmini_i2c.c.

◆ RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_L

#define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_L   0x56

Definition at line 80 of file tfmini_i2c.c.

◆ SETTING_OF_RANGE_LIMIT_REG_ADDR

#define SETTING_OF_RANGE_LIMIT_REG_ADDR   0x55

Definition at line 76 of file tfmini_i2c.c.

◆ SLAVE_ADDRESS_REG_ADDR

#define SLAVE_ADDRESS_REG_ADDR   0x26

Definition at line 102 of file tfmini_i2c.c.

◆ TFMINI_I2C_ADDR

#define TFMINI_I2C_ADDR   0x10

Definition at line 60 of file tfmini_i2c.c.

◆ TFMINI_I2C_MAX_RANGE

#define TFMINI_I2C_MAX_RANGE   6.0f

The maximum range for the device to be able to measure.

Definition at line 122 of file tfmini_i2c.c.

◆ TFMINI_I2C_MIN_RANGE

#define TFMINI_I2C_MIN_RANGE   0.3f

The minimum range for the device to be able to measure.

Definition at line 117 of file tfmini_i2c.c.

◆ TFMINI_I2C_OFFSET

#define TFMINI_I2C_OFFSET   0.0f

Ranger offset value for what considered the distance should be zero, e.g. high landing gear to tarmac 60cm still could be considerd zero.

Definition at line 112 of file tfmini_i2c.c.

◆ TFMINI_I2C_READ_ADDR

#define TFMINI_I2C_READ_ADDR   0x10

Definition at line 65 of file tfmini_i2c.c.

◆ TFMINI_I2C_REG_ADDR

#define TFMINI_I2C_REG_ADDR   0x26

Definition at line 63 of file tfmini_i2c.c.

◆ TFMINI_I2C_REG_VAL

#define TFMINI_I2C_REG_VAL   0x10

Definition at line 64 of file tfmini_i2c.c.

◆ TRIGGER_MODE_REG_ADDR

#define TRIGGER_MODE_REG_ADDR   0x27

Definition at line 104 of file tfmini_i2c.c.

◆ UNIT_OF_DISTANCE_CM

#define UNIT_OF_DISTANCE_CM   0x01

Definition at line 100 of file tfmini_i2c.c.

◆ UNIT_OF_DISTANCE_MM

#define UNIT_OF_DISTANCE_MM   0x00

Definition at line 99 of file tfmini_i2c.c.

◆ UNIT_OF_DISTANCE_REG_ADDR

#define UNIT_OF_DISTANCE_REG_ADDR   0x66

Definition at line 98 of file tfmini_i2c.c.

◆ UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H

#define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H   0x5B

Definition at line 91 of file tfmini_i2c.c.

◆ UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L

#define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L   0x5A

Definition at line 90 of file tfmini_i2c.c.

◆ USE_EXTERNAL_TRIGGER

#define USE_EXTERNAL_TRIGGER   0

Definition at line 105 of file tfmini_i2c.c.

Function Documentation

◆ tfmini_i2c_downlink()

void tfmini_i2c_downlink ( void  )

◆ tfmini_i2c_event()

void tfmini_i2c_event ( void  )

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

polling the ranger at >100Hz)

Definition at line 167 of file tfmini_i2c.c.

References I2CTransDone, I2CTransFailed, I2CTransPending, I2CTransRunning, I2CTransSuccess, i2c_transaction::status, tfmini_i2c, and TFMiniI2C::trans.

◆ tfmini_i2c_init()

◆ tfmini_i2c_periodic()

◆ tfmini_i2c_send_lidar()

static void tfmini_i2c_send_lidar ( 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 130 of file tfmini_i2c.c.

References dev, TFMiniI2C::dist, i2c_transaction::status, TFMiniI2C::status, tfmini_i2c, and TFMiniI2C::trans.

Referenced by tfmini_i2c_init().

+ Here is the caller graph for this function:

Variable Documentation

◆ tfmini_i2c