28 #include "generated/airframe.h"
41 static uint8_t sonar_bebop_spi_d[16] = { 0xF0,0xF0,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
90 for(i = 0; i < 8192; i++){
92 if(start_send == 0 && adc_val == 4095)
94 else if(start_send != 0 && stop_send == 0 && adc_val != 4095)
101 if(start_send != 0 && stop_send != 0 && first_peek == 0 && adc_val < lowest_value)
102 lowest_value = adc_val;
103 else if (start_send != 0 && stop_send != 0 && adc_val > lowest_value + 100) {
105 lowest_value = adc_val - 100;
107 else if(start_send != 0 && stop_send != 0 && first_peek != 0 && adc_val+100 < (adc_buffer[first_peek]>>4)) {
113 uint16_t diff = stop_send - start_send;
114 int16_t peek_distance = first_peek - (stop_send - diff/2);
115 if(first_peek <= stop_send || diff > 250)
127 if(peek_distance > 0)
132 #ifdef SENSOR_SYNC_SEND_SONAR
void adc_enable(struct adc_t *adc, uint8_t value)
Start or stop the ADC readings.
int adc_read(struct adc_t *adc, uint16_t *buf, uint16_t size)
Read the ADC buffer from the driver.
static pthread_t sonar_bebop_thread
uint16_t output_length
number of data words to write
static struct spi_transaction sonar_bebop_spi_t
Main include for ABI (AirBorneInterface).
Parrot Bebop Sonar driver.
SPI transaction structure.
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
static void * sonar_bebop_read(void *data)
Read ADC value to update sonar measurement.
enum SPISlaveSelect select
slave selection behavior
arch independent ADC (Analog to Digital Converter) API
static uint8_t sonar_bebop_spi_d[16]
Architecture independent SPI (Serial Peripheral Interface) API.
float distance
Distance measured in meters.
uint16_t input_length
number of data words to read
#define DefaultChannel
SITL.
API to get/set the generic vehicle states.
void sonar_bebop_init(void)
slave is selected before transaction and unselected after
Common code for AP and FBW telemetry.
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint16_t offset
Sonar offset in ADC units.
uint16_t meas
Raw ADC value.
struct SonarBebop sonar_bebop
enum SPITransactionStatus status