Barometric pressure sensor class.
More...
Barometric pressure sensor class.
A pressure sensor is a struct pbl_pressure device. Each read runs one conversion; the sensor sleeps in between. Every call into the driver runs with the device lock held, a recursive mutex.
uint32_t pa;
}
const struct pbl_pressure *const PRESSURE
The board's barometric pressure sensor.
int pbl_pressure_read(const struct pbl_pressure *pressure, uint32_t *pa)
Measure the pressure.
◆ pbl_pressure_state
| struct pbl_pressure_state |
Pressure sensor runtime state.
| Data Fields |
|
struct pbl_mutex |
lock |
Device lock. |
◆ pbl_pressure
◆ PBL_PRESSURE_INIT
| #define PBL_PRESSURE_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
.state = &sym##_pressure_state, \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153
Initialize a struct pbl_pressure.
- Parameters
-
◆ PBL_PRESSURE_STATE_DEFINE
| #define PBL_PRESSURE_STATE_DEFINE |
( |
|
sym | ) |
|
Value:
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
struct pbl_mutex lock
Device lock.
Definition pressure.h:42
Pressure sensor runtime state.
Definition pressure.h:40
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50
Define the class state of a pressure sensor.
- Parameters
-
| sym | Symbol of the instance. |
◆ pbl_pressure_read()
| int pbl_pressure_read |
( |
const struct pbl_pressure * |
pressure, |
|
|
uint32_t * |
pa |
|
) |
| |
Measure the pressure.
Runs one conversion, which takes tens of milliseconds and sleeps the caller.
- Parameters
-
| pressure | Pressure sensor. |
| [out] | pa | Pressure in pascals. |
- Returns
- 0, -ENODEV if the sensor is not ready, -ETIMEDOUT if the conversion timed out, or a negative errno.
◆ PRESSURE
The board's barometric pressure sensor.