forked from foxsi/SAAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsbc_temp.cpp
More file actions
27 lines (23 loc) · 696 Bytes
/
sbc_temp.cpp
File metadata and controls
27 lines (23 loc) · 696 Bytes
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
#include <stdio.h>
#include <unistd.h>
#include <sys/io.h> // needed for inb/outb
#define EC_INDEX 0x6f0
#define EC_DATA 0x6f1
int main() {
signed char ambtemp, start;
if (iopl(3))
{ // Linux-specific, e.g. DOS doesn't need this
printf("Failed to get I/O access permissions.\n");
printf("You must be root to run this.\n");
return 1;
}
outb(0x40, EC_INDEX); //access to start/stop register
start = 0x01 | inb(EC_DATA);
outb(start, EC_DATA); //activate monitor mode
printf("AMBIENT\n");
outb(0x26, EC_INDEX); //read out ambient temp
ambtemp = inb(EC_DATA);
printf("%3d\n", ambtemp);
fflush(stdout);
return 0;
}