Skip to content

Instantly share code, notes, and snippets.

@jklmnn
Created March 9, 2018 15:48
Show Gist options
  • Save jklmnn/4a30450a4b731cacdf1e06170bb46e61 to your computer and use it in GitHub Desktop.
Save jklmnn/4a30450a4b731cacdf1e06170bb46e61 to your computer and use it in GitHub Desktop.
Test hwio irq handler
#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