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

Public Member Functions

 LPS25H (device::Device *interface, const char *path)
 
virtual ~LPS25H ()
 
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 Attributes

device::Device_interface
 
- Protected Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes) More...
 

Private Member Functions

void start ()
 Initialise the automatic measurement state machine and start it. More...
 
void stop ()
 Stop the automatic measurement state machine. More...
 
int reset ()
 Reset the device. More...
 
void Run () override
 Perform a poll cycle; collect from the previous measurement and start a new one. More...
 
int write_reg (uint8_t reg, uint8_t val)
 Write a register. More...
 
int read_reg (uint8_t reg, uint8_t &val)
 Read a register. More...
 
int measure ()
 Issue a measurement command. More...
 
int collect ()
 Collect the result of the most recent measurement. More...
 
 LPS25H (const LPS25H &)
 
LPS25H operator= (const LPS25H &)
 

Private Attributes

unsigned _measure_interval {0}
 
ringbuffer::RingBuffer * _reports {nullptr}
 
bool _collect_phase {false}
 
orb_advert_t _baro_topic {nullptr}
 
int _orb_class_instance {-1}
 
int _class_instance {-1}
 
perf_counter_t _sample_perf
 
perf_counter_t _comms_errors
 
sensor_baro_s _last_report {}
 used for info() More...
 

Additional Inherited Members

- 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...
 
- 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 154 of file lps25h.cpp.

Constructor & Destructor Documentation

◆ LPS25H() [1/2]

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

Definition at line 262 of file lps25h.cpp.

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

Referenced by lps25h::start_bus().

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

◆ ~LPS25H()

LPS25H::~LPS25H ( )
virtual

Definition at line 272 of file lps25h.cpp.

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

Here is the call graph for this function:

◆ LPS25H() [2/2]

LPS25H::LPS25H ( const LPS25H )
private

Member Function Documentation

◆ collect()

int LPS25H::collect ( )
private

Collect the result of the most recent measurement.

Definition at line 551 of file lps25h.cpp.

References _baro_topic, _comms_errors, _interface, _last_report, _orb_class_instance, _reports, _sample_perf, ADDR_STATUS_REG, sensor_baro_s::device_id, sensor_baro_s::error_count, device::Device::get_device_id(), hrt_absolute_time(), OK, orb_advertise_multi(), ORB_ID, ORB_PRIO_HIGH, ORB_PRIO_MAX, orb_publish(), perf_begin(), perf_count(), perf_end(), perf_event_count(), cdev::CDev::poll_notify(), sensor_baro_s::pressure, device::Device::read(), status, sensor_baro_s::temperature, and sensor_baro_s::timestamp.

Referenced by read(), and Run().

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

◆ init()

int LPS25H::init ( )
virtual

Reimplemented from cdev::CDev.

Definition at line 293 of file lps25h.cpp.

References _class_instance, _reports, BARO_BASE_DEVICE_PATH, ToneAlarmInterface::init(), OK, cdev::CDev::register_class_devname(), and reset().

Here is the call graph for this function:

◆ ioctl()

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

Definition at line 386 of file lps25h.cpp.

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

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

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

◆ measure()

int LPS25H::measure ( )
private

Issue a measurement command.

Returns
OK if the measurement command was successful.

Definition at line 534 of file lps25h.cpp.

References _comms_errors, ADDR_CTRL_REG2, CTRL_REG2_ONE_SHOT, OK, perf_count(), and write_reg().

Referenced by read(), and Run().

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

◆ operator=()

LPS25H LPS25H::operator= ( const LPS25H )
private

◆ print_info()

void LPS25H::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 646 of file lps25h.cpp.

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

Referenced by lps25h::info().

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

◆ read()

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

Definition at line 327 of file lps25h.cpp.

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

Referenced by lps25h::test().

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

◆ read_reg()

int LPS25H::read_reg ( uint8_t  reg,
uint8_t &  val 
)
private

Read a register.

Parameters
regThe register to read.
valThe value read.
Returns
OK on read success.

Definition at line 637 of file lps25h.cpp.

References _interface, and device::Device::read().

Here is the call graph for this function:

◆ reset()

int LPS25H::reset ( )
private

Reset the device.

Definition at line 470 of file lps25h.cpp.

References ADDR_CTRL_REG1, ADDR_CTRL_REG2, CTRL_REG1_PD, CTRL_REG2_BOOT, CTRL_REG2_SWRESET, and write_reg().

Referenced by init(), and ioctl().

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

◆ Run()

void LPS25H::Run ( )
overrideprivate

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 493 of file lps25h.cpp.

References _collect_phase, _measure_interval, collect(), LPS25H_CONVERSION_INTERVAL, measure(), OK, and start().

Here is the call graph for this function:

◆ start()

void LPS25H::start ( )
private

Initialise the automatic measurement state machine and start it.

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 453 of file lps25h.cpp.

References _collect_phase, and _reports.

Referenced by ioctl(), and Run().

Here is the caller graph for this function:

◆ stop()

void LPS25H::stop ( )
private

Stop the automatic measurement state machine.

Definition at line 464 of file lps25h.cpp.

Referenced by ~LPS25H().

Here is the caller graph for this function:

◆ write_reg()

int LPS25H::write_reg ( uint8_t  reg,
uint8_t  val 
)
private

Write a register.

Parameters
regThe register to write.
valThe value to write.
Returns
OK on write success.

Definition at line 630 of file lps25h.cpp.

References _interface, and device::Device::write().

Referenced by measure(), and reset().

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

Member Data Documentation

◆ _baro_topic

orb_advert_t LPS25H::_baro_topic {nullptr}
private

Definition at line 179 of file lps25h.cpp.

Referenced by collect().

◆ _class_instance

int LPS25H::_class_instance {-1}
private

Definition at line 181 of file lps25h.cpp.

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

◆ _collect_phase

bool LPS25H::_collect_phase {false}
private

Definition at line 177 of file lps25h.cpp.

Referenced by Run(), and start().

◆ _comms_errors

perf_counter_t LPS25H::_comms_errors
private

Definition at line 184 of file lps25h.cpp.

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

◆ _interface

device::Device* LPS25H::_interface
protected

Definition at line 171 of file lps25h.cpp.

Referenced by collect(), ioctl(), LPS25H(), read_reg(), write_reg(), and ~LPS25H().

◆ _last_report

sensor_baro_s LPS25H::_last_report {}
private

used for info()

Definition at line 186 of file lps25h.cpp.

Referenced by collect(), and print_info().

◆ _measure_interval

unsigned LPS25H::_measure_interval {0}
private

Definition at line 174 of file lps25h.cpp.

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

◆ _orb_class_instance

int LPS25H::_orb_class_instance {-1}
private

Definition at line 180 of file lps25h.cpp.

Referenced by collect().

◆ _reports

ringbuffer::RingBuffer* LPS25H::_reports {nullptr}
private

Definition at line 176 of file lps25h.cpp.

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

◆ _sample_perf

perf_counter_t LPS25H::_sample_perf
private

Definition at line 183 of file lps25h.cpp.

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


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