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

Driver for the LPS25H barometer connected via I2C or SPI. More...

#include "lps25h.h"
Include dependency graph for lps25h.cpp:

Go to the source code of this file.

Classes

class  LPS25H
 
struct  lps25h::lps25h_bus_option
 

Namespaces

 lps25h
 Local functions in support of the shell command.
 

Macros

#define LPS25H_CONVERSION_INTERVAL   (1000000 / 25) /* microseconds */
 
#define ADDR_REF_P_XL   0x08
 
#define ADDR_REF_P_L   0x09
 
#define ADDR_REF_P_H   0x0A
 
#define ADDR_WHO_AM_I   0x0F
 
#define ADDR_RES_CONF   0x10
 
#define ADDR_CTRL_REG1   0x20
 
#define ADDR_CTRL_REG2   0x21
 
#define ADDR_CTRL_REG3   0x22
 
#define ADDR_CTRL_REG4   0x23
 
#define ADDR_INT_CFG   0x24
 
#define ADDR_INT_SOURCE   0x25
 
#define ADDR_STATUS_REG   0x27
 
#define ADDR_P_OUT_XL   0x28
 
#define ADDR_P_OUT_L   0x29
 
#define ADDR_P_OUT_H   0x2A
 
#define ADDR_TEMP_OUT_L   0x2B
 
#define ADDR_TEMP_OUT_H   0x2C
 
#define ADDR_FIFO_CTRL   0x2E
 
#define ADDR_FIFO_STATUS   0x2F
 
#define ADDR_THS_P_L   0x30
 
#define ADDR_THS_P_H   0x31
 
#define ADDR_RPDS_L   0x39
 
#define ADDR_RPDS_H   0x3A
 
#define RES_CONF_AVGT_8   0x00
 
#define RES_CONF_AVGT_32   0x01
 
#define RES_CONF_AVGT_128   0x02
 
#define RES_CONF_AVGT_512   0x03
 
#define RES_CONF_AVGP_8   0x00
 
#define RES_CONF_AVGP_32   0x04
 
#define RES_CONF_AVGP_128   0x08
 
#define RES_CONF_AVGP_512   0x0C
 
#define CTRL_REG1_SIM   (1 << 0)
 
#define CTRL_REG1_RESET_AZ   (1 << 1)
 
#define CTRL_REG1_BDU   (1 << 2)
 
#define CTRL_REG1_DIFF_EN   (1 << 3)
 
#define CTRL_REG1_PD   (1 << 7)
 
#define CTRL_REG1_ODR_SINGLE   (0 << 4)
 
#define CTRL_REG1_ODR_1HZ   (1 << 4)
 
#define CTRL_REG1_ODR_7HZ   (2 << 4)
 
#define CTRL_REG1_ODR_12HZ5   (3 << 4)
 
#define CTRL_REG1_ODR_25HZ   (4 << 4)
 
#define CTRL_REG2_ONE_SHOT   (1 << 0)
 
#define CTRL_REG2_AUTO_ZERO   (1 << 1)
 
#define CTRL_REG2_SWRESET   (1 << 2)
 
#define CTRL_REG2_FIFO_MEAN_DEC   (1 << 4)
 
#define CTRL_REG2_WTM_EN   (1 << 5)
 
#define CTRL_REG2_FIFO_EN   (1 << 6)
 
#define CTRL_REG2_BOOT   (1 << 7)
 
#define CTRL_REG3_INT1_S_DATA   0x0
 
#define CTRL_REG3_INT1_S_P_HIGH   0x1
 
#define CTRL_REG3_INT1_S_P_LOW   0x2
 
#define CTRL_REG3_INT1_S_P_LIM   0x3
 
#define CTRL_REG3_PP_OD   (1 << 6)
 
#define CTRL_REG3_INT_H_L   (1 << 7)
 
#define CTRL_REG4_P1_DRDY   (1 << 0)
 
#define CTRL_REG4_P1_OVERRUN   (1 << 1)
 
#define CTRL_REG4_P1_WTM   (1 << 2)
 
#define CTRL_REG4_P1_EMPTY   (1 << 3)
 
#define INTERRUPT_CFG_PH_E   (1 << 0)
 
#define INTERRUPT_CFG_PL_E   (1 << 1)
 
#define INTERRUPT_CFG_LIR   (1 << 2)
 
#define INT_SOURCE_PH   (1 << 0)
 
#define INT_SOURCE_PL   (1 << 1)
 
#define INT_SOURCE_IA   (1 << 2)
 
#define STATUS_REG_T_DA   (1 << 0)
 
#define STATUS_REG_P_DA   (1 << 1)
 
#define STATUS_REG_T_OR   (1 << 4)
 
#define STATUS_REG_P_OR   (1 << 5)
 
#define FIFO_CTRL_WTM_FMEAN_2   0x01
 
#define FIFO_CTRL_WTM_FMEAN_4   0x03
 
#define FIFO_CTRL_WTM_FMEAN_8   0x07
 
#define FIFO_CTRL_WTM_FMEAN_16   0x0F
 
#define FIFO_CTRL_WTM_FMEAN_32   0x1F
 
#define FIFO_CTRL_F_MODE_BYPASS   (0x0 << 5)
 
#define FIFO_CTRL_F_MODE_FIFO   (0x1 << 5)
 
#define FIFO_CTRL_F_MODE_STREAM   (0x2 << 5)
 
#define FIFO_CTRL_F_MODE_SFIFO   (0x3 << 5)
 
#define FIFO_CTRL_F_MODE_BSTRM   (0x4 << 5)
 
#define FIFO_CTRL_F_MODE_FMEAN   (0x6 << 5)
 
#define FIFO_CTRL_F_MODE_BFIFO   (0x7 << 5)
 
#define FIFO_STATUS_EMPTY   (1 << 5)
 
#define FIFO_STATUS_FULL   (1 << 6)
 
#define FIFO_STATUS_WTM   (1 << 7)
 
#define NUM_BUS_OPTIONS   (sizeof(bus_options)/sizeof(bus_options[0]))
 

Enumerations

enum  LPS25H_BUS { LPS25H_BUS_ALL = 0, LPS25H_BUS_I2C_INTERNAL, LPS25H_BUS_I2C_EXTERNAL, LPS25H_BUS_SPI }
 

Functions

__EXPORT int lps25h_main (int argc, char *argv[])
 
void lps25h::start (enum LPS25H_BUS busid)
 Start the driver. More...
 
bool lps25h::start_bus (struct lps25h_bus_option &bus)
 start driver for a specific bus option More...
 
struct lps25h_bus_option & lps25h::find_bus (enum LPS25H_BUS busid)
 find a bus structure for a busid More...
 
void lps25h::test (enum LPS25H_BUS busid)
 Perform some basic functional tests on the driver; make sure we can collect data from the sensor in polled and automatic modes. More...
 
void lps25h::reset (enum LPS25H_BUS busid)
 Reset the driver. More...
 
void lps25h::info ()
 Print a little info about the driver. More...
 
void lps25h::usage ()
 Prints info about the driver argument usage. More...
 

Variables

struct lps25h::lps25h_bus_option lps25h::bus_options []
 

Detailed Description

Driver for the LPS25H barometer connected via I2C or SPI.

Definition in file lps25h.cpp.

Macro Definition Documentation

◆ ADDR_CTRL_REG1

#define ADDR_CTRL_REG1   0x20

◆ ADDR_CTRL_REG2

◆ ADDR_CTRL_REG3

#define ADDR_CTRL_REG3   0x22

◆ ADDR_CTRL_REG4

#define ADDR_CTRL_REG4   0x23

Definition at line 57 of file lps25h.cpp.

Referenced by LSM303D::reset(), and LIS3MDL::set_default_register_values().

◆ ADDR_FIFO_CTRL

#define ADDR_FIFO_CTRL   0x2E

Definition at line 68 of file lps25h.cpp.

◆ ADDR_FIFO_STATUS

#define ADDR_FIFO_STATUS   0x2F

Definition at line 69 of file lps25h.cpp.

◆ ADDR_INT_CFG

#define ADDR_INT_CFG   0x24

Definition at line 58 of file lps25h.cpp.

◆ ADDR_INT_SOURCE

#define ADDR_INT_SOURCE   0x25

Definition at line 59 of file lps25h.cpp.

◆ ADDR_P_OUT_H

#define ADDR_P_OUT_H   0x2A

Definition at line 64 of file lps25h.cpp.

◆ ADDR_P_OUT_L

#define ADDR_P_OUT_L   0x29

Definition at line 63 of file lps25h.cpp.

◆ ADDR_P_OUT_XL

#define ADDR_P_OUT_XL   0x28

Definition at line 62 of file lps25h.cpp.

◆ ADDR_REF_P_H

#define ADDR_REF_P_H   0x0A

Definition at line 51 of file lps25h.cpp.

◆ ADDR_REF_P_L

#define ADDR_REF_P_L   0x09

Definition at line 50 of file lps25h.cpp.

◆ ADDR_REF_P_XL

#define ADDR_REF_P_XL   0x08

Definition at line 49 of file lps25h.cpp.

◆ ADDR_RES_CONF

#define ADDR_RES_CONF   0x10

Definition at line 53 of file lps25h.cpp.

◆ ADDR_RPDS_H

#define ADDR_RPDS_H   0x3A

Definition at line 74 of file lps25h.cpp.

◆ ADDR_RPDS_L

#define ADDR_RPDS_L   0x39

Definition at line 73 of file lps25h.cpp.

◆ ADDR_STATUS_REG

#define ADDR_STATUS_REG   0x27

Definition at line 61 of file lps25h.cpp.

Referenced by LPS25H::collect().

◆ ADDR_TEMP_OUT_H

#define ADDR_TEMP_OUT_H   0x2C

Definition at line 66 of file lps25h.cpp.

◆ ADDR_TEMP_OUT_L

#define ADDR_TEMP_OUT_L   0x2B

Definition at line 65 of file lps25h.cpp.

◆ ADDR_THS_P_H

#define ADDR_THS_P_H   0x31

Definition at line 71 of file lps25h.cpp.

◆ ADDR_THS_P_L

#define ADDR_THS_P_L   0x30

Definition at line 70 of file lps25h.cpp.

◆ ADDR_WHO_AM_I

#define ADDR_WHO_AM_I   0x0F

Definition at line 52 of file lps25h.cpp.

Referenced by LPS25H_I2C::probe(), and LSM303D::probe().

◆ CTRL_REG1_BDU

#define CTRL_REG1_BDU   (1 << 2)

Definition at line 88 of file lps25h.cpp.

◆ CTRL_REG1_DIFF_EN

#define CTRL_REG1_DIFF_EN   (1 << 3)

Definition at line 89 of file lps25h.cpp.

◆ CTRL_REG1_ODR_12HZ5

#define CTRL_REG1_ODR_12HZ5   (3 << 4)

Definition at line 94 of file lps25h.cpp.

◆ CTRL_REG1_ODR_1HZ

#define CTRL_REG1_ODR_1HZ   (1 << 4)

Definition at line 92 of file lps25h.cpp.

◆ CTRL_REG1_ODR_25HZ

#define CTRL_REG1_ODR_25HZ   (4 << 4)

Definition at line 95 of file lps25h.cpp.

◆ CTRL_REG1_ODR_7HZ

#define CTRL_REG1_ODR_7HZ   (2 << 4)

Definition at line 93 of file lps25h.cpp.

◆ CTRL_REG1_ODR_SINGLE

#define CTRL_REG1_ODR_SINGLE   (0 << 4)

Definition at line 91 of file lps25h.cpp.

◆ CTRL_REG1_PD

#define CTRL_REG1_PD   (1 << 7)

Definition at line 90 of file lps25h.cpp.

Referenced by LPS25H::reset().

◆ CTRL_REG1_RESET_AZ

#define CTRL_REG1_RESET_AZ   (1 << 1)

Definition at line 87 of file lps25h.cpp.

◆ CTRL_REG1_SIM

#define CTRL_REG1_SIM   (1 << 0)

Definition at line 86 of file lps25h.cpp.

◆ CTRL_REG2_AUTO_ZERO

#define CTRL_REG2_AUTO_ZERO   (1 << 1)

Definition at line 98 of file lps25h.cpp.

◆ CTRL_REG2_BOOT

#define CTRL_REG2_BOOT   (1 << 7)

Definition at line 103 of file lps25h.cpp.

Referenced by LPS25H::reset().

◆ CTRL_REG2_FIFO_EN

#define CTRL_REG2_FIFO_EN   (1 << 6)

Definition at line 102 of file lps25h.cpp.

◆ CTRL_REG2_FIFO_MEAN_DEC

#define CTRL_REG2_FIFO_MEAN_DEC   (1 << 4)

Definition at line 100 of file lps25h.cpp.

◆ CTRL_REG2_ONE_SHOT

#define CTRL_REG2_ONE_SHOT   (1 << 0)

Definition at line 97 of file lps25h.cpp.

Referenced by LPS25H::measure().

◆ CTRL_REG2_SWRESET

#define CTRL_REG2_SWRESET   (1 << 2)

Definition at line 99 of file lps25h.cpp.

Referenced by LPS25H::reset().

◆ CTRL_REG2_WTM_EN

#define CTRL_REG2_WTM_EN   (1 << 5)

Definition at line 101 of file lps25h.cpp.

◆ CTRL_REG3_INT1_S_DATA

#define CTRL_REG3_INT1_S_DATA   0x0

Definition at line 105 of file lps25h.cpp.

◆ CTRL_REG3_INT1_S_P_HIGH

#define CTRL_REG3_INT1_S_P_HIGH   0x1

Definition at line 106 of file lps25h.cpp.

◆ CTRL_REG3_INT1_S_P_LIM

#define CTRL_REG3_INT1_S_P_LIM   0x3

Definition at line 108 of file lps25h.cpp.

◆ CTRL_REG3_INT1_S_P_LOW

#define CTRL_REG3_INT1_S_P_LOW   0x2

Definition at line 107 of file lps25h.cpp.

◆ CTRL_REG3_INT_H_L

#define CTRL_REG3_INT_H_L   (1 << 7)

Definition at line 110 of file lps25h.cpp.

◆ CTRL_REG3_PP_OD

#define CTRL_REG3_PP_OD   (1 << 6)

Definition at line 109 of file lps25h.cpp.

◆ CTRL_REG4_P1_DRDY

#define CTRL_REG4_P1_DRDY   (1 << 0)

Definition at line 112 of file lps25h.cpp.

◆ CTRL_REG4_P1_EMPTY

#define CTRL_REG4_P1_EMPTY   (1 << 3)

Definition at line 115 of file lps25h.cpp.

◆ CTRL_REG4_P1_OVERRUN

#define CTRL_REG4_P1_OVERRUN   (1 << 1)

Definition at line 113 of file lps25h.cpp.

◆ CTRL_REG4_P1_WTM

#define CTRL_REG4_P1_WTM   (1 << 2)

Definition at line 114 of file lps25h.cpp.

◆ FIFO_CTRL_F_MODE_BFIFO

#define FIFO_CTRL_F_MODE_BFIFO   (0x7 << 5)

Definition at line 141 of file lps25h.cpp.

◆ FIFO_CTRL_F_MODE_BSTRM

#define FIFO_CTRL_F_MODE_BSTRM   (0x4 << 5)

Definition at line 139 of file lps25h.cpp.

◆ FIFO_CTRL_F_MODE_BYPASS

#define FIFO_CTRL_F_MODE_BYPASS   (0x0 << 5)

Definition at line 135 of file lps25h.cpp.

◆ FIFO_CTRL_F_MODE_FIFO

#define FIFO_CTRL_F_MODE_FIFO   (0x1 << 5)

Definition at line 136 of file lps25h.cpp.

◆ FIFO_CTRL_F_MODE_FMEAN

#define FIFO_CTRL_F_MODE_FMEAN   (0x6 << 5)

Definition at line 140 of file lps25h.cpp.

◆ FIFO_CTRL_F_MODE_SFIFO

#define FIFO_CTRL_F_MODE_SFIFO   (0x3 << 5)

Definition at line 138 of file lps25h.cpp.

◆ FIFO_CTRL_F_MODE_STREAM

#define FIFO_CTRL_F_MODE_STREAM   (0x2 << 5)

Definition at line 137 of file lps25h.cpp.

◆ FIFO_CTRL_WTM_FMEAN_16

#define FIFO_CTRL_WTM_FMEAN_16   0x0F

Definition at line 133 of file lps25h.cpp.

◆ FIFO_CTRL_WTM_FMEAN_2

#define FIFO_CTRL_WTM_FMEAN_2   0x01

Definition at line 130 of file lps25h.cpp.

◆ FIFO_CTRL_WTM_FMEAN_32

#define FIFO_CTRL_WTM_FMEAN_32   0x1F

Definition at line 134 of file lps25h.cpp.

◆ FIFO_CTRL_WTM_FMEAN_4

#define FIFO_CTRL_WTM_FMEAN_4   0x03

Definition at line 131 of file lps25h.cpp.

◆ FIFO_CTRL_WTM_FMEAN_8

#define FIFO_CTRL_WTM_FMEAN_8   0x07

Definition at line 132 of file lps25h.cpp.

◆ FIFO_STATUS_EMPTY

#define FIFO_STATUS_EMPTY   (1 << 5)

Definition at line 143 of file lps25h.cpp.

◆ FIFO_STATUS_FULL

#define FIFO_STATUS_FULL   (1 << 6)

Definition at line 144 of file lps25h.cpp.

◆ FIFO_STATUS_WTM

#define FIFO_STATUS_WTM   (1 << 7)

Definition at line 145 of file lps25h.cpp.

◆ INT_SOURCE_IA

#define INT_SOURCE_IA   (1 << 2)

Definition at line 123 of file lps25h.cpp.

◆ INT_SOURCE_PH

#define INT_SOURCE_PH   (1 << 0)

Definition at line 121 of file lps25h.cpp.

◆ INT_SOURCE_PL

#define INT_SOURCE_PL   (1 << 1)

Definition at line 122 of file lps25h.cpp.

◆ INTERRUPT_CFG_LIR

#define INTERRUPT_CFG_LIR   (1 << 2)

Definition at line 119 of file lps25h.cpp.

◆ INTERRUPT_CFG_PH_E

#define INTERRUPT_CFG_PH_E   (1 << 0)

Definition at line 117 of file lps25h.cpp.

◆ INTERRUPT_CFG_PL_E

#define INTERRUPT_CFG_PL_E   (1 << 1)

Definition at line 118 of file lps25h.cpp.

◆ LPS25H_CONVERSION_INTERVAL

#define LPS25H_CONVERSION_INTERVAL   (1000000 / 25) /* microseconds */

Definition at line 47 of file lps25h.cpp.

Referenced by LPS25H::ioctl(), LPS25H::read(), and LPS25H::Run().

◆ NUM_BUS_OPTIONS

#define NUM_BUS_OPTIONS   (sizeof(bus_options)/sizeof(bus_options[0]))

Definition at line 686 of file lps25h.cpp.

Referenced by lps25h::find_bus(), lps25h::info(), and lps25h::start().

◆ RES_CONF_AVGP_128

#define RES_CONF_AVGP_128   0x08

Definition at line 83 of file lps25h.cpp.

◆ RES_CONF_AVGP_32

#define RES_CONF_AVGP_32   0x04

Definition at line 82 of file lps25h.cpp.

◆ RES_CONF_AVGP_512

#define RES_CONF_AVGP_512   0x0C

Definition at line 84 of file lps25h.cpp.

◆ RES_CONF_AVGP_8

#define RES_CONF_AVGP_8   0x00

Definition at line 81 of file lps25h.cpp.

◆ RES_CONF_AVGT_128

#define RES_CONF_AVGT_128   0x02

Definition at line 79 of file lps25h.cpp.

◆ RES_CONF_AVGT_32

#define RES_CONF_AVGT_32   0x01

Definition at line 78 of file lps25h.cpp.

◆ RES_CONF_AVGT_512

#define RES_CONF_AVGT_512   0x03

Definition at line 80 of file lps25h.cpp.

◆ RES_CONF_AVGT_8

#define RES_CONF_AVGT_8   0x00

Definition at line 77 of file lps25h.cpp.

◆ STATUS_REG_P_DA

#define STATUS_REG_P_DA   (1 << 1)

Definition at line 126 of file lps25h.cpp.

◆ STATUS_REG_P_OR

#define STATUS_REG_P_OR   (1 << 5)

Definition at line 128 of file lps25h.cpp.

◆ STATUS_REG_T_DA

#define STATUS_REG_T_DA   (1 << 0)

Definition at line 125 of file lps25h.cpp.

◆ STATUS_REG_T_OR

#define STATUS_REG_T_OR   (1 << 4)

Definition at line 127 of file lps25h.cpp.

Enumeration Type Documentation

◆ LPS25H_BUS

enum LPS25H_BUS
Enumerator
LPS25H_BUS_ALL 
LPS25H_BUS_I2C_INTERNAL 
LPS25H_BUS_I2C_EXTERNAL 
LPS25H_BUS_SPI 

Definition at line 147 of file lps25h.cpp.

Function Documentation

◆ lps25h_main()

int lps25h_main ( int  argc,
char *  argv[] 
)

Definition at line 901 of file lps25h.cpp.

References errx, lps25h::info(), LPS25H_BUS_ALL, LPS25H_BUS_I2C_EXTERNAL, LPS25H_BUS_I2C_INTERNAL, LPS25H_BUS_SPI, lps25h::reset(), lps25h::start(), lps25h::test(), and lps25h::usage().

Here is the call graph for this function: