GPIO setup script (testgpio):

This script will create the files and directories necessary to map GPIO pins to the configfs of the NGW100. It must be run after each boot as the directories and files made are temporary.

#!/bin/sh

echo -n " * setup GPIO PA21 test ...       "
if mkdir /config/gpio/pa21 > /dev/null 2> /dev/null; then
        if ! echo 0 > /config/gpio/pa21/gpio_id; then
                echo "[ FAILED ]"
                exit 1
        fi

        if ! echo 0x200000 > /config/gpio/pa21/pin_mask; then
                echo "[ FAILED ]"
                exit 1
        fi

        if ! echo 0x200000 > /config/gpio/pa21/oe_mask; then
                echo "[ FAILED ]"
                exit 1
        fi

        # go high
        if ! echo 0 > /config/gpio/pa21/enabled; then
                echo "[ FAILED ]"
                exit 1
                fi


        if ! echo 0x200000 > /dev/gpio0; then
                echo "[ FAILED ]"
                exit 1
        fi

        echo "[ OK ]"

        echo 0 >/dev/gpio0;
else
        echo "[ FAILED ]"
        exit 1
fi

golow - Go Low

#!/bin/sh
echo 1 >/config/gpio/pa21/enabled

gohigh - Go High

#!/bin/sh
echo 0 >/config/gpio/pa21/enabled

Setting up the GPIO configfs mapping automatically on boot

create a file called S99mygpio in the /etc/init.d of the flash file system of the NGW100. Then put the contents of the script below in that file. Adjust your home directory as appropriate.

#!/bin/sh
echo `date` testgpio called >>/tmp/testgpio.log
/home/lcox/testgpio
Back to AVR/IO Remote Control of AC Outlet