mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
/*
|
|
* Copyright (C) 2014 Freie Universität Berlin
|
|
* 2018 Inria
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
* directory for more details.
|
|
*/
|
|
|
|
/**
|
|
* @ingroup tests
|
|
* @{
|
|
*
|
|
* @file
|
|
* @brief Test application for the LPS331AP/LPS25HB/LPS22HB/LPS22HH
|
|
* pressure sensor
|
|
*
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
|
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
|
*
|
|
* @}
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "xtimer.h"
|
|
#include "lpsxxx.h"
|
|
#include "lpsxxx_params.h"
|
|
|
|
int main(void)
|
|
{
|
|
lpsxxx_t dev;
|
|
|
|
printf("Test application for %s pressure sensor\n\n", LPSXXX_SAUL_NAME);
|
|
printf("Initializing %s sensor\n", LPSXXX_SAUL_NAME);
|
|
if (lpsxxx_init(&dev, &lpsxxx_params[0]) != LPSXXX_OK) {
|
|
puts("Initialization failed");
|
|
return 1;
|
|
}
|
|
|
|
uint16_t pres;
|
|
int16_t temp;
|
|
while (1) {
|
|
lpsxxx_enable(&dev);
|
|
xtimer_sleep(1); /* wait a bit for the measurements to complete */
|
|
|
|
lpsxxx_read_temp(&dev, &temp);
|
|
lpsxxx_read_pres(&dev, &pres);
|
|
lpsxxx_disable(&dev);
|
|
|
|
int temp_abs = temp / 100;
|
|
temp -= temp_abs * 100;
|
|
|
|
printf("Pressure value: %ihPa - Temperature: %2i.%02i°C\n",
|
|
pres, temp_abs, temp);
|
|
}
|
|
|
|
return 0;
|
|
}
|