BME280 fixes, codestyle, return code for bme280_init added, Unneeded header files removed

This commit is contained in:
Robert Olsson 2016-09-30 13:17:28 +02:00 committed by Antonio Lignan
parent 1c0e33be79
commit 23a481600a
3 changed files with 9 additions and 15 deletions

View File

@ -33,7 +33,6 @@
* Created : 2016-09-14
*/
#include <stdlib.h>
#include "contiki.h"
#include "lib/sensors.h"
#include "dev/bme280/bme280.h"
@ -55,28 +54,26 @@ value(int type)
return bme280_mea.t_overscale100 / 100;
case BME280_SENSOR_HUMIDITY:
return bme280_mea.h_overscale1024>>10;
return bme280_mea.h_overscale1024 >> 10;
case BME280_SENSOR_PRESSURE:
/* Scale down w. 10 not to overslow the signed int */
#ifdef BME280_64BIT
return bme280_mea.p_overscale256/(256*10);
return bme280_mea.p_overscale256 / (256 * 10);
#else
return bme280_mea.p/10;
return bme280_mea.p / 10;
#endif
}
return 0;
}
static int
status(int type)
{
return 0;
}
static int
configure(int type, int c)
{
bme280_init(BME280_MODE_WEATHER);
return bme280_init(BME280_MODE_WEATHER);
}
SENSORS_SENSOR(bme280_sensor, "bme280", value, configure, status);

View File

@ -39,11 +39,7 @@
*/
#include "contiki.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include "bme280.h"
#include "dev/bme280-arch.h"
@ -159,7 +155,7 @@ bme280_h_overscale1024(int32_t uh)
v1 = (v1 > 419430400 ? 419430400 : v1);
return (uint32_t)(v1 >> 12);
}
void
uint8_t
bme280_init(uint8_t mode)
{
uint8_t buf[26];
@ -167,7 +163,7 @@ bme280_init(uint8_t mode)
/* Do not mess with other chips */
i2c_read_mem(BME280_ADDR, 0xD0, buf, 1);
if(buf[0] != BME280_CHIP_ID) {
return;
return 0;
}
i2c_write_mem(BME280_ADDR, BME280_CNTL_RESET, 0xB6);
@ -201,6 +197,7 @@ bme280_init(uint8_t mode)
bm.dig_h6 = (unsigned char)buf[7];
bm.mode = mode;
return 1;
}
void
bme280_read(uint8_t mode)

View File

@ -30,7 +30,7 @@
*
*
* Author : Robert Olsson rolss@kth.se/robert@radio-sensors.com
*
*
* Created : 2016-09-14
*/
@ -46,7 +46,7 @@
#define BME280_64BIT
#endif
void bme280_init(uint8_t mode);
uint8_t bme280_init(uint8_t mode);
void bme280_read(uint8_t mode);
#ifdef I2C_BME280_ADDR