-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbmp_example.c
39 lines (30 loc) · 949 Bytes
/
bmp_example.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
///@file bmp.c
#include <stdio.h>
#include "BMP280driver/bmp_c.h"
int main(int argc, char *argv[])
{
int8_t rslt;
struct bmp280_dev bmp;
struct bmp280_config conf;
struct bmp280_uncomp_data ucomp_data;
double pres, temp;
// IIR filter
conf.filter = BMP280_FILTER_OFF;
// Temperature over sampling
conf.os_temp = BMP280_OS_2X;
// Pressure over sampling
conf.os_pres = BMP280_OS_16X;
// Setting the output data period as 500us
conf.odr = BMP280_ODR_0_5_MS;
bmp_init(&bmp, &conf, &ucomp_data, USE_SPI);
while (1)
{
// Getting the compensated temperature as floating point value
rslt |= get_values(&temp, &pres, &bmp, &ucomp_data);
printf("Temperature: %.2f C \r\nPressure: %.2f hPa \r\n", temp, pres / 100);
bmp.delay_ms(1000);
}
// Unreachable code, here in case I decide to change it in the future
close_all(bmp);
return rslt;
}