PX4 Firmware
PX4 Autopilot Software http://px4.io
srf02.cpp File Reference

Driver for the SRF02 sonar range finder adapted from the Maxbotix sonar range finder driver (srf02). More...

#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <containers/Array.hpp>
#include <drivers/device/i2c.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <semaphore.h>
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <perf/perf_counter.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_range_finder.h>
#include <drivers/device/ringbuffer.h>
#include <uORB/uORB.h>
#include <uORB/topics/distance_sensor.h>
#include <board_config.h>
Include dependency graph for srf02.cpp:

Go to the source code of this file.

Classes

class  SRF02
 

Namespaces

 srf02
 Local functions in support of the shell command.
 

Macros

#define SRF02_BASEADDR   0x70
 
#define SRF02_BUS_DEFAULT   PX4_I2C_BUS_EXPANSION
 
#define SRF02_DEVICE_PATH   "/dev/srf02"
 
#define SRF02_TAKE_RANGE_REG   0x51
 
#define SRF02_SET_ADDRESS_0   0xA0
 
#define SRF02_SET_ADDRESS_1   0xAA
 
#define SRF02_SET_ADDRESS_2   0xA5
 
#define SRF02_MIN_DISTANCE   (0.20f)
 
#define SRF02_MAX_DISTANCE   (7.65f)
 
#define SRF02_CONVERSION_INTERVAL   100000
 
#define SRF02_INTERVAL_BETWEEN_SUCCESIVE_FIRES   100000
 

Functions

__EXPORT int srf02_main (int argc, char *argv[])
 Driver 'main' command. More...
 
int srf02::reset ()
 Reset the driver. More...
 
int srf02::start (uint8_t rotation)
 Attempt to start driver on all available I2C busses. More...
 
int srf02::start_bus (uint8_t rotation, int i2c_bus)
 Start the driver on a specific bus. More...
 
int srf02::status ()
 Print the driver status. More...
 
int srf02::stop ()
 Stop the driver. More...
 
int srf02::test ()
 Perform some basic functional tests on the driver; make sure we can collect data from the sensor in polled and automatic modes. More...
 
int srf02::usage ()
 Prints info about the driver argument usage. More...
 

Variables

SRF02srf02::g_dev
 

Detailed Description

Driver for the SRF02 sonar range finder adapted from the Maxbotix sonar range finder driver (srf02).

Definition in file srf02.cpp.

Macro Definition Documentation

◆ SRF02_BASEADDR

#define SRF02_BASEADDR   0x70

Definition at line 72 of file srf02.cpp.

Referenced by SRF02::init().

◆ SRF02_BUS_DEFAULT

#define SRF02_BUS_DEFAULT   PX4_I2C_BUS_EXPANSION

Definition at line 73 of file srf02.cpp.

Referenced by srf02_main(), and srf02::usage().

◆ SRF02_CONVERSION_INTERVAL

#define SRF02_CONVERSION_INTERVAL   100000

Definition at line 86 of file srf02.cpp.

Referenced by SRF02::init().

◆ SRF02_DEVICE_PATH

#define SRF02_DEVICE_PATH   "/dev/srf02"

Definition at line 74 of file srf02.cpp.

Referenced by srf02::reset(), srf02::start_bus(), and srf02::test().

◆ SRF02_INTERVAL_BETWEEN_SUCCESIVE_FIRES

#define SRF02_INTERVAL_BETWEEN_SUCCESIVE_FIRES   100000

Definition at line 87 of file srf02.cpp.

Referenced by SRF02::init().

◆ SRF02_MAX_DISTANCE

#define SRF02_MAX_DISTANCE   (7.65f)

Definition at line 84 of file srf02.cpp.

◆ SRF02_MIN_DISTANCE

#define SRF02_MIN_DISTANCE   (0.20f)

Definition at line 83 of file srf02.cpp.

◆ SRF02_SET_ADDRESS_0

#define SRF02_SET_ADDRESS_0   0xA0

Definition at line 78 of file srf02.cpp.

◆ SRF02_SET_ADDRESS_1

#define SRF02_SET_ADDRESS_1   0xAA

Definition at line 79 of file srf02.cpp.

◆ SRF02_SET_ADDRESS_2

#define SRF02_SET_ADDRESS_2   0xA5

Definition at line 80 of file srf02.cpp.

◆ SRF02_TAKE_RANGE_REG

#define SRF02_TAKE_RANGE_REG   0x51

Definition at line 77 of file srf02.cpp.

Referenced by SRF02::measure().

Function Documentation

◆ srf02_main()

__EXPORT int srf02_main ( int  argc,
char *  argv[] 
)

Driver 'main' command.

Definition at line 780 of file srf02.cpp.

References srf02::reset(), SRF02_BUS_DEFAULT, srf02::start(), srf02::start_bus(), srf02::status(), srf02::stop(), srf02::test(), and srf02::usage().

Here is the call graph for this function: