Created
March 9, 2018 15:48
-
-
Save jklmnn/4a30450a4b731cacdf1e06170bb46e61 to your computer and use it in GitHub Desktop.
Test hwio irq handler
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 <stdlib.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <sys/ioctl.h> | |
#include <unistd.h> | |
#include "hwio.h" | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2){ | |
return 1; | |
} | |
int irq = atoi(argv[1]); | |
int fd = open("/dev/hwio", O_RDWR|O_SYNC); | |
if (fd < 0){ | |
perror("open"); | |
return 2; | |
} | |
if(ioctl(fd, IRQ_SET, &irq) < 0){ | |
perror("ioctl irq"); | |
return 3; | |
} | |
while (read(fd, 0, 0) == 0){ | |
printf("irq triggered\n"); | |
} | |
close(fd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment