Repository navigation
Expand file tree
/
Copy pathlps22hb_temp_pres.c
More file actions
120 lines (96 loc) · 2.4 KB
/
Copy pathlps22hb_temp_pres.c
File metadata and controls
120 lines (96 loc) · 2.4 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* lps22hb_temp_pres.c
*
* Created on: 23 gen 2018
* Author: marco.cossali
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include "lps22hb_temp_pres.h"
#include "search_device.h"
void get_name_lps22hb_temp_pres(int n_device){
FILE *file;
char str[1000];
char path[100];
sprintf(path, "/sys/bus/iio/devices/iio:device%d/name", n_device);
file = fopen(path, "r");
fscanf(file, "%[^\n]", str);
printf("Name sensor: %s\n", str);
fclose(file);
}
double get_in_pressure_raw(int n_device){
FILE *file;
double d = 0.0f;
char str[1000];
char path[100];
sprintf(path, "/sys/bus/iio/devices/iio:device%d/in_pressure_raw", n_device);
file = fopen(path, "r");
fscanf(file, "%[^\n]", str);
sscanf(str, "%lf", &d);
fclose(file);
return d;
}
double get_in_pressure_scale(int n_device){
FILE *file;
double d = 0.0f;
char str[1000];
char path[100];
sprintf(path, "/sys/bus/iio/devices/iio:device%d/in_pressure_scale", n_device);
file = fopen(path, "r");
fscanf(file, "%[^\n]", str);
sscanf(str, "%lf", &d);
fclose(file);
return d;
}
double get_in_temp_raw(int n_device){
FILE *file;
double d = 0.0f;
char str[1000];
char path[100];
sprintf(path, "/sys/bus/iio/devices/iio:device%d/in_temp_raw", n_device);
file = fopen(path, "r");
fscanf(file, "%[^\n]", str);
sscanf(str, "%lf", &d);
fclose(file);
return d;
}
double get_in_temp_scale(int n_device){
FILE *file;
double d = 0.0f;
char str[1000];
char path[100];
sprintf(path, "/sys/bus/iio/devices/iio:device%d/in_temp_scale", n_device);
file = fopen(path, "r");
fscanf(file, "%[^\n]", str);
sscanf(str, "%lf", &d);
fclose(file);
return d;
}
int get_sampling_frequency_lps22hb_temp_pres(int n_device){
FILE *file;
double d = 0;
char str[1000];
char path[100];
sprintf(path, "/sys/bus/iio/devices/iio:device%d/sampling_frequency", n_device);
file = fopen(path, "r");
fscanf(file, "%[^\n]", str);
sscanf(str, "%lf", &d);
fclose(file);
return d;
}
void set_sampling_frequency_lps22hb_temp_pres(int n_device, int val_frequenza){
FILE *file;
char str[1000];
char path[100];
sprintf(str, "%d", val_frequenza);
sprintf(path, "/sys/bus/iio/devices/iio:device%d/sampling_frequency", n_device);
file = fopen(path, "w");
fprintf(file,"%s", str);
printf("The new frequency value is: %s\n", str);
fclose(file);
}
void getLIST_sampling_frequency_lps22hb_temp_pres(){
printf("Values: 1 10 25 50 75\n");
}