Hi, thanks alot for your help on this. I will try this out. :)


From: shashidhara <shashi.mailme@gmail.com>
To: gumstix-users@lists.sourceforge.net
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


#define gpio145_pad 0x48002174
#define gpiobank5 0x49056034
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;
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)

        } else
                printk(KERN_ERR "could not obtain gpio for gpio144 IRQ\n");
if ((gpio_request(OVERO_GPIO1_PENDOWN,"gpio_test")) == 0 && (gpio_direction_input(OVERO_GPIO1_PENDOWN))==0)

        } else
                printk(KERN_ERR "could not obtain gpio for gpio145 IRQ\n");

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 */
 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;


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


    rm *.ko *.o Module.symvers hello.mod.c

---------- Forwarded message ----------
From: shashidhara <shashi.mailme@gmail.com>
Date: Fri, Jul 3, 2009 at 7:58 PM
Subject: [Gumstix-users] GPIO programming and Interrupts
To: gumstix-users@lists.sourceforge.net

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.


Date: Tue, 30 Jun 2009 01:39:42 -0700 (PDT)
From: cruizbugs <cruiz_bugs@yahoo.com>
Subject: [Gumstix-users]  GPIO programming and Interrupts
To: gumstix-users@lists.sourceforge.net
Message-ID: <24268234.post@talk.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi, I have a few questions.

I have a task to make my gumstix to control a switch.

So, I am using a GPIO 28 to control the external device.
I understand that I can use
# echo "GPIO out set" > /proc/gpio/GPIO28
# echo "GPIO out clear" > /proc/gpio/GPIO28
to control the pin output manually, but what I have to do is to make an
automatic on-off.
I will have to read from a .txt file that contains all the day and time to
this text file will turn on-off the switch every few minutes, i.e.
Monday 01:00 am ON
Monday 01:02 am OFF
Monday 01:05 am ON
Monday 01:59 am OFF

So, regarding this task and since i'm still new to linux,
1. i was thinking what programming language I should use? C or C++ ? which
one easier?

2. i found this http://docwiki.gumstix.org/index.php/Sample_code/C/gpregs
how to run this file ? does this work for verdex pro XL6P ? i'm using GPIO
on consoleLCD16

3. Is there any idea on how to do this effectively?
I was being told to try to use interrupt, for example, for every minute i
will receive an interrupt, then i will read the list of the timing and check
out if I have to on or off the switch.
but the problem is, how to set this kind of interrupt? i heard about kernel
programming, but i'm still quite lost here.
or is there any other better way to do this task?
I saw http://docwiki.gumstix.org/GPIO_event , but i dont think this is
related to what I have to do, right ??

sorry I ask alot.
Thanks you in advance :-)

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.