Contiki-NG
Files | Functions | Variables

Due to the time required for the sensor to startup, this driver is meant to be used in an asynchronous fashion. More...

Files

 
 

Functions

static bool init (void)
 Initalise the sensor. More...
 
static bool enable_sensor (bool enable)
 Enable/disable measurements. More...
 
static bool read_data (uint8_t *data, size_t count)
 Read temperature and pressure data. More...
 
static void convert (uint8_t *data, int32_t *temp, uint32_t *press)
 Convert raw data to values in degrees C (temp) and Pascal (pressure). More...
 
static int value (int type)
 Returns a reading from the sensor. More...
 
static int configure (int type, int enable)
 Configuration function for the BMP280 sensor. More...
 
static int status (int type)
 Returns the status of the sensor. More...
 

Variables

const struct sensors_sensor bmp_280_sensor
 Exports a global symbol to be used by the sensor API.
 

Detailed Description

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

Function Documentation

◆ configure()

static int configure ( int  type,
int  enable 
)
static

Configuration function for the BMP280 sensor.

Parameters
typeActivate, enable or disable the sensor. See below
enableDisable 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 372 of file bmp-280-sensor.c.

◆ convert()

static void convert ( uint8_t *  data,
int32_t *  temp,
uint32_t *  press 
)
static

Convert raw data to values in degrees C (temp) and Pascal (pressure).

Parameters
dataPointer to a buffer that holds raw sensor data.
tempPointer to a variable where the converted temperature will be written.
pressPointer to a variable where the converted pressure will be written.

Definition at line 261 of file bmp-280-sensor.c.

◆ enable_sensor()

static bool enable_sensor ( bool  enable)
static

Enable/disable measurements.

Parameters
enableEnable if true; else, disable.
Returns
Boolean Value descibing whether initialization were successful or not.
Return values
trueSuccessful initialization
falseError during initialization

Definition at line 224 of file bmp-280-sensor.c.

◆ init()

static bool init ( void  )
static

Initalise the sensor.

Returns
Boolean Value descibing whether initialization were successful or not.
Return values
trueSuccessful initialization
falseError during initialization

Definition at line 189 of file bmp-280-sensor.c.

◆ read_data()

static bool read_data ( uint8_t *  data,
size_t  count 
)
static

Read temperature and pressure data.

Parameters
dataPointer to a buffer where temperature and pressure will be written.
countNumber of byes to read.
Returns
Boolean Value descibing whether initialization were successful or not.
Return values
trueSuccessful initialization
falseError during initialization

Definition at line 245 of file bmp-280-sensor.c.

◆ status()

static int status ( int  type)
static

Returns the status of the sensor.

Parameters
typeSENSORS_ACTIVE or SENSORS_READY.
Returns
Current status of the sensor.

Definition at line 412 of file bmp-280-sensor.c.

◆ value()

static int value ( int  type)
static

Returns a reading from the sensor.

Parameters
typeParameter of type BMP_280_SENSOR_TYPE, choosing between either measuring temperature or pressure.
Returns
Sensor data of either Temperature (centi degrees C) or Pressure (Pascal).

Definition at line 322 of file bmp-280-sensor.c.