Contiki-NG
|
Files | |
file | bmp-280-sensor.c |
Driver for the Sensortag BMP280 Altimeter / Pressure Sensor. | |
file | bmp-280-sensor.h |
Header file for the Sensortag BMP280 Altimeter / Pressure Sensor. | |
Functions | |
static bool | init (void) |
Initalise the sensor. | |
static bool | enable_sensor (bool enable) |
Enable/disable measurements. | |
static bool | read_data (uint8_t *data, size_t count) |
Read temperature and pressure data. | |
static void | convert (uint8_t *data, int32_t *temp, uint32_t *press) |
Convert raw data to values in degrees C (temp) and Pascal (pressure). | |
static int | value (int type) |
Returns a reading from the sensor. | |
static int | configure (int type, int enable) |
Configuration function for the BMP280 sensor. | |
static int | status (int type) |
Returns the status of the sensor. | |
Variables | |
const struct sensors_sensor | bmp_280_sensor |
Exports a global symbol to be used by the sensor API. | |
Due to the time required for the sensor to startup, this driver is meant to be used in an asynchronous fashion. The caller must first activate the sensor by calling SENSORS_ACTIVATE(). This will trigger the sensor's startup sequence, but the call will not wait for it to complete so that the CPU can perform other tasks or drop to a low power mode.
Once the sensor is stable, the driver will generate a sensors_changed event.
We take readings in "Forced" mode. In this mode, the BMP will take a single measurement and it will then automatically go to sleep.
SENSORS_ACTIVATE must be called again to trigger a new reading cycle
|
static |
Configuration function for the BMP280 sensor.
type | Activate, enable or disable the sensor. See below |
enable | Disable sensor if 0; else, enable sensor otherwise. When type == SENSORS_HW_INIT we turn on the hardware. When type == SENSORS_ACTIVE and enable==1 we enable the sensor. When type == SENSORS_ACTIVE and enable==0 we disable the sensor. |
Definition at line 385 of file bmp-280-sensor.c.
References configure(), ctimer_set(), ctimer_stop(), enable_sensor(), and init().
Referenced by configure().
|
static |
Convert raw data to values in degrees C (temp) and Pascal (pressure).
data | Pointer to a buffer that holds raw sensor data. |
temp | Pointer to a variable where the converted temperature will be written. |
press | Pointer to a variable where the converted pressure will be written. |
Definition at line 274 of file bmp-280-sensor.c.
References value().
|
static |
Enable/disable measurements.
enable | Enable if true; else, disable. |
true | Successful initialization |
false | Error during initialization |
Definition at line 209 of file bmp-280-sensor.c.
References i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write(), and value().
|
static |
Initalise the sensor.
true | Successful initialization |
false | Error during initialization |
Definition at line 173 of file bmp-280-sensor.c.
References i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write(), i2c_arch_write_read(), and value().
|
static |
Read temperature and pressure data.
data | Pointer to a buffer where temperature and pressure will be written. |
count | Number of byes to read. |
true | Successful initialization |
false | Error during initialization |
Definition at line 244 of file bmp-280-sensor.c.
References count, i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write_read(), and value().
|
static |
Returns the status of the sensor.
type | SENSORS_ACTIVE or SENSORS_READY. |
Definition at line 425 of file bmp-280-sensor.c.
|
static |
Returns a reading from the sensor.
type | Parameter of type BMP_280_SENSOR_TYPE, choosing between either measuring temperature or pressure. |
Definition at line 335 of file bmp-280-sensor.c.
References convert(), read_data(), and value().
Referenced by enable_sensor(), init(), and read_data().