Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
41d1de1b
Commit
41d1de1b
authored
8 years ago
by
Alexandre Abadie
Browse files
Options
Downloads
Patches
Plain Diff
tests/driver_bmp180: apply changes in driver API
parent
da16943e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/driver_bmp180/Makefile
+3
-7
3 additions, 7 deletions
tests/driver_bmp180/Makefile
tests/driver_bmp180/main.c
+22
-30
22 additions, 30 deletions
tests/driver_bmp180/main.c
with
25 additions
and
37 deletions
tests/driver_bmp180/Makefile
+
3
−
7
View file @
41d1de1b
...
@@ -5,14 +5,10 @@ USEMODULE += bmp180
...
@@ -5,14 +5,10 @@ USEMODULE += bmp180
USEMODULE
+=
xtimer
USEMODULE
+=
xtimer
USEMODULE
+=
printf_float
USEMODULE
+=
printf_float
# set default device parameters in case they are undefined
# set default altitude
TEST_I2C
?=
I2C_DEV
\(
0
\)
TEST_ALTITUDE
?=
158
# altitude in Polytechnique School campus
TEST_MEASURE_OVERSAMPLING
?=
BMP180_ULTRALOWPOWER
TEST_ALTITUDE
?=
158
# altitude in Polytechnique School campus
# export parameters
# export altitude parameter
CFLAGS
+=
-DTEST_I2C
=
$(
TEST_I2C
)
CFLAGS
+=
-DTEST_MEASURE_OVERSAMPLING
=
$(
TEST_MEASURE_OVERSAMPLING
)
CFLAGS
+=
-DTEST_ALTITUDE
=
$(
TEST_ALTITUDE
)
CFLAGS
+=
-DTEST_ALTITUDE
=
$(
TEST_ALTITUDE
)
include
$(RIOTBASE)/Makefile.include
include
$(RIOTBASE)/Makefile.include
This diff is collapsed.
Click to expand it.
tests/driver_bmp180/main.c
+
22
−
30
View file @
41d1de1b
...
@@ -18,47 +18,37 @@
...
@@ -18,47 +18,37 @@
* @}
* @}
*/
*/
#ifndef TEST_I2C
#error "TEST_I2C not defined"
#endif
#ifndef TEST_MEASURE_OVERSAMPLING
#error "TEST_MEASURE_OVERSAMPLING not defined"
#endif
#ifndef TEST_ALTITUDE
#error "TEST_ALTITUDE not defined"
#endif
#include
<stdio.h>
#include
<stdio.h>
#include
<inttypes.h>
#include
<inttypes.h>
#include
"bmp180.h"
#include
"bmp180.h"
#include
"bmp180_params.h"
#include
"xtimer.h"
#include
"xtimer.h"
#include
"board.h"
#include
"board.h"
#define SLEEP_2S (2 * 1000 * 1000u)
/* 2 seconds delay between printf */
int
main
(
void
)
int
main
(
void
)
{
{
bmp180_t
dev
;
bmp180_t
dev
;
int32_t
temperature
,
pressure
,
altitude
,
pressure_0
;
int
result
;
int
result
;
puts
(
"BMP180 test application
\n
"
);
puts
(
"BMP180 test application
\n
"
);
printf
(
"+------------Initializing------------+
\n
"
);
printf
(
"+------------Initializing------------+
\n
"
);
result
=
bmp180_init
(
&
dev
,
TEST_I2C
,
TEST_MEASURE_OVERSAMPLING
);
result
=
bmp180_init
(
&
dev
,
&
bmp180_params
[
0
]
);
if
(
result
==
-
1
)
{
if
(
result
==
-
BMP180_ERR_NOI2C
)
{
puts
(
"[Error] The given i2c is not enabled"
);
puts
(
"[Error] The given i2c is not enabled"
);
return
1
;
return
1
;
}
}
else
if
(
result
==
-
2
)
{
else
if
(
result
==
-
BMP180_ERR_NODEV
)
{
puts
(
"[Error] The sensor did not answer correctly on the given address"
);
puts
(
"[Error] The sensor did not answer correctly on the given address"
);
return
1
;
return
1
;
}
}
else
if
(
result
==
-
BMP180_ERR_NOCAL
)
{
puts
(
"[Error] Cannot read the sensor calibration values"
);
return
1
;
}
else
{
else
{
p
rintf
(
"Initialization successful
\n
\n
"
);
p
uts
(
"Initialization successful
\n
"
);
}
}
printf
(
"+------------Calibration------------+
\n
"
);
printf
(
"+------------Calibration------------+
\n
"
);
...
@@ -76,26 +66,28 @@ int main(void)
...
@@ -76,26 +66,28 @@ int main(void)
printf
(
"
\n
+--------Starting Measurements--------+
\n
"
);
printf
(
"
\n
+--------Starting Measurements--------+
\n
"
);
while
(
1
)
{
while
(
1
)
{
/* Get temperature in deci degrees celsius */
/* Get temperature in deci degrees celsius */
bmp180_read_temperature
(
&
dev
,
&
temperature
);
int16_t
temperature
=
bmp180_read_temperature
(
&
dev
);
/* Get pressure in Pa */
/* Get pressure in Pa */
bmp180_read_pressure
(
&
dev
,
&
pressure
);
uint32_t
pressure
=
bmp180_read_pressure
(
&
dev
);
/* Get pressure at sealevel in Pa */
/* Get pressure at sealevel in Pa */
bmp180_sealevel_pressure
(
&
dev
,
(
int
32
_t
)
TEST_ALTITUDE
,
&
pressure_0
);
uint32_t
pressure_0
=
bmp180_sealevel_pressure
(
&
dev
,
(
int
16
_t
)
TEST_ALTITUDE
);
/* Get altitude in meters */
/* Get altitude in meters */
bmp180_altitude
(
&
dev
,
pressure_0
,
&
altitude
);
int16_t
altitude
=
bmp180_altitude
(
&
dev
,
pressure_0
);
printf
(
"Temperature [°C]: %
.1f
\n
"
printf
(
"Temperature [°C]: %
d.%d
\n
"
"Pressure [hPa]: %
.2f
\n
"
"Pressure [hPa]: %
lu.%d
\n
"
"Pressure at see level [hPa]: %
.2f
\n
"
"Pressure at see level [hPa]: %
lu.%d
\n
"
"Altitude [m]: %i
\n
"
"Altitude [m]: %i
\n
"
"
\n
+-------------------------------------+
\n
"
,
"
\n
+-------------------------------------+
\n
"
,
(
double
)
temperature
/
10
.
0
,
(
double
)
pressure
/
100
.
0
,
(
int
)(
temperature
/
10
),
(
int
)(
temperature
%
10
),
(
double
)
pressure_0
/
100
.
0
,
(
int
)
altitude
);
(
unsigned
long
)
pressure
/
100
,
(
int
)(
pressure
%
100
),
(
unsigned
long
)
pressure_0
/
100
,
(
int
)(
pressure_0
%
100
),
(
int
)
altitude
);
xtimer_
u
sleep
(
SLEEP_2S
);
xtimer_sleep
(
2
);
}
}
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment