BME280 fixes, codestyle, return code for bme280_init added, Unneeded header files removed
This commit is contained in:
parent
1c0e33be79
commit
23a481600a
3 changed files with 9 additions and 15 deletions
|
@ -33,7 +33,6 @@
|
||||||
* Created : 2016-09-14
|
* Created : 2016-09-14
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "lib/sensors.h"
|
#include "lib/sensors.h"
|
||||||
#include "dev/bme280/bme280.h"
|
#include "dev/bme280/bme280.h"
|
||||||
|
@ -67,16 +66,14 @@ value(int type)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
status(int type)
|
status(int type)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
configure(int type, int c)
|
configure(int type, int c)
|
||||||
{
|
{
|
||||||
bme280_init(BME280_MODE_WEATHER);
|
return bme280_init(BME280_MODE_WEATHER);
|
||||||
}
|
}
|
||||||
SENSORS_SENSOR(bme280_sensor, "bme280", value, configure, status);
|
SENSORS_SENSOR(bme280_sensor, "bme280", value, configure, status);
|
||||||
|
|
|
@ -39,11 +39,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include "bme280.h"
|
#include "bme280.h"
|
||||||
#include "dev/bme280-arch.h"
|
#include "dev/bme280-arch.h"
|
||||||
|
|
||||||
|
@ -159,7 +155,7 @@ bme280_h_overscale1024(int32_t uh)
|
||||||
v1 = (v1 > 419430400 ? 419430400 : v1);
|
v1 = (v1 > 419430400 ? 419430400 : v1);
|
||||||
return (uint32_t)(v1 >> 12);
|
return (uint32_t)(v1 >> 12);
|
||||||
}
|
}
|
||||||
void
|
uint8_t
|
||||||
bme280_init(uint8_t mode)
|
bme280_init(uint8_t mode)
|
||||||
{
|
{
|
||||||
uint8_t buf[26];
|
uint8_t buf[26];
|
||||||
|
@ -167,7 +163,7 @@ bme280_init(uint8_t mode)
|
||||||
/* Do not mess with other chips */
|
/* Do not mess with other chips */
|
||||||
i2c_read_mem(BME280_ADDR, 0xD0, buf, 1);
|
i2c_read_mem(BME280_ADDR, 0xD0, buf, 1);
|
||||||
if(buf[0] != BME280_CHIP_ID) {
|
if(buf[0] != BME280_CHIP_ID) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_write_mem(BME280_ADDR, BME280_CNTL_RESET, 0xB6);
|
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.dig_h6 = (unsigned char)buf[7];
|
||||||
|
|
||||||
bm.mode = mode;
|
bm.mode = mode;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
bme280_read(uint8_t mode)
|
bme280_read(uint8_t mode)
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
#define BME280_64BIT
|
#define BME280_64BIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void bme280_init(uint8_t mode);
|
uint8_t bme280_init(uint8_t mode);
|
||||||
void bme280_read(uint8_t mode);
|
void bme280_read(uint8_t mode);
|
||||||
|
|
||||||
#ifdef I2C_BME280_ADDR
|
#ifdef I2C_BME280_ADDR
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue