Use the BMP in 'forced' mode and reduce startup delay

In forced mode, the BMP will turn itself off after a reading
This commit is contained in:
George Oikonomou 2015-05-01 15:43:33 +01:00
parent 3bbf3cc435
commit cee6c190c5
2 changed files with 7 additions and 8 deletions

View file

@ -136,7 +136,7 @@ static int enabled = SENSOR_STATUS_DISABLED;
static uint8_t sensor_value[SENSOR_DATA_BUF_SIZE]; static uint8_t sensor_value[SENSOR_DATA_BUF_SIZE];
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Wait SENSOR_STARTUP_DELAY clock ticks for the sensor to be ready - ~80ms */ /* Wait SENSOR_STARTUP_DELAY clock ticks for the sensor to be ready - ~80ms */
#define SENSOR_STARTUP_DELAY 11 #define SENSOR_STARTUP_DELAY 3
static struct ctimer startup_timer; static struct ctimer startup_timer;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -187,7 +187,7 @@ enable_sensor(bool enable)
if(enable) { if(enable) {
/* Enable forced mode */ /* Enable forced mode */
val = PM_NORMAL | OSRSP(1) | OSRST(1); val = PM_FORCED | OSRSP(1) | OSRST(1);
} else { } else {
val = PM_OFF; val = PM_OFF;
} }
@ -345,6 +345,7 @@ configure(int type, int enable)
case SENSORS_HW_INIT: case SENSORS_HW_INIT:
enabled = SENSOR_STATUS_INITIALISED; enabled = SENSOR_STATUS_INITIALISED;
init(); init();
enable_sensor(0);
break; break;
case SENSORS_ACTIVE: case SENSORS_ACTIVE:
/* Must be initialised first */ /* Must be initialised first */

View file

@ -42,12 +42,10 @@
* *
* Once the sensor is stable, the driver will generate a sensors_changed event. * Once the sensor is stable, the driver will generate a sensors_changed event.
* *
* Once a reading has been taken, the caller has two options: * We take readings in "Forced" mode. In this mode, the BMP will take a single
* - Turn the sensor off by calling SENSORS_DEACTIVATE, but in order to take * measurement and it will then automatically go to sleep.
* subsequent readings SENSORS_ACTIVATE must be called again *
* - Leave the sensor on. In this scenario, the caller can simply keep calling * SENSORS_ACTIVATE must be called again to trigger a new reading cycle
* value() for subsequent readings, but having the sensor on will consume
* energy
* @{ * @{
* *
* \file * \file