beagle board expantion header access

I would like to configure expantion headers in beagle board as gpio pins.
Please let me know if any one knows the procedure for how to access the expantion headers.


This weekend I wrote a linux module that does GPIO access. The linux
kernel APIs I used are:
    #include <linux/gpio.h>

    // at setup time
    result = gpio_request(158, "gpiotest");
    allocated = (result >= 0);
    if(allocated) gpio_direction_output(158, 1);

    // to change the output
    if(allocated) gpio_set_value(158, i & 1);

    // at cleanup time
    if(allocated) gpio_free(158);
This code access GPIO 158 which is at pin 12 on the expansion header.
My full code simply toggles it, creating an approximately 500Hz square
wave which is 1.8V p-p.

Here are two articles on doing GPIO access from userspace. I have not
personally tried either method:

Two final notes: first, the pin numbering on the expansion header viewed
from the top is backwards to the standard headers in eagle, so take care
when designing the board you will connect to the beagle. Second, the
I/O voltage is 1.8v, and applying a higher voltage to the pins will
cause physical damage. To interface with 5V systems, I am planning a
daughtercard based on the txb0104 (my project only requires 4 signals)