1 #include <errno.h> 2 #include <fcntl.h> 3 #include <string.h> 4 #include <stdio.h> 5 #include <unistd.h> 6 7 #include <OS.h> 8 9 #include <hpet_interface.h> 10 11 int main() 12 { 13 int hpetFD = open("/dev/misc/hpet", O_RDWR); 14 if (hpetFD < 0) { 15 printf("Cannot open HPET driver: %s\n", strerror(errno)); 16 return -1; 17 } 18 19 uint64 value, newValue; 20 read(hpetFD, &value, sizeof(uint64)); 21 22 snooze(1000000); 23 24 read(hpetFD, &newValue, sizeof(uint64)); 25 printf("HPET counter value difference (1 sec): %lld\n", newValue - value); 26 27 status_t status; 28 bigtime_t timeValue = 2000000; 29 printf("Waiting 2 seconds...\n"); 30 status = ioctl(hpetFD, HPET_WAIT_TIMER, &timeValue, sizeof(timeValue)); 31 printf("%s.\n", strerror(status)); 32 33 timeValue = 5000000; 34 printf("Waiting 5 seconds...\n"); 35 status = ioctl(hpetFD, HPET_WAIT_TIMER, &timeValue, sizeof(timeValue)); 36 printf("%s.\n", strerror(status)); 37 38 timeValue = 1000000; 39 printf("Waiting 1 second...\n"); 40 status = ioctl(hpetFD, HPET_WAIT_TIMER, &timeValue, sizeof(timeValue)); 41 printf("%s.\n", strerror(status)); 42 43 close(hpetFD); 44 45 return 0; 46 } 47 48