36#include "generated/airframe.h"
53#define SONAR_BEBOP_INX_DIFF_TO_DIST 340./(2.*160000.)
56#define SONAR_BEBOP_ADC_MAX_VALUE 4095
59#define SONAR_BEBOP_ADC_BUFFER_SIZE 8192
68#ifndef SONAR_BEBOP_TRANSITION_HIGH_TO_LOW
69#define SONAR_BEBOP_TRANSITION_HIGH_TO_LOW 0.8
73#ifndef SONAR_BEBOP_TRANSITION_LOW_TO_HIGH
74#define SONAR_BEBOP_TRANSITION_LOW_TO_HIGH 1.2
78#ifndef SONAR_BEBOP_TRANSITION_COUNT
79#define SONAR_BEBOP_TRANSITION_COUNT 7
85#ifndef SONAR_BEBOP_PEAK_THRESHOLD
86#define SONAR_BEBOP_PEAK_THRESHOLD 50
90#ifndef SONAR_BEBOP_MIN_PEAK_VAL
91#define SONAR_BEBOP_MIN_PEAK_VAL 512
95#define SONAR_BEBOP_MAX_TRANS_TIME 370
101static uint8_t sonar_bebop_spi_d[2][16] = {{ 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
102 { 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00 }};
101static uint8_t sonar_bebop_spi_d[2][16] = {{ 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, {
…};
107#if SONAR_BEBOP_FILTER_NARROW_OBSTACLES
132#if SONAR_BEBOP_FILTER_NARROW_OBSTACLES
150#if SONAR_COMPENSATE_ROTATION
157#if SONAR_BEBOP_FILTER_NARROW_OBSTACLES
165#ifdef SENSOR_SYNC_SEND_SONAR
251#if SONAR_BEBOP_FILTER_NARROW_OBSTACLES
253#ifndef SONAR_BEBOP_FILTER_NARROW_OBSTACLES_JUMP
254#define SONAR_BEBOP_FILTER_NARROW_OBSTACLES_JUMP 0.4f
258#ifndef SONAR_BEBOP_FILTER_NARROW_OBSTACLES_TIME
259#define SONAR_BEBOP_FILTER_NARROW_OBSTACLES_TIME 1.0f
Main include for ABI (AirBorneInterface).
arch independent ADC (Analog to Digital Converter) API
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Common code for AP and FBW telemetry.
enum SPISlaveSelect select
slave selection behavior
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPISelectUnselect
slave is selected before transaction and unselected after
SPI transaction structure.
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
int adc_read(struct adc_t *adc, uint16_t *buf, uint16_t size)
Read the ADC buffer from the driver.
void adc_enable(struct adc_t *adc, uint8_t value)
Start or stop the ADC readings.
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
static uint8_t sonar_bebop_spi_d[2][16]
sonar_bebop_spi_d the waveforms emitted by the sonar waveform 0 is long pulse used at high altitude w...
#define SONAR_BEBOP_ADC_MAX_VALUE
SONAR_BEBOP_ADC_MAX_VALUE maximum ADC output (12 bit ADC)
void sonar_bebop_init(void)
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
uint32_t sonar_bebop_spike_timer
#define SONAR_BEBOP_ADC_BUFFER_SIZE
SONAR_BEBOP_ADC_BUFFER_SIZE ADC buffer size.
void * sonar_bebop_read(void *data)
sonar_bebop_read Read ADC value to update sonar measurement
#define SONAR_BEBOP_MIN_PEAK_VAL
SONAR_BEBOP_MIN_PEAK_VAL minimum adc value of reflected peak that will be cosidered.
#define SONAR_BEBOP_TRANSITION_COUNT
SONAR_BEBOP_TRANSITION_COUNT number of samples before switching mode.
static struct spi_transaction sonar_bebop_spi_t
#define SONAR_BEBOP_MAX_TRANS_TIME
SONAR_BEBOP_MAX_TRANS_TIME maximum time for a reflection to travel and return in the adc measurement ...
static uint8_t pulse_transition_counter
#define SONAR_BEBOP_TRANSITION_LOW_TO_HIGH
SONAR_BEBOP_TRANSITION_LOW_TO_HIGH above this altitude we should use mode 1.
#define SONAR_BEBOP_INX_DIFF_TO_DIST
SONAR_BEBOP_INX_DIFF_TO_DIST conversion from index difference to distance based on time of flight ADC...
#define SONAR_BEBOP_TRANSITION_HIGH_TO_LOW
SONAR_BEBOP_TRANSITION_HIGH_TO_LOW below this altitude we should use mode 0.
struct MedianFilterFloat sonar_filt
uint16_t adc_buffer[SONAR_BEBOP_ADC_BUFFER_SIZE]
#define SONAR_BEBOP_PEAK_THRESHOLD
SONAR_BEBOP_PEAK_THRESHOLD minimum samples from broadcast stop.
struct SonarBebop sonar_bebop
static pthread_mutex_t sonar_mutex
void sonar_bebop_event(void)
Parrot Bebop Sonar driver.
uint16_t meas
Raw ADC value.
float distance
Distance measured in meters.
uint16_t offset
Sonar offset in ADC units.
bool available
New data available.
Architecture independent SPI (Serial Peripheral Interface) API.
Architecture independent timing functions.
#define SysTimeTimerStart(_t)
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.