NB if you want to try out the latest firmware with all the funtions go to the pull down menu item 2
- the downloads here are of historical interest!

Using the four GPIO (General Purpose Input/Output) Pins

What the pins do

The ADM 5120 data sheet shows pins 148,149,150 and 151 to be GPIO

In the Sweex router pin 148 is wired to the Power Status LED
Pin 150 is wired to the reset switch and serves as a data input.

Pins 149 and 151 are unused and may be connected to external equipment
I connected to mine using the same technique as for the second serial port.

Once booted Midge does not make use of the power LED or the reset switch.
So with very little modification you can have four pins that can be inputs or outputs.

The russian site - http://adm5120.narod.ru/led.htm - reports:-

148 GPIO_0---240ohms---|>|------| Ground ----this is led0---(the power LED)
149 GPIO_1---|>|------470ohms---| 3.3Volts------------------------this is led1 edited 20 May
150 GPIO_2---|SWITCH|-----------| Ground-------------this is the reset switch
151 GPIO_3---|>|------470ohms---| 3.3Volts ------------------------this is led3
edited 20 May

|>| represents an LED
I chose 470ohms to keep the extra power demand low

A listing of the /dev directory reveals

crw-r--r-- 1 root root 166, 0 Jan 1 02:00 led0
crw-r--r-- 1 root root 166, 1 Jan 1 02:00 led1
crw-r--r-- 1 root root 166, 2 Jan 1 02:00 led2
crw-r--r-- 1 root root 166, 3 Jan 1 02:00 led3

So leds 0 1 2 and 3 may be controlled - Do not confuse these with the Ethernet status leds - read the data sheet

Control and Measurement

LED Status

To determine the status of an LED in a Telnet session type, for led0 as an example :-
the router responds with one of:-
LED ON (actually it is off)
LED OFF (actually it is on)

Control the LED states - GPIO pins 148, 149, 151

to turn the power LED (led0) on
echo "LED OFF" > /dev/led0 (the GPIO pin 148 goes high [+3.3V])
to turn the power LED off
echo "LED ON" > /dev/led0 (the GPIO pin 148 goes low [0V])
to flash the power LED for 200 msec period
echo "LED BLINK 200" > /dev/led0

to turn the GPIO pin149 LED (led3) on
echo "LED ON" > /dev/led3 (the GPIO pin 149 goes low [0V])
to turn the power LED off
echo "LED OFF" > /dev/led3 (the GPIO pin 149 goes high [+3.3V])
to flash the power LED for 200 msec period
echo "LED BLINK 200" > /dev/led3

Similarly for GPIO pin151 LED led1

Read the Reset Switch status

mknod /dev/switch c 167 2
cat /dev/switch

you receive
if switch is open (pin 150 high)
if switch is closed (pin 150 low)

(please - If any of the above are typed wrongly please email me)

Testing GPIO lines as inputs

The 4 GPIO lines can be set up as logic inputs.
At the same time you can control the 15 ethernet status LEDs as outputs
(see pull down menu item 7)

Electrickery said
From some simple experiments, I get the impression the lines can be used as input and output at the same time, with some limitations. When you put /dev/led2 (this is the pin connected to the reset switch) on, reading the switch via /dev/switch always returns 0, key pressed or not. With /dev/led2 off (echo "LED OFF" > /dev/led2), the actual key status becomes visible.

So to test the GPIO 1 to 3 as inputs do this -
echo "LED OFF" > /dev/ledx
mknod /dev/gpiox c 167 2
cat /dev/gpiox
you receive in the terminal window -
1 if input is high (i.e. pulled high by the internal current source - SEE BELOW *)
0 if input is low (pulled to ground by an external switch or transistor)

I have tested this on
GPIO[1] which is pin149 and called led1 in /dev set x=1 above
GPIO[2] which is pin150 and called led2 in /dev
set x=2 above
GPIO[3] which is pin151 and called led3 in /dev
set x=3 avove

What to wire them to
The data sheet says the GPIO lines are BIDIRECTIONAL
The circuit board connects the RESET line to ground (pressed) or leaves it floating (internal pull up)
When a pin is "ON" and able to drive an LED via a 220ohm resistor connected to +3.3volts it is at 0 volts
So even in the "ON" state you can safely short it to ground - * BUT NOT TO 3.3 volts
You detect the state of the switch in the "OFF" state when the pin, if not pulled to ground by your circuit, is at 3.3 volts.
(In that state there must be an internal current limit since it survives a short to ground!)

Please email me if you find printed confirmation of all of this - there is nothing in the my data sheet about output stage schematics and current limits.
In the GPIO section it also includes the ethernet status LEDs and says they are also BI (bidirectional) but in the LED section it says they are O (outputs)

The following worked for me - try at you own risk

GPIO[1, 2 or 3] line--------collector--NPN transistor--emitter----------ground
Connect transistor base to 2.2Kohm resistor then connect the other end of the resistor to LOW (0V) or HIGH(+3.3V or +5V)
or connect the output of an open collector logic gate to the GPIO line.
NEVER connect GPIO lines 1, 2 and 3 to HIGH via zero resistance
pull them low - but let them float high

NB! GPIO[0] (the power led line) IS DIFFERENT
In the GPIO section of the data sheet it says GPIO[0] (the power LED pin 148 called led0 in /dev) is "internal pulled up"
the others (1, 2, and 3) are "internal pulled down".
I think that means that in the "ON" state the 1, 2 and 3 lines are connected internally to the collector of an NPN transistor the emitter of which is connected to earth and is in a conducting state.
When the internal transistor is not conducting an internal current limited current source pulls the line up to 3.3Volts.

You can drive GPIO[0] from the collector of a pnp transistor with it's emitter connected to +3.3volts.
Connect the base to 2.2Kohm and apply high or low to the other end of the resistor.

GPIO[0] line--------collector--PNP transistor--emitter----------+3.3V NOT 5V
Connect transistor base to 2.2Kohm resistor then connect the other end of the resistor to LOW (0V) or HIGH(+3.3V) NOT 5V
NEVER connect GPIO line 0 to LOW via zero resistance
pull it high - but let it float low