Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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