Write Application Test Code
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
typedef struct {
int T;
int P;
}BMP180_Result;
int main(int argc,char *argv[])
{
int fd,ret;
int value;
BMP180_Result BMP180_Result;
fd = open("/dev/BMP180", O_RDWR);
if (fd < 0){
perror("open error \n");
return fd;
}
while (1){
read(fd,&BMP180_Result,sizeof(BMP180_Result)); printf("temperature: %d.%dC\n",BMP180_Result.T/10,
BMP180_Result.T%10);
printf("pressure: %dpa\n",BMP180_Result.P);
printf("-----------------------\n");
sleep(1);
}
close(fd);
return 0;
}
Compile the application file, run the command aarch64-none-linux-gnu-gcc app.c -o app, copy the compiled executable file to DEBIX.
Test result
l Execute the application test code, and run the command ./app.