CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/packages/bsp/sunxi-temp/sunxi_tp_temp.c
Views: 3960
1
#include <sys/mman.h>
2
#include <sys/types.h>
3
#include <sys/stat.h>
4
#include <errno.h>
5
#include <fcntl.h>
6
#include <unistd.h>
7
#include <string.h>
8
#include <stdlib.h>
9
#include <stdio.h>
10
#include <time.h>
11
#include <math.h>
12
#include "mod_mmio.h"
13
14
//#define _debug ;
15
16
const int SoCTempAdjustment = 1447 ;
17
18
int main(int argc, char *argv[])
19
{
20
21
mmio_write(0x01c25000, 0x0027003f) ;
22
mmio_write(0x01c25010, 0x00040000) ;
23
mmio_write(0x01c25018, 0x00010fff) ;
24
mmio_write(0x01c25004, 0x00000010) ;
25
26
#ifdef _debug
27
printf("w 0x01c25000: %08lx\n", mmio_read(0x01c25000)) ;
28
printf("w 0x01c25010: %08lx\n", mmio_read(0x01c25010)) ;
29
printf("w 0x01c25018: %08lx\n", mmio_read(0x01c25018)) ;
30
printf("w 0x01c25004: %08lx\n", mmio_read(0x01c25004)) ;
31
printf("r 0x01c25020: %08lx\n", mmio_read(0x01c25020)) ;
32
#endif
33
34
printf("%0.1f\n",(float)(mmio_read(0x01c25020)-SoCTempAdjustment)/10.0);
35
36
return 0;
37
38
}
39
40