Advertisement
Guest User

irq

a guest
May 18th, 2014
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <linux/init.h>
  2. #include <linux/kernel.h>
  3. #include <linux/gpio.h>
  4. #include <linux/module.h>
  5. #include <linux/interrupt.h>
  6.  
  7. MODULE_LICENSE("GPL");
  8.  
  9. module_init(init_func);
  10. module_exit(exit_func);
  11.  
  12.  
  13. static int init_func(void);
  14. static void exit_func(void);
  15. static irqreturn_t gpio23_handler(int irq, void *dummy);
  16.  
  17.  
  18. static irqreturn_t gpio23_handler(int irq, void *dummy) {
  19.  
  20.   int x;
  21.   x= gpio_get_value(23)
  22.         if(x == 0){
  23.                 printk(KERN_INFO "GPIO_23 has value 0");
  24.         }
  25.  
  26.         return IRQ_HANDLED;
  27. }
  28.  
  29. static int init_func(void) {
  30.  
  31.   gpio_request(24, "tjugofyra");
  32.   gpio_request(23, "tjugotre");
  33.  
  34.   gpio_set_value(24, 0);
  35.  
  36.   int irq23 = gpio_to_irq(23);
  37.  
  38.   if (request_irq(irq23, gpio23_handler, IRQF_TRIGGER_NONE, "GPIO_23", NULL)) {
  39.           printk(KERN_INFO "GPIO_23 irq fel");
  40.   }
  41.  
  42.  
  43.   return 0;
  44. }
  45.  
  46.  
  47.  
  48. static void exit_func(void) {
  49.  
  50.     int irq23 = gpio_to_irq(23);
  51.     free_irq(irq23, NULL);
  52.     gpio_free(23);
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement