29#include "generated/airframe.h"
35#include "pprzlink/messages.h"
38#ifdef SENSOR_SYNC_SEND
46#ifndef AGL_LIDAR_TFMINI_I2C_ID
47#define AGL_LIDAR_TFMINI_I2C_ID AGL_LIDAR_TFMINI_ID
52#error TFMINI_I2C_DEV needs to be defined
59#ifndef TFMINI_I2C_ADDR
60#define TFMINI_I2C_ADDR 0x10
63#define TFMINI_I2C_REG_ADDR 0x26
64#define TFMINI_I2C_REG_VAL 0x10
65#define TFMINI_I2C_READ_ADDR 0x10
67#define DISTANCE_MODE_REG_ADDR 0x50
68#define DISTANCE_MODE_SHORT 0x00
69#define DISTANCE_MODE_MIDDLE 0x03
70#define DISTANCE_MODE_LONG 0x07
72#define DETECTION_PATTERN_REG_ADDR 0x51
73#define AUTOMATIC_DETECTION_PATTERN 0x00
74#define FIXED_DETECTION_PATTERN 0x01
76#define SETTING_OF_RANGE_LIMIT_REG_ADDR 0x55
77#define RANGE_LIMIT_DISABLED 0x00
78#define RANGE_LIMIT_ENABLED 0x01
80#define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_L 0x56
81#define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_H 0x57
85#define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L 0x58
86#define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H 0x59
90#define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L 0x5A
91#define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H 0x5B
94#define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_L 0x5C
95#define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_H 0x5D
98#define UNIT_OF_DISTANCE_REG_ADDR 0x66
99#define UNIT_OF_DISTANCE_MM 0x00
100#define UNIT_OF_DISTANCE_CM 0x01
102#define SLAVE_ADDRESS_REG_ADDR 0x26
104#define TRIGGER_MODE_REG_ADDR 0x27
105#define USE_EXTERNAL_TRIGGER 0
106#define EXTERNAL_TRIGGER_REG_ADDR 0x01
108#define DEVICE_RESET_ADDR 0x70
111#ifndef TFMINI_I2C_OFFSET
112#define TFMINI_I2C_OFFSET 0.0f
116#ifndef TFMINI_I2C_MIN_RANGE
117#define TFMINI_I2C_MIN_RANGE 0.3f
121#ifndef TFMINI_I2C_MAX_RANGE
122#define TFMINI_I2C_MAX_RANGE 6.0f
156#if PERIODIC_TELEMETRY
249#ifdef SENSOR_SYNC_SEND
Main include for ABI (AirBorneInterface).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Common code for AP and FBW telemetry.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum I2CTransactionStatus status
Transaction status.
bool i2c_blocking_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction and wait for it to complete.
@ I2CTransRunning
transaction is currently ongoing
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
@ I2CTransPending
transaction is pending in queue
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
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.
#define TFMINI_I2C_OFFSET
Ranger offset value for what considered the distance should be zero, e.g. high landing gear to tarmac...
struct TFMiniI2C tfmini_i2c
void tfmini_i2c_downlink(void)
void tfmini_i2c_init(void)
Set the default values at initialization.
void tfmini_i2c_periodic(void)
Get the ranger current distance value.
void tfmini_i2c_event(void)
Ranger event function Basically just check the progress of the transation to prevent overruns during ...
#define TFMINI_I2C_MAX_RANGE
The maximum range for the device to be able to measure.
#define TFMINI_I2C_MIN_RANGE
The minimum range for the device to be able to measure.
#define AGL_LIDAR_TFMINI_I2C_ID
Driver for the TFMini ranging device when used via I2C bus.
float offset
offset to what one considers a zero distance to sensor in [m]
bool update_agl
Do or don't update AGL ABI message.
uint16_t raw_dist
raw non scaled value from sensor
uint16_t strength
strength of reflect signal, not implemented ATM
float dist
Sacled distance measured in [m].
enum TFMiniI2CStatus status
struct i2c_transaction trans
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.