PX4 Firmware
PX4 Autopilot Software http://px4.io
MPL3115A2 Class Reference
Inheritance diagram for MPL3115A2:
Collaboration diagram for MPL3115A2:

Public Member Functions

 MPL3115A2 (device::Device *interface, const char *path)
 
 ~MPL3115A2 ()
 
virtual int init ()
 
virtual ssize_t read (struct file *filp, char *buffer, size_t buflen)
 
virtual int ioctl (struct file *filp, int cmd, unsigned long arg)
 
void print_info ()
 Diagnostics - print some basic information about the driver. More...
 
- Public Member Functions inherited from cdev::CDev
 CDev (const char *devname)
 Constructor. More...
 
 CDev (const CDev &)=delete
 
CDevoperator= (const CDev &)=delete
 
 CDev (CDev &&)=delete
 
CDevoperator= (CDev &&)=delete
 
virtual ~CDev ()
 
virtual int open (file_t *filep)
 Handle an open of the device. More...
 
virtual int close (file_t *filep)
 Handle a close of the device. More...
 
virtual ssize_t read (file_t *filep, char *buffer, size_t buflen)
 Perform a read from the device. More...
 
virtual ssize_t write (file_t *filep, const char *buffer, size_t buflen)
 Perform a write to the device. More...
 
virtual off_t seek (file_t *filep, off_t offset, int whence)
 Perform a logical seek operation on the device. More...
 
virtual int ioctl (file_t *filep, int cmd, unsigned long arg)
 Perform an ioctl operation on the device. More...
 
virtual int poll (file_t *filep, px4_pollfd_struct_t *fds, bool setup)
 Perform a poll setup/teardown operation. More...
 
const char * get_devname () const
 Get the device name. More...
 

Protected Member Functions

void start (unsigned delay_us=1)
 Initialize the automatic measurement state machine and start it. More...
 
void stop ()
 Stop the automatic measurement state machine. More...
 
void Run () override
 Perform a poll cycle; collect from the previous measurement and start a new one. More...
 
virtual int measure ()
 Issue a measurement command for the current state. More...
 
virtual int collect ()
 Collect the result of the most recent measurement. More...
 
- Protected Member Functions inherited from cdev::CDev
virtual pollevent_t poll_state (file_t *filep)
 Check the current state of the device for poll events from the perspective of the file. More...
 
virtual void poll_notify (pollevent_t events)
 Report new poll events. More...
 
virtual void poll_notify_one (px4_pollfd_struct_t *fds, pollevent_t events)
 Internal implementation of poll_notify. More...
 
virtual int open_first (file_t *filep)
 Notification of the first open. More...
 
virtual int close_last (file_t *filep)
 Notification of the last close. More...
 
virtual int register_class_devname (const char *class_devname)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
virtual int unregister_class_devname (const char *class_devname, unsigned class_instance)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
void lock ()
 Take the driver lock. More...
 
void unlock ()
 Release the driver lock. More...
 
int unregister_driver_and_memory ()
 First, unregisters the driver. More...
 

Protected Attributes

device::Device_interface
 
unsigned _measure_interval
 
ringbuffer::RingBuffer * _reports
 
bool _collect_phase
 
float _P
 
float _T
 
orb_advert_t _baro_topic
 
int _orb_class_instance
 
int _class_instance
 
perf_counter_t _sample_perf
 
perf_counter_t _measure_perf
 
perf_counter_t _comms_errors
 
- Protected Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes) More...
 

Additional Inherited Members

- Static Protected Attributes inherited from cdev::CDev
static const px4_file_operations_t fops = {}
 Pointer to the default cdev file operations table; useful for registering clone devices etc. More...
 

Detailed Description

Definition at line 64 of file mpl3115a2.cpp.

Constructor & Destructor Documentation

◆ MPL3115A2()

MPL3115A2::MPL3115A2 ( device::Device interface,
const char *  path 
)

Definition at line 149 of file mpl3115a2.cpp.

References _interface, DRV_BARO_DEVTYPE_MPL3115A2, and device::Device::set_device_type().

Referenced by mpl3115a2::start_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~MPL3115A2()

MPL3115A2::~MPL3115A2 ( )

Definition at line 168 of file mpl3115a2.cpp.

References _class_instance, _comms_errors, _interface, _measure_perf, _reports, _sample_perf, cdev::CDev::get_devname(), perf_free(), stop(), and cdev::CDev::unregister_class_devname().

Here is the call graph for this function:

Member Function Documentation

◆ collect()

int MPL3115A2::collect ( )
protectedvirtual

Collect the result of the most recent measurement.

Definition at line 502 of file mpl3115a2.cpp.

References _baro_topic, _comms_errors, _interface, _P, _reports, _sample_perf, _T, CTRL_REG1_OST, sensor_baro_s::device_id, sensor_baro_s::error_count, f(), device::Device::get_device_id(), hrt_absolute_time(), MPL3115A2_CTRL_REG1, OK, ORB_ID, orb_publish(), OUT_P_MSB, perf_begin(), perf_count(), perf_end(), perf_event_count(), cdev::CDev::poll_notify(), sensor_baro_s::pressure, device::Device::read(), sensor_baro_s::temperature, and sensor_baro_s::timestamp.

Referenced by init(), read(), and Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

int MPL3115A2::init ( )
virtual

Reimplemented from cdev::CDev.

Definition at line 191 of file mpl3115a2.cpp.

References _baro_topic, _class_instance, _interface, _orb_class_instance, _reports, BARO_BASE_DEVICE_PATH, collect(), sensor_baro_s::device_id, device::Device::external(), device::Device::get_device_id(), ToneAlarmInterface::init(), measure(), OK, orb_advertise_multi(), ORB_ID, ORB_PRIO_DEFAULT, ORB_PRIO_HIGH, cdev::CDev::register_class_devname(), and warnx.

Here is the call graph for this function:

◆ ioctl()

int MPL3115A2::ioctl ( struct file filp,
int  cmd,
unsigned long  arg 
)
virtual

Definition at line 336 of file mpl3115a2.cpp.

References _interface, _measure_interval, device::Device::ioctl(), IOCTL_RESET, MPL3115A2_CONVERSION_INTERVAL, OK, SENSOR_POLLRATE_DEFAULT, SENSORIOCRESET, SENSORIOCSPOLLRATE, and start().

Referenced by mpl3115a2::reset(), and mpl3115a2::start_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ measure()

int MPL3115A2::measure ( )
protectedvirtual

Issue a measurement command for the current state.

Returns
OK if the measurement command was successful.

Definition at line 480 of file mpl3115a2.cpp.

References _comms_errors, _interface, _measure_perf, device::Device::ioctl(), IOCTL_MEASURE, MPL3115A2_CTRL_REG1, MPL3115A2_CTRL_TRIGGER, perf_begin(), perf_count(), and perf_end().

Referenced by init(), read(), and Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_info()

void MPL3115A2::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 564 of file mpl3115a2.cpp.

References _comms_errors, _measure_interval, _reports, _sample_perf, and perf_print_counter().

Referenced by mpl3115a2::info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

ssize_t MPL3115A2::read ( struct file filp,
char *  buffer,
size_t  buflen 
)
virtual

Definition at line 272 of file mpl3115a2.cpp.

References _measure_interval, _reports, collect(), measure(), and OK.

Referenced by mpl3115a2::test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Run()

void MPL3115A2::Run ( )
overrideprotected

Perform a poll cycle; collect from the previous measurement and start a new one.

This is the heart of the measurement state machine. This function alternately starts a measurement, or collects the data from the previous measurement.

When the interval between measurements is greater than the minimum measurement interval, a gap is inserted between collection and measurement to provide the most recent measurement possible at the next interval.

Definition at line 426 of file mpl3115a2.cpp.

References _collect_phase, _interface, collect(), device::Device::ioctl(), IOCTL_RESET, measure(), MPL3115A2_CONVERSION_INTERVAL, and start().

Here is the call graph for this function:

◆ start()

void MPL3115A2::start ( unsigned  delay_us = 1)
protected

Initialize the automatic measurement state machine and start it.

Parameters
delay_usthe number of microseconds before executing the next cycle
Note
This function is called at open and error time. It might make sense to make it more aggressive about resetting the bus in case of errors.

Definition at line 409 of file mpl3115a2.cpp.

References _collect_phase, and _reports.

Referenced by ioctl(), and Run().

Here is the caller graph for this function:

◆ stop()

void MPL3115A2::stop ( )
protected

Stop the automatic measurement state machine.

Definition at line 420 of file mpl3115a2.cpp.

Referenced by ~MPL3115A2().

Here is the caller graph for this function:

Member Data Documentation

◆ _baro_topic

orb_advert_t MPL3115A2::_baro_topic
protected

Definition at line 92 of file mpl3115a2.cpp.

Referenced by collect(), and init().

◆ _class_instance

int MPL3115A2::_class_instance
protected

Definition at line 94 of file mpl3115a2.cpp.

Referenced by init(), and ~MPL3115A2().

◆ _collect_phase

bool MPL3115A2::_collect_phase
protected

Definition at line 86 of file mpl3115a2.cpp.

Referenced by Run(), and start().

◆ _comms_errors

perf_counter_t MPL3115A2::_comms_errors
protected

Definition at line 98 of file mpl3115a2.cpp.

Referenced by collect(), measure(), print_info(), and ~MPL3115A2().

◆ _interface

device::Device* MPL3115A2::_interface
protected

Definition at line 81 of file mpl3115a2.cpp.

Referenced by collect(), init(), ioctl(), measure(), MPL3115A2(), Run(), and ~MPL3115A2().

◆ _measure_interval

unsigned MPL3115A2::_measure_interval
protected

Definition at line 83 of file mpl3115a2.cpp.

Referenced by ioctl(), print_info(), and read().

◆ _measure_perf

perf_counter_t MPL3115A2::_measure_perf
protected

Definition at line 97 of file mpl3115a2.cpp.

Referenced by measure(), and ~MPL3115A2().

◆ _orb_class_instance

int MPL3115A2::_orb_class_instance
protected

Definition at line 93 of file mpl3115a2.cpp.

Referenced by init().

◆ _P

float MPL3115A2::_P
protected

Definition at line 89 of file mpl3115a2.cpp.

Referenced by collect().

◆ _reports

ringbuffer::RingBuffer* MPL3115A2::_reports
protected

Definition at line 85 of file mpl3115a2.cpp.

Referenced by collect(), init(), print_info(), read(), start(), and ~MPL3115A2().

◆ _sample_perf

perf_counter_t MPL3115A2::_sample_perf
protected

Definition at line 96 of file mpl3115a2.cpp.

Referenced by collect(), print_info(), and ~MPL3115A2().

◆ _T

float MPL3115A2::_T
protected

Definition at line 90 of file mpl3115a2.cpp.

Referenced by collect().


The documentation for this class was generated from the following file: