Created
August 13, 2014 08:41
-
-
Save cyndis/66126c9c176b5f94a76f to your computer and use it in GitHub Desktop.
Thermtrip test program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/mman.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#define SOCTHERM_ADDR 0x700e2000 | |
#define THERMTRIP_OFFS 0x80 | |
int main() { | |
int mem_fd; | |
unsigned char *mem; | |
unsigned long val; | |
mem_fd = open("/dev/mem", O_RDWR | O_SYNC); | |
if (mem_fd < 0) { | |
printf("Failed to open mem_fd\n"); | |
return 1; | |
} | |
mem = mmap(NULL, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, | |
mem_fd, SOCTHERM_ADDR); | |
if (mem < 0) { | |
printf("Failed to mmap mem\n"); | |
return 1; | |
} | |
val = *(unsigned long *)(mem + THERMTRIP_OFFS); | |
/* set trip temp to 0 */ | |
val &= ~0xff; | |
*(unsigned long*)(mem + THERMTRIP_OFFS) = val; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment