|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
GPIO programming and InterruptsHello , I have written a device driver to make use of the gpio to trigger interrupts. I have attached a part of the whole code. You can try using it. I have attached the makefile as well. Edit the path to kernel source in the makefile. shashi. Date: Tue, 30 Jun 2009 01:39:42 -0700 (PDT) [gpio_interrupt.c] #include<linux/init.h> #include<linux/module.h> #include<linux/kernel.h> #include<linux/slab.h> #include<linux/errno.h> #include<linux/types.h> #include<linux/fs.h> #include<linux/proc_fs.h> #include<linux/fcntl.h> #include<linux/fb.h> #include<linux/interrupt.h> #include<linux/ioctl.h> #include<linux/types.h> #include<linux/fcntl.h> #include<linux/errno.h> #include<linux/gpio.h> #include<linux/mman.h> #include<linux/mm.h> #include<linux/vmalloc.h> #include<linux/slab.h> #define OVERO_SPI_PENDOWN 144 #define OVERO_GPIO1_PENDOWN 145 #define gpio145_pad 0x48002174 #define gpiobank5 0x49056034 MODULE_LICENSE("Dual BSD/GPL"); void gpioint_exit(void); int gpioint_init(void); static int result,temp=0; static irqreturn_t gpio_ISR(int irq,void *dev_id); static irqreturn_t gpio_ISR1(int irq,void *dev_id); static void volatile *gpio5_base1, *gpio5_base2; module_init(gpioint_init); module_exit(gpioint_exit); int fgen_open(struct inode *inode, struct file *filp); int fgen_release(struct inode *inode, struct file *filp); struct file_operations fgen_fops = { open: fgen_open, release: fgen_release }; int gpioint_init() { //int i,j,k; result = register_chrdev(0, "gpio_test",&fgen_fops); printk("gpio:major number %d \n",result); if ((gpio_request(OVERO_SPI_PENDOWN,"gpio_test")) == 0 && (gpio_direction_input(OVERO_SPI_PENDOWN))==0) { gpio_export(OVERO_SPI_PENDOWN,0); } else { printk(KERN_ERR "could not obtain gpio for gpio144 IRQ\n"); return(0); } if ((gpio_request(OVERO_GPIO1_PENDOWN,"gpio_test")) == 0 && (gpio_direction_input(OVERO_GPIO1_PENDOWN))==0) { gpio_export(OVERO_GPIO1_PENDOWN,0); } else { printk(KERN_ERR "could not obtain gpio for gpio145 IRQ\n"); return(0); } if(request_irq(OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN),gpio_ISR, IRQF_TRIGGER_LOW, "gpio_test",NULL)) { printk(" can't load interrupt\n"); } printk("\n IRQ value=%d \n",OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN)); if(request_irq(OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN),gpio_ISR1, IRQF_TRIGGER_HIGH, "gpio_test",NULL)) { printk(" can't load interrupt\n"); } printk("\n IRQ value=%d \n",OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN)); } void gpioint_exit(void) { /* Freeing the major number */ unregister_chrdev(result, "gpio_test"); /* Freeing interrupt */ free_irq(OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN),NULL); free_irq(OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN),NULL); printk("<1>Removing fgen module\n"); } static irqreturn_t gpio_ISR(int irq,void *dev_id) { printk("interrupt acknowledged 144\n"); return IRQ_HANDLED; } static irqreturn_t gpio_ISR1(int irq,void *dev_id) { printk("interrupt acknowledged 145\n"); return IRQ_HANDLED; } int fgen_open(struct inode *inode, struct file *filp) { /* Success */ return 0; } int fgen_release(struct inode *inode, struct file *filp) { /* Success */ return 0; } ------------------------------------------------------------------------------ _______________________________________________ gumstix-users mailing list gumstix-users@... https://lists.sourceforge.net/lists/listinfo/gumstix-users |
|
|
Fwd: GPIO programming and Interruptscant see the attachment .... sorry for that.... here's the code and make file -------gpio_interrupt.c #define OVERO_SPI_PENDOWN 144 #define OVERO_GPIO1_PENDOWN 145 #define gpio145_pad 0x48002174 #define gpiobank5 0x49056034 MODULE_LICENSE("Dual BSD/GPL"); void gpioint_exit(void); int gpioint_init(void); static int result,temp=0; static irqreturn_t gpio_ISR(int irq,void *dev_id); static irqreturn_t gpio_ISR1(int irq,void *dev_id); static void volatile *gpio5_base1, *gpio5_base2; module_init(gpioint_init); module_exit(gpioint_exit); int fgen_open(struct inode *inode, struct file *filp); int fgen_release(struct inode *inode, struct file *filp); struct file_operations fgen_fops = { open: fgen_open, release: fgen_release }; int gpioint_init() { //int i,j,k; result = register_chrdev(0, "gpio_test",&fgen_fops); printk("gpio:major number %d \n",result); if ((gpio_request(OVERO_SPI_PENDOWN,"gpio_test")) == 0 && (gpio_direction_input(OVERO_SPI_PENDOWN))==0) { gpio_export(OVERO_SPI_PENDOWN,0); } else { printk(KERN_ERR "could not obtain gpio for gpio144 IRQ\n"); return(0); } if ((gpio_request(OVERO_GPIO1_PENDOWN,"gpio_test")) == 0 && (gpio_direction_input(OVERO_GPIO1_PENDOWN))==0) { gpio_export(OVERO_GPIO1_PENDOWN,0); } else { printk(KERN_ERR "could not obtain gpio for gpio145 IRQ\n"); return(0); } if(request_irq(OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN),gpio_ISR, IRQF_TRIGGER_LOW, "gpio_test",NULL)) { printk(" can't load interrupt\n"); } printk("\n IRQ value=%d \n",OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN)); if(request_irq(OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN),gpio_ISR1, IRQF_TRIGGER_HIGH, "gpio_test",NULL)) { printk(" can't load interrupt\n"); } printk("\n IRQ value=%d \n",OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN)); } void gpioint_exit(void) { /* Freeing the major number */ unregister_chrdev(result, "gpio_test"); /* Freeing interrupt */ free_irq(OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN),NULL); free_irq(OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN),NULL); printk("<1>Removing fgen module\n"); } static irqreturn_t gpio_ISR(int irq,void *dev_id) { printk("interrupt acknowledged 144\n"); return IRQ_HANDLED; } static irqreturn_t gpio_ISR1(int irq,void *dev_id) { printk("interrupt acknowledged 145\n"); return IRQ_HANDLED; } int fgen_open(struct inode *inode, struct file *filp) { /* Success */ return 0; } int fgen_release(struct inode *inode, struct file *filp) { /* Success */ return 0; } ------------------Makefile obj-m := gpio_interrupt.o all: gpio_interrupt.c make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- -C /home/cedt/Desktop/sakoman_latest_kernels/linux-omap-2.6 M=$(PWD) modules clean: rm *.ko *.o Module.symvers hello.mod.c ---------- Forwarded message ---------- From: shashidhara <shashi.mailme@...> Date: Fri, Jul 3, 2009 at 7:58 PM Subject: [Gumstix-users] GPIO programming and Interrupts To: gumstix-users@... Hello , I have written a device driver to make use of the gpio to trigger interrupts. I have attached a part of the whole code. You can try using it. I have attached the makefile as well. Edit the path to kernel source in the makefile. shashi. Date: Tue, 30 Jun 2009 01:39:42 -0700 (PDT) -- From His Divine Power Comes Forth All This Magical Show Of Name And Form, Of You And Me, Which Casts The Spell Of Pain And Pleasure. Only When We Pierce Through This Magic Veil Do We See The One Who Appears As Many. - SHVETASHVATARA UPANISHAD ------------------------------------------------------------------------------ _______________________________________________ gumstix-users mailing list gumstix-users@... https://lists.sourceforge.net/lists/listinfo/gumstix-users |
|
|
Re: Fwd: GPIO programming and InterruptsHi, thanks alot for your help on this. I will try this out. :) Regards, Chri From: shashidhara <shashi.mailme@...> To: gumstix-users@... Sent: Friday, July 3, 2009 22:56:23 Subject: [Gumstix-users] Fwd: GPIO programming and Interrupts cant see the attachment .... sorry for that.... here's the code and make file -------gpio_interrupt.c #define OVERO_SPI_PENDOWN 144 #define OVERO_GPIO1_PENDOWN 145 #define gpio145_pad 0x48002174 #define gpiobank5 0x49056034 MODULE_LICENSE("Dual BSD/GPL"); void gpioint_exit(void); int gpioint_init(void); static int result,temp=0; static irqreturn_t gpio_ISR(int irq,void *dev_id); static irqreturn_t gpio_ISR1(int irq,void *dev_id); static void volatile *gpio5_base1, *gpio5_base2; module_init(gpioint_init); module_exit(gpioint_exit); int fgen_open(struct inode *inode, struct file *filp); int fgen_release(struct inode *inode, struct file *filp); struct file_operations fgen_fops = { open: fgen_open, release: fgen_release }; int gpioint_init() { //int i,j,k; result = register_chrdev(0, "gpio_test",&fgen_fops); printk("gpio:major number %d \n",result); if ((gpio_request(OVERO_SPI_PENDOWN,"gpio_test")) == 0 && (gpio_direction_input(OVERO_SPI_PENDOWN))==0) { gpio_export(OVERO_SPI_PENDOWN,0); } else { printk(KERN_ERR "could not obtain gpio for gpio144 IRQ\n"); return(0); } if ((gpio_request(OVERO_GPIO1_PENDOWN,"gpio_test")) == 0 && (gpio_direction_input(OVERO_GPIO1_PENDOWN))==0) { gpio_export(OVERO_GPIO1_PENDOWN,0); } else { printk(KERN_ERR "could not obtain gpio for gpio145 IRQ\n"); return(0); } if(request_irq(OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN),gpio_ISR, IRQF_TRIGGER_LOW, "gpio_test",NULL)) { printk(" can't load interrupt\n"); } printk("\n IRQ value=%d \n",OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN)); if(request_irq(OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN),gpio_ISR1, IRQF_TRIGGER_HIGH, "gpio_test",NULL)) { printk(" can't load interrupt\n"); } printk("\n IRQ value=%d \n",OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN)); } void gpioint_exit(void) { /* Freeing the major number */ unregister_chrdev(result, "gpio_test"); /* Freeing interrupt */ free_irq(OMAP_GPIO_IRQ(OVERO_SPI_PENDOWN),NULL); free_irq(OMAP_GPIO_IRQ(OVERO_GPIO1_PENDOWN),NULL); printk("<1>Removing fgen module\n"); } static irqreturn_t gpio_ISR(int irq,void *dev_id) { printk("interrupt acknowledged 144\n"); return IRQ_HANDLED; } static irqreturn_t gpio_ISR1(int irq,void *dev_id) { printk("interrupt acknowledged 145\n"); return IRQ_HANDLED; } int fgen_open(struct inode *inode, struct file *filp) { /* Success */ return 0; } int fgen_release(struct inode *inode, struct file *filp) { /* Success */ return 0; } ------------------Makefile obj-m := gpio_interrupt.o all: gpio_interrupt.c make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- -C /home/cedt/Desktop/sakoman_latest_kernels/linux-omap-2.6 M=$(PWD) modules clean: rm *.ko *.o Module.symvers hello.mod.c ---------- Forwarded message ---------- From: shashidhara <shashi.mailme@...> Date: Fri, Jul 3, 2009 at 7:58 PM Subject: [Gumstix-users] GPIO programming and Interrupts To: gumstix-users@... Hello , I have written a device driver to make use of the gpio to trigger interrupts. I have attached a part of the whole code. You can try using it. I have attached the makefile as well. Edit the path to kernel source in the makefile. shashi. Date: Tue, 30 Jun 2009 01:39:42 -0700 (PDT) -- From His Divine Power Comes Forth All This Magical Show Of Name And Form, Of You And Me, Which Casts The Spell Of Pain And Pleasure. Only When We Pierce Through This Magic Veil Do We See The One Who Appears As Many. - SHVETASHVATARA UPANISHAD Get your preferred Email name! Now you can @ymail.com and @rocketmail.com. ------------------------------------------------------------------------------ _______________________________________________ gumstix-users mailing list gumstix-users@... https://lists.sourceforge.net/lists/listinfo/gumstix-users |
| Free embeddable forum powered by Nabble | Forum Help |