Skip to content

Instantly share code, notes, and snippets.

@cyndis
Created August 13, 2014 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyndis/66126c9c176b5f94a76f to your computer and use it in GitHub Desktop.
Save cyndis/66126c9c176b5f94a76f to your computer and use it in GitHub Desktop.
Thermtrip test program
#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