2018-02-04 14:31:23 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* examples/bmp180/bmp180_main.c
|
|
|
|
*
|
2021-06-16 08:42:54 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2018-02-04 14:31:23 +01:00
|
|
|
*
|
2021-06-16 08:42:54 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-04 14:31:23 +01:00
|
|
|
*
|
2021-06-16 08:42:54 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2018-02-04 14:31:23 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2020-11-13 09:39:49 +01:00
|
|
|
#include <inttypes.h>
|
2018-02-04 14:31:23 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* bmp180_main
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int main(int argc, FAR char *argv[])
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int ret;
|
|
|
|
uint32_t sample;
|
|
|
|
|
2020-06-15 17:22:53 +02:00
|
|
|
fd = open("/dev/press0", O_RDONLY);
|
2018-02-04 14:31:23 +01:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
ret = read(fd, &sample, sizeof(uint32_t));
|
|
|
|
if (ret != sizeof(sample))
|
|
|
|
{
|
2020-06-15 17:22:53 +02:00
|
|
|
perror("Could not read");
|
2018-02-04 14:31:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-11-13 09:39:49 +01:00
|
|
|
printf("Pressure value = %05" PRId32 "\n", sample);
|
2018-02-04 14:31:23 +01:00
|
|
|
|
|
|
|
usleep(500000);
|
|
|
|
}
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
return 0;
|
|
|
|
}
|